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 socket | |
| class Proxy: | |
| serversock_port = 987654 | |
| def __init__(self, host='localhost', port=1234, req_func=None, resp_func=None): | |
| self.browsersock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| self.browsersock.bind((host,port)) | |
| print 'listening %s:%d' % (host,port) |
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 mergesort(array, start=None, end=None): | |
| if start is None and end is None: | |
| return mergesort(array,0,len(array)-1) | |
| else: | |
| if start == end: return | |
| middle = start+(end-start)/2 | |
| mergesort(array,start,middle) | |
| mergesort(array,middle+1,end) | |
| merge(array,start,middle,middle+1,end) | |
| return array |
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
| George Washington | |
| John Adams | |
| Thomas Jefferson | |
| James Madison | |
| James Monroe | |
| John Quincy Adams | |
| Andrew Jackson | |
| Martin Van Buren | |
| William H. Harrison | |
| John Tyler |
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 quicksort(array, start=None, end=None): | |
| """end is the index of the last element to be sorted""" | |
| if start is None and end is None: | |
| quicksort(array,0,len(array)-1) | |
| return array | |
| else: | |
| if start < end: | |
| pivot_index = partition(array,start,end) | |
| quicksort(array,start,pivot_index-1) | |
| quicksort(array,pivot_index+1,end) |
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 java.util.ArrayList; | |
| public class SudokuBoard { | |
| private int[][] board; | |
| public SudokuBoard() { | |
| board = new int[9][9]; | |
| } | |
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
| CmdUtils.makeBookmarkletCommand({ | |
| name: "twine-this", | |
| url:"javascript:(function(){var%20d=document,w=window,a=window.getSelection,b=document.getSelection,c=document.selection,s=(a?a():(b)?b():(c?c.createRange().text:0)),l=d.location,e=encodeURIComponent;if(!d.getElementById('rdr-script'))try{var%20s=d.createElement('script');s.type='text/javascript';s.id='rdr-script';s.src='http://www.twine.com/js/spotthis.js';(d.body||d.documentElement).appendChild(s);}catch(x){var%20p='?u='%20+e(l.href)%20+'&t='+e(d.title)%20+'&s='+e(s)%20+'&v=1',u='http://www.twine.com/bookmark/basic'+p;l.href=u%20+'&adv=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
| octave = ['C',('C#','Db'),'D',('D#','Eb'),'E','F',('F#','Gb'),'G',('G#','Ab'),'A',('A#','Bb'),'B'] | |
| def is_valid_scale_name(scalename): | |
| if len(scalename) > 2: return False | |
| if len(scalename) == 2 and scalename[1] != 'b': return False | |
| if scalename[0].upper() not in 'ABCDEFG': return False | |
| return True | |
| def find_note(name): | |
| for i in range(len(octave)): |
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
| CmdUtils.CreateCommand({ | |
| name: "is.gd", | |
| takes: {"url to shorten": noun_type_url}, | |
| icon: "http://is.gd/favicon.ico", | |
| description: "Shortens the selected url with <a href=\"http://is.gd/\">is.gd</a>", | |
| preview: function(pblock, urlToShorten){ | |
| pblock.innerHTML = "Shortens the selected url with is.gd."; | |
| var baseUrl = "http://is.gd/api.php?longurl="; | |
| pblock.innerHTML = "Replaces the selected URL with "; | |
| jQuery.ajax({ |
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
| CmdUtils.makeBookmarkletCommand({ | |
| name: "Chyrp this", | |
| url: "javascript:var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://thinking-chair.com/notebook/admin/?action=bookmarklet',l=d.location,e=encodeURIComponent,p='&url='+e(l.href)+'&title='+e(d.title)+'&selection='+e(s),u=f+p;a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,status=1,width=450,height=430'))l.href=u;};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();void(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
| CmdUtils.makeBookmarkletCommand({ | |
| name: "Read Later", | |
| url: "javascript:var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://www.instapaper.com/b',l=d.location,e=encodeURIComponent,p='?v=4&k=9UhIRDKrjIUD&u='+e(l.href)%20+'&t='+e(d.title)%20+'&s='+e(s),u=f+p;try{if(!/^(.*\.)?instapaper([^.]*)?$/.test(l.host))throw(0);iptstbt();}catch(z){a%20=function(){if(!w.open(u,'t','toolbar=0,resizable=0,status=1,width=250,height=150'))l.href=u;};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();}void(0)" | |
| }) |
NewerOlder