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
function sort_by(attr) { | |
return function(a, b) { | |
if( a[attr] > b[attr]) { | |
return 1; | |
} else if( a[attr] < b[attr] ) { | |
return -1; | |
} | |
return 0; | |
} | |
} |
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
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Write tags to files | |
Usage: | |
tag.py "TagName" FileName1 FileName2 | |
You can use wildcards for the file name. Use quotes if spaces in tags. | |
To check if it worked, use xattr -l FileName |
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
#!/usr/bin/python | |
""" | |
Dropbox File Transfer Comparison - POC | |
This program compares the speed of uploading multiple files to dropbox using | |
both queued and parallel connections per file. | |
""" | |
import time |
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 signature(word): | |
""" Returns the sorted word """ | |
return ''.join(sorted(word)) | |
def anagrams(word): | |
""" Returns a list of all anagrams for a given word """ | |
words = [w.strip().lower() for w in open('words.txt')] |
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 ugly_number(n): | |
""" Returns Nth ugly number """ | |
assert n > 0, 'The argument must be greater than zero.' | |
list = [0]*n | |
i2, i3, i5 = 0, 0, 0 | |
w2, w3, w5 = 2, 3, 5 | |
w, list[0] = 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
import re | |
units = { | |
0: 'Zero', 1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', 6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine' | |
} | |
tens = { | |
10: 'Ten', 11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', 15: 'Fifteen', 16: 'Sixteen', | |
17: 'Seventeen', 18: 'Eighteen', 19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', 50: 'Fifty', | |
60: 'Sixty', 70: 'Seventy', 80: 'Eighty', 90: 'Ninety' | |
} |
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 sum(args): | |
""" Returns sum of all elements of a given list, recursively """ | |
if len(args) == 0: | |
return 0 | |
return args[0] + sum(args[1:]) | |
if __name__ == "__main__": |
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
<?php | |
try { | |
$options = array( | |
'soap_version'=>SOAP_1_2, | |
'exceptions'=>true, | |
'trace'=>1, | |
'cache_wsdl'=>WSDL_CACHE_NONE | |
); | |
$client = new SoapClient('http://soap.service-provider.com/endpoint.asmx?WSDL', $options); | |
} |
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
#!/usr/bin/env python | |
import os, sys | |
import hashlib | |
def usage(full=False): | |
msg = '' | |
if full: | |
msg += 'Computes hash of a string.' + os.linesep |
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
<?php | |
$http_client_ip = ''; | |
$http_x_forwarded_for = ''; | |
$remote_addr = $_SERVER['REMOTE_ADDR']; | |
$remote_host = ''; | |
$remote_port = $_SERVER['REMOTE_PORT']; | |
$remote_user = ''; | |
$redirect_remote_user = ''; | |
$http_user_agent = $_SERVER['HTTP_USER_AGENT']; |