Skip to content

Instantly share code, notes, and snippets.

@wrenoud
wrenoud / debug.js
Last active December 22, 2015 17:59
Used to print debug message in node.js that include filename and line number.
// 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;
@wrenoud
wrenoud / file_browser.py
Created November 10, 2012 03:26
Pythonista file browser using scene module. Latest change adds delete functionality.
import os
import sys
sys.path += [os.path.join(
os.path.dirname(
os.path.abspath(__file__)), 'lib')]
# Pythonista Modules
import console
from scene import *
@wrenoud
wrenoud / DropboxSync.py
Created November 10, 2012 02:46
DropboxSync
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'
@wrenoud
wrenoud / Delete Line.py
Created November 9, 2012 20:50
Delete Line
import editor
selection = editor.get_line_selection()
editor.replace_text(selection[0], selection[1], '')
@wrenoud
wrenoud / Select Line.py
Created November 9, 2012 20:45
Select Line
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)