Skip to content

Instantly share code, notes, and snippets.

View wudi's full-sized avatar
🎯
Focusing

Di Wu wudi

🎯
Focusing
View GitHub Profile
@wudi
wudi / random.js
Created October 13, 2014 09:42
JS 生成范围内随机整数
var randNum = function (min, max) {
return parseInt(Math.random() * (max - min + 1) + min, 10);
};
@wudi
wudi / new_gist_file_0
Created October 11, 2014 07:51
iOS程序字体与ps设计字体换算
一,ps和pt转换px:相对长度单位。像素(Pixel)。(PS字体)
pt:绝对长度单位。点(Point)。(iOS字体)公式如下:pt=(px/96)*72。二,字体间转换1in = 2.54cm = 25.4 mm = 72pt = 6pc
具体换算是:
Points Pixels Ems Percent
6pt 8px 0.5em 50%
7pt 9px 0.55em 55%
7.5pt 10px 0.625em 62.5%
8pt 11px 0.7em 70%
9pt 12px 0.75em 75%
10pt 13px 0.8em 80%
@wudi
wudi / nsobject_to_string.php
Last active August 29, 2015 14:06
NSObject To String
<?php
$str = '82a16300 a16482a9 61737365 745f6b65 79da002a 31343130 37383632 33333538 61393737 63363732 61393836 61353333 39303238 61363035 35343261 3832a564 65627567 da005968 7474703a 2f2f3139 322e3136 382e3738 2e31373a 38303830 2f63646e 5f617373 6574732f 61756469 6f2f3230 31343039 2f31352f 62633537 61353430 34333461 31656534 38386132 30386632 64643733 37316135 2e616d72';
$str = str_replace(' ','',$str);
for($i =0; $i<strlen($str); $i+=2){
$char = substr($str, $i,2);
$dec_str = hexdec($char);
echo chr($dec_str);
}
<?php
$dbConnection = new PDO('mysql:dbname=dbtest;host=127.0.0.1;charset=utf8', 'user', 'pass');
$dbConnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);