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 datetime, time | |
| def convert_enddate_to_seconds(self, ts): | |
| """Takes ISO 8601 format(string) and converts into epoch time.""" | |
| dt = datetime.datetime.strptime(ts[:-7],'%Y-%m-%dT%H:%M:%S.%f')+\ | |
| datetime.timedelta(hours=int(ts[-5:-3]), | |
| minutes=int(ts[-2:]))*int(ts[-6:-5]+'1') | |
| seconds = time.mktime(dt.timetuple()) + dt.microsecond/1000000.0 | |
| return seconds |
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 extract(dictin): | |
| dictout={} | |
| for key, value in dictin.iteritems(): | |
| print('key:%s \t Value:%s' % (key,value)) | |
| if isinstance(value, dict): | |
| extract(value, dictout) | |
| elif isinstance(value, list): | |
| for i in value: | |
| extract(i,dictout) |
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 hex_to_rgb(value): | |
| ... lv = len(value) | |
| ... return tuple(int(value[i:i+lv/3], 16) for i in range(0, lv, lv/3)) | |
| ... | |
| >>> | |
| >>> hex_to_rgb("FFFFFF") | |
| (255, 255, 255) | |
| >>> def rgb_to_hex(rgb): | |
| ... return '%02x%02x%02x' % rgb |
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 urllib, urllib2 | |
| import simplejson as json | |
| import datetime url = 'https://sandbox.itunes.apple.com/verifyReceipt' receipt_data = 'receipt_data' password = 'your_password' | |
| data = { "receipt-data": receipt_data, "password": password } | |
| headers = {'Content-Type': 'text/Json; charset=utf-8'} | |
| dataj = json.dumps(data) | |
| request = urllib2.Request(url, dataj, headers) | |
| # In case you are wondering what is being sent and the format |
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 os | |
| def unique_id(): | |
| return os.urandom(10).encode('hex') | |
| print " Printing Unique_id" | |
| a=unique_id() | |
| print a | |
| OR | |
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 os | |
| import sys | |
| import csv | |
| def opencsv(filename): | |
| tfile = open(filename, "r") | |
| line = tfile.readline() | |
| tfile.close() | |
| if line[0] == '"': | |
| quote_char = '"' |
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 statements | |
| from BaseHTTPServer import HTTPServer | |
| from BaseHTTPServer import BaseHTTPRequestHandler | |
| from socket import gethostname, gethostbyname | |
| import re | |
| import os | |
| import csv | |
| 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
| import re | |
| def check_mdn(mdn, mdn_re = re.compile('^\d{10,15}$')): | |
| ''' Check if MDN is acceptable | |
| ''' | |
| print " MDN: %s " % mdn | |
| if mdn_re.match(str(mdn)): | |
| print " %s is fine " % mdn | |
| return True | |
| else: |
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
| #Newbie programmer | |
| def factorial(x): | |
| if x == 0: | |
| return 1 | |
| else: | |
| return x * factorial(x - 1) | |
| print factorial(6) | |
| #First year programmer, studied Pascal |
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 time | |
| import struct | |
| import socket | |
| import hashlib | |
| import sys | |
| from select import select | |
| import re | |
| import logging | |
| from threading import Thread | |
| import signal |
OlderNewer