Oct 16 2010
- 04/10/2011 - Updated application.js and application.rb thanks to @rebo's comments
In this article, I will walk through some simple steps to get a [demo app][2] up and running with [Backbone.js][3] and [Sinatra][4] on [Heroku][5].
<?php | |
/** | |
* Return the number of pages of a PDF. | |
* | |
* Imagick::pingImage() takes too much when dealing with big files. | |
* | |
* Command to execute: | |
* | |
* gs -q -dNODISPLAY -c "(%s) (r) file runpdfbegin pdfpagecount = quit" |
import java.util.Map; | |
import java.util.Map.Entry; | |
import java.util.Optional; | |
import java.util.Random; | |
import java.util.concurrent.ConcurrentHashMap; | |
import java.util.stream.Collectors; | |
/** | |
* <pre> | |
* 转盘抽奖算法demo |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Fix iPhone4/iOS6 browser viewport appear black or white area bug!!</title> | |
<!-- | |
关键是要注意在初始化页面时设置 viewport width=320.1, 非常之诡异! | |
PS: 在查了N多资料, N多尝试后发现, 其实只要不将width设置成320或device-width即可, 其他任何数字都可以! 不设置width这个属性也可以! |
#with regex from http://detectmobilebrowsers.com/ | |
#map suggestion via kolbyjack | |
#not tested | |
map $http_user_agent $mobile_agent{ | |
default 0; | |
~* "android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino" 1; | |
~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibr |