Skip to content

Instantly share code, notes, and snippets.

View ophentis's full-sized avatar

Willy Tseng ophentis

View GitHub Profile
@ophentis
ophentis / gist:950793
Created May 1, 2011 19:39
javascript base64 images
1x1 image
white
data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAACAkwBADs=
data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==
black
data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==
transparent
@ophentis
ophentis / gist:951526
Created May 2, 2011 12:25
RFC2397: The "data" url scheme
syntax:
dataurl := "data:" [ mediatype ] [ ";base64" ] "," data
mediatype := [ type "/" subtype ] *( ";" parameter )
data := *urlchar
parameter := attribute "=" value
e.g.
data:text/html,<html><body><p><b>Hello, world!</b></p></body></html>
data:text/plain;charset=UTF-8;base64,5L2g5aW977yM5Lit5paH77yB
@ophentis
ophentis / gist:1037197
Created June 21, 2011 03:43
php multibyte truncate (chineese)
if(mb_strlen($string,$charset) > $length) {
$string = mb_substr($string,0,$length,$charset);
return preg_replace('/(\p{Mc}|\p{Zl})+$/u','',$string).$suffix;
} else {
return $string;
}
@ophentis
ophentis / gist:1039688
Created June 22, 2011 08:18
fire text effect
text-shadow: 0 0 20px #fefcc9, 10px -10px 30px #feec85, -20px -20px 40px #ffae34, 20px -40px 50px #ec760c, -20px -60px 60px #cd4606, 0 -80px 70px #973716, 10px -90px 80px #451b0e;
@ophentis
ophentis / gist:1048487
Created June 27, 2011 08:14
xslt output html5 doctype
<xsl:output doctype-system="about:legacy-compat" method="html"/>
@ophentis
ophentis / gist:1077572
Created July 12, 2011 07:48
[xslt] data to table
<xsl:for-each select="data/entry[position() mod 3 = 1]">
<tr>
<xsl:for-each select=". | following-sibling::entry[position() &lt; 3]">
<td>
<xsl:value-of select="@id"/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
@ophentis
ophentis / gist:1440559
Created December 6, 2011 23:25
TW perosnal id validator, 身份證字號檢查
//身份證字號檢查
function isValid(id) {
return typeof id === 'string' && id.match(/^[a-z][12][0-9]{8}$/i) && (function(id) {
var hash = [1, 10, 19, 28, 37, 46, 55, 64, 39, 73, 82, 2, 11, 20, 48, 29, 38, 47, 56, 65, 74, 83, 21, 3, 12, 30][id.charCodeAt(0) - 65];
for (var i = 1; i < 9; i++) {
hash += (9 - i) * (id.charCodeAt(i) - 48);
}
return (hash + id.charCodeAt(9) - 48) % 10 === 0;
})(id);
}
@ophentis
ophentis / gist:1501067
Created December 20, 2011 10:19
remove .DS_Store recursively from current folder
sudo find . -name ".DS_Store" -depth -exec rm {} \;
@ophentis
ophentis / gist:1604979
Created January 13, 2012 07:14
packaging commands
tar -cvf ../filename.tar .
@ophentis
ophentis / gist:2773972
Created May 23, 2012 08:47
how to configure an existing git repo to be shared with unix group
#by David UnderHill @ http://stackoverflow.com/questions/3242282/how-to-configure-an-existing-git-repo-to-be-shared-by-a-unix-group
ex: share a git repo to a group called foo
chgrp -R foo repodir # set the group
chmod -R g+rw repodir # allow the group to read/write
chmod g+s `find repodir -type d` # new files get group id of directory
config.sharedRepository = true