This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def download_file(url): | |
r = requests.get(url) | |
if r.status_code != 200 or len(r.content) < 100: | |
raise 'Download Failed' | |
if re.search('\.png', url): | |
file_type = 'png' | |
elif re.search('\.gif', url): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* An Octal Escape Sequence looks like this \345\225\206 | |
* The unicode hex value is 0xE5 0x95 0x86 | |
* The octal value 345 is hexal value E5 | |
* The octal value 225 is hexal value 95 | |
* The octal value 206 is hexal value 86 | |
* This function converts octal values to hexal values first | |
* Then join the hexal values into an url escape code %E5%95%86, | |
* which HTML/Javascript is able to output properly | |
* WARNING: not the safest method. If the string has \xxx but not |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible " be iMproved, required | |
filetype off " required | |
let mapleader = "\<Space>" | |
" Use Vundle to install packages, the path may be ~/.vim/bundle/vundle depending on how vundle was installed | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" Bundles/Plugins | |
Plugin 'gmarik/Vundle.vim' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// alterkeys.c | |
// http://osxbook.com | |
// | |
// Complile using the following command line: | |
// gcc -Wall -o alterkeys alterkeys.c -framework ApplicationServices | |
// | |
// You need superuser privileges to create the event tap, unless accessibility | |
// is enabled. To do so, select the "Enable access for assistive devices" | |
// checkbox in the Universal Access system preference pane. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cmd": ["/absolute-file-path-to-your-env/bin/python", "$file"], | |
"selector": "source.python", | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "dart:mirrors"; | |
MirrorSystem mirrors = currentMirrorSystem(); | |
LibraryMirror lm = mirrors.findLibrary(new Symbol('libraryName')); | |
ClassMirror cm=lm.declarations[new Symbol('ClassName')] as ClassMirror; | |
InstanceMirror im=cm.newInstance(const Symbol(''), []); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import re | |
class mysql_to_mssql_converter: | |
""" | |
Python script for converting MySQL dump into MSSQL compatible scripts | |
Based on my project, I know the following points need to be converted | |
1. ` need to be removed | |
2. ENGINE=InnoDB etc need to be removed | |
3. int(size), (size) is not supported for int, need to be removed. | |
4. AUTO_INCREMENT need to be changed to IDENTITY(1,1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var width = screen.width; | |
if (width >= 900) { | |
$('meta[name=viewport]').attr('content','width=device-width, initial-scale=1'); | |
} else if (width < 900 && width >= 700) { // iPad in portrait mode | |
$('meta[name=viewport]').attr('content','width=device-width, initial-scale=0.8'); | |
} else if (width <700) { // anything smaller than 700px in width | |
$('meta[name=viewport]').attr('content','width=device-width, initial-scale=0.4'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newgroup your_group | |
setfacl -dR -m mask:007 /path/to/shared/folder | |
chmod g+s /path/to/shared/folder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List what zones are there | |
# ls /usr/share/zoneinfo/Asia/ | |
#if the localtime is already set, rename it to something else | |
# mv /etc/localtime /etc/_localtime | |
# create a symbol link for the localtime | |
ln -s /usr/share/zoneinfo/Asia/Singapore /etc/localtime |