This file contains 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains 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
syntax enable | |
syntax on | |
set nu | |
set smartindent | |
set tabstop=4 | |
set shiftwidth=4 | |
set expandtab | |
set softtabstop=4 | |
set hlsearch |
This file contains 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 datetime | |
import time | |
#Get now time string | |
timestr = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") | |
#Calc time delta | |
t1 = datetime.datetime.now() | |
time.sleep(3) | |
t2 = datetime.datetime.now() |
This file contains 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 concurrent.futures | |
import math | |
import time | |
PRIMES = [ | |
112272535095293, | |
112272535095293, | |
112582705942171, | |
112272535095293, | |
115280095190773, |
This file contains 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
placeholders = ', '.join(['%s'] * len(myDict)) | |
columns = ', '.join(myDict.keys()) | |
sql = "INSERT INTO %s ( %s ) VALUES ( %s )" % (table, columns, placeholders) | |
cursor.execute(sql, myDict.values()) |
This file contains 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 codecs | |
import chardet | |
bytes = min(32, os.path.getsize(filename)) | |
raw = open(filename, 'rb').read(bytes) | |
if raw.startswith(codecs.BOM_UTF8): | |
encoding = 'utf-8-sig' | |
else: | |
result = chardet.detect(raw) |
This file contains 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 random | |
def sort(a,low,high): | |
if low>=high: | |
return | |
i = low | |
j = high | |
mid_value = a[i] | |
while(True): |
This file contains 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
# | |
# script to register Python 2.0 or later for use with win32all | |
# and other extensions that require Python registry settings | |
# | |
# written by Joakim Loew for Secret Labs AB / PythonWare | |
# | |
# source: | |
# http://www.pythonware.com/products/works/articles/regpy20.htm | |
# | |
# modified by Valentine Gogichashvili as described in http://www.mail-archive.com/[email protected]/msg10512.html |
This file contains 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 win32print | |
import win32ui | |
from PIL import Image, ImageWin | |
PHYSICALWIDTH = 110 | |
PHYSICALHEIGHT = 111 | |
printer_name = win32print.GetDefaultPrinter () | |
file_name = "new.jpg" |