Skip to content

Instantly share code, notes, and snippets.

@ieure
ieure / toggle-root.el
Created January 19, 2011 02:45
Toggle between root and non-root users
(defun find-file-as-root ()
"Find a file as root."
(interactive)
(let* ((parsed (when (tramp-tramp-file-p default-directory)
(coerce (tramp-dissect-file-name default-directory)
'list)))
(default-directory
(if parsed
(apply 'tramp-make-tramp-file-name
(append '("sudo" "root") (cddr parsed)))
(defun local-path (path)
"Return the local portion of a path.
If PATH is local, return it unaltered.
If PATH is remote, return the remote diretory portion of the path."
(if (tramp-tramp-file-p path)
(elt (tramp-dissect-file-name path) 3)
path))
(defun python-find-python-command (&optional root)
@ieure
ieure / throttle.py
Created March 3, 2011 20:07
Example of a class which can be used as a decorator or context manager.
import time
from functools import wraps
class throttle(object):
"""Throttle calls to a method by `factor'."""
def __init__(self, factor, error_only=False):
self.factor = factor
(eval-after-load "magit"
'(progn
(defun magit-browse-github (commit)
"Open a browser pointing to the tracked branch on GitHub.
With prefix argument, go to the commit HEAD is at."
(interactive "p")
(let* ((branch (magit-get-current-branch))
(remote (and branch (magit-get "branch" branch "remote")))
(remote-branch (or (and branch (magit-remote-branch-for branch))
$ cat input
alice
bob
carol
dave
eve
$ y nl nl < input
1 alice
1 bob
2 carol
$ sudo port install s3cmd
---> Computing dependencies for s3cmd
---> Dependencies to be installed: python25
---> Fetching python25^C^C^C
PYPY_USESSION_BASENAME='-' python pypy/translator/goal/translate.py --batch --source --opt=jit pypy/translator/goal/targetpypystandalone --allworkingmodules
Recent stdout:
gcc -O3 -pthread -fomit-frame-pointer -Wall -Wno-unused -DPy_BUILD_CORE -msse2 -mfpmath=sse -DPYPY_CPU_HAS_STANDARD_PRECISION -frandom-seed=implement_72.c -o implement_72.s -S implement_72.c -I/home/ieure/pypy/1.5/pypy-1.5/pypy/translator/c -I/home/ieure/pypy/1.5/pypy-1.5/pypy/module/cpyext/include -I..
implement_72.c: In function ‘pypy_g_ccall_RAND_add__arrayPtr_INT_Float_reload’:
implement_72.c:62419: warning: implicit declaration of function ‘RAND_add’
/usr/bin/python /home/ieure/pypy/1.5/pypy-1.5/pypy/translator/c/gcc/trackgcroot.py -mmain -t implement_72.s > implement_72.gctmp
mv implement_72.gctmp implement_72.gcmap
gcc -O3 -pthread -fomit-frame-pointer -Wall -Wno-unused -DPy_BUILD_CORE -msse2 -mfpmath=sse -DPYPY_CPU_HAS_STANDARD_PRECISION -frandom-seed=implement_73.c -o implement_73.s -S implement_73.c -I/home/ieure/pypy/1.5/pypy-1.
{
"properties": {
"classifiers": [
{
"category": "Restaurant",
"type": "Food & Drink",
"subcategory": ""
}
]
}
Traceback (most recent call last):
File "/Users/ieure/Dropbox/Projects/simplegeo/places/places/importer.py", line 136, in import_geojson
while q.qsize() >= QUEUE_THRESH:
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/multiprocessing/queues.py", line 113, in qsize
return self._maxsize - self._sem._semlock._get_value()
NotImplementedError
<html><head><title>Error 500</title></head><body bgcolor="#ffffff"><h1>Status Code: 500</h1>Exception: <br>Stacktrace: <pre>net.sf.json.JSONException: null object
at net.sf.json.JSONObject.verifyIsNull(JSONObject.java:2424)
at net.sf.json.JSONObject.getJSONObject(JSONObject.java:1747)
at com.cloudbees.jenkins.GitHubWebHook.doIndex(GitHubWebHook.java:137)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:282)
at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:149)