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 editor | |
text = editor.get_text() | |
selection = editor.get_line_selection() | |
selected_text = text[selection[0]:selection[1]] | |
editor.set_selection(selection[0], selection[0] + len(selected_text) - 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 editor | |
selection = editor.get_line_selection() | |
editor.replace_text(selection[0], selection[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 os | |
import sys | |
import pickle | |
import console | |
# I moved 'dropboxlogin' into a sub folder so it doesn't clutter my main folder | |
sys.path += [os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lib')] | |
import dropboxlogin # this code can be found here https://gist.github.com/4034526 | |
STATE_FILE = '.dropbox_state' |
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 | |
sys.path += [os.path.join( | |
os.path.dirname( | |
os.path.abspath(__file__)), 'lib')] | |
# Pythonista Modules | |
import console | |
from scene import * |
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
// Modified from code found in the following stackoverflow answer: | |
// http://stackoverflow.com/questions/14172455/get-name-and-line-of-calling-function-in-node-js | |
Object.defineProperty(global, '__stack', { | |
get: function(){ | |
var orig = Error.prepareStackTrace; | |
Error.prepareStackTrace = function(_, stack){ return stack; }; | |
var err = new Error; | |
Error.captureStackTrace(err, arguments.callee); | |
var stack = err.stack; |
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 countTo10_recursively(count = 0): | |
if(count <= 10): | |
countTo10_recursively(count + 1) | |
# which is the same as | |
def countTo10_theObviousWay(): | |
for count in xrange(10): | |
pass | |
# lets do some tests |
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 enum_the_old_way(): | |
i = 0 | |
for j in myrange: | |
i += 1 | |
def enum_the_new_way(): | |
for i,j in enumerate(myrange): | |
pass | |
myrange = range(10000) |
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 | |
"""CLI USAGE: hexdump [-w n] [-ws b] <filename> | |
-w --words the number of words to display on a line | |
-ws --word-size the number of bytes to display in a word | |
""" | |
import __future__ | |
from StringIO import StringIO | |
import math |
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
from collections import deque | |
import struct | |
import sys | |
import io | |
class datagram_reader: | |
"""Buffered datagram reader | |
Accepts any stream that supports read() method | |
""" |
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 calendar | |
from datetime import datetime, timedelta, tzinfo | |
from math import floor | |
def seconds(day=0.0,hour=0.0,minute=0.0,second=0.0,microsecond=0.0): | |
return ((day*24.0 + hour)*60.0 + minute)*60.0 + second + microsecond/1000000.0 | |
def minutes(day=0.0,hour=0.0,minute=0.0,second=0.0,microsecond=0.0): | |
return (day*24.0 + hour)*60.0 + minute + (second + microsecond/1000000.0)/60.0 |
OlderNewer