Skip to content

Instantly share code, notes, and snippets.

View fakedrake's full-sized avatar

Chris Perivolaropoulos fakedrake

View GitHub Profile
@fakedrake
fakedrake / gist:2584033
Created May 3, 2012 07:34
a defun to find the next C function declaration in a copy of a .h file's contents and insert the brackets intead of ;
(defun my-prepeare-function ()
"if next function not prepared, prepare it for implementation"
(interactive)
(save-excursion
(search-forward ")" nil (lambda () (message "No more functions after point")) 1)
(cond ((looking-at "[\n\t ]*;")
(progn
(zap-to-char 1 ?\;)
(move-end-of-line)
(newline) (insert "{") (newline) (insert "}") (newline))))))
@fakedrake
fakedrake / gist:2627722
Created May 7, 2012 13:22
tried to comment out the rest of the line in a narrowed buffer
Debugger entered--Lisp error: (args-out-of-range 1 93)
parse-partial-sexp(1 93)
c-determine-limit(500)
c-guess-basic-syntax()
c-indent-line()
indent-according-to-mode()
c-electric-slash(nil)
call-interactively(c-electric-slash nil nil)
recursive-edit()
debug(error (args-out-of-range 1 94))
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define DEPTH 7
#define INVALID 50
#define WIDTH 8
#define BOARD_SIZE WIDTH*WIDTH
#define COLOR(i) ((i)%2)
@fakedrake
fakedrake / gist:3129122
Created July 17, 2012 12:19
elisp for local key
(define-key py-mode-map "\C-cp" (lambda () (insert-string "import ipdb; ipdb.set_trace()")))
@fakedrake
fakedrake / gist:3353661
Created August 14, 2012 22:44
Error initializing database
[fakedrake@Keep ~/Projects/python/webdev/pyramid/pyramida/belogeh/FooDooBlog]$ ../bin/initialize_FooDooBlog_db development.ini
2012-08-15 01:42:09,086 INFO [sqlalchemy.engine.base.Engine][MainThread] PRAGMA table_info("posts")
2012-08-15 01:42:09,086 INFO [sqlalchemy.engine.base.Engine][MainThread] ()
2012-08-15 01:42:09,087 INFO [sqlalchemy.engine.base.Engine][MainThread] BEGIN (implicit)
2012-08-15 01:42:09,088 INFO [sqlalchemy.engine.base.Engine][MainThread] INSERT INTO posts (name, title, body, view_count) VALUES (?, ?, ?, ?)
2012-08-15 01:42:09,088 INFO [sqlalchemy.engine.base.Engine][MainThread] ('one', 'The One', '"One Ring to rule them all, One Ring to find them,\nOne Ring to bring them all and in the darkness bind them', 0)
2012-08-15 01:42:09,088 INFO [sqlalchemy.engine.base.Engine][MainThread] ROLLBACK
Traceback (most recent call last):
File "../bin/initialize_FooDooBlog_db", line 8, in <module>
load_entry_point('FooDooBlog==0.0', 'console_scripts', 'initialize_FooDooBlog_db')()
@fakedrake
fakedrake / gist:3379699
Created August 17, 2012 15:10
bit more lexible equality
def matches(v, l):
try:
return v in l
except TypeError:
try:
return l in v
except TypeError:
return l == v
(setq a '("a" "b" "c"))
(delete* "a" a)
(print a)
@fakedrake
fakedrake / gist:3753790
Created September 20, 2012 03:21
When pressing tab in ansi term
Debugger entered--Lisp error: (wrong-type-argument characterp tab)
string(tab)
term-send-raw()
call-interactively(term-send-raw)
yas--fallback(trigger-key)
yas-expand()
call-interactively(yas-expand nil nil)
;; I hope this works
(defun channel-names (channel)
(when (erc-channel-p channel)
(with-current-buffer channel
(erc-get-channel-nickname-list))))
(defun intersect-lists (head &rest lists)
"Intersect any number of lists"
(if (consp lists)
(defun py-my-indent-region (&optional min max)
"Stupidly clamp indentation to the closest multiple of 4 spaces."
(interactive)
(save-excursion
(let ((top (or min (point-min)))
(bottom (or max (point-max)))
(line-move-visual nil))
(goto-char top)
(while (<= (point) bottom)
(indent-line-to