Skip to content

Instantly share code, notes, and snippets.

function svn_line_changes {
echo "Scanning $@"
removed=`svn diff $@ | grep "^-[^-]" | wc -l`
echo "Removed: $removed"
added=`svn diff $@ | grep "^+[^+]" | wc -l`
echo "Added: $added"
difference=`expr $added - $removed`
echo "Difference: $difference"
unset removed added difference
}
# setup your DB connection, cursor, etc
cur.execute('BACKUP DATABASE ? TO DISK=?',
['test', r'd:\temp\test.bak'])
while cur.nextset():
pass
#backup done, close everything
@ryepup
ryepup / coroutines in lisp
Created November 21, 2010 05:44
lisp coroutines using chanl (threads)
(defmacro make-coroutine ((&key (coroutine-done-value :done)) &body body)
(alexandria:with-gensyms ((thrfn "thread body")
(c "channel"))
`(let* ((,c (make-instance 'chanl:bounded-channel))
(,thrfn (lambda ()
(flet ((yield (&optional n)
(chanl:send ,c n)))
,@body
(yield ,coroutine-done-value)))))
(let ((alive-p T) val thr)
@ryepup
ryepup / gist:708500
Created November 21, 2010 06:03
coroutine test function
(defun coroutine-test ()
(let ((cor (make-coroutine (:coroutine-done-value :done)
(yield 1)
(yield)
(yield 4))))
(assert (eql 1 (funcall cor)) )
(assert (null (funcall cor)))
(assert (eql 4 (funcall cor)))
(assert (eql :done (funcall cor)))
(assert (eql :done (funcall cor)))))
@ryepup
ryepup / gist:708501
Created November 21, 2010 06:04
coroutines with chanl
(defmacro make-coroutine ((&key (coroutine-done-value :done)) &body body)
(alexandria:with-gensyms ((thrfn "thread body")
(c "channel"))
`(let* ((,c (make-instance 'chanl:bounded-channel))
(,thrfn (lambda ()
(flet ((yield (&optional n)
(chanl:send ,c n)))
,@body
(yield ,coroutine-done-value)))))
(let ((alive-p T) val thr)
@ryepup
ryepup / gist:708502
Created November 21, 2010 06:04
coroutines with bordeaux-threads (broken)
(defmacro make-coroutine ((&key (coroutine-done-value :done)) &body body)
(alexandria:with-gensyms ((yield-cv "can we yield?")
(run-cv "can we run?")
(run-lck "lock for the runner thread")
(val "yielding value")
(thrfn "thread body"))
`(let* ((,yield-cv (bordeaux-threads:make-condition-variable
:name "yield"))
(,run-cv (bordeaux-threads:make-condition-variable
:name "run"))
@ryepup
ryepup / gist:714424
Created November 24, 2010 21:12
testing syntax for a simpy lisp port
;; from SimPy.Simulation import *
;; class Message(Process):
;; """ a simple Process """
;; def __init__(self,i,len):
;; Process.__init__(self,name="Message"+str(i))
;; self.i = i
;; self.len = len
;; def go(self):
@ryepup
ryepup / sbclrc.lisp
Created October 19, 2012 16:00
Generate TAP files using lisp-unit, ASDF, and with-test-listener
(defmethod asdf:perform :around ((o asdf:test-op) (system asdf:system))
;; find a good filename, inside the current Jenkins workspace
(let ((outfile
(merge-pathnames (format nil "TAP/~a.tap" (asdf:component-name system))
(truename (sb-ext:posix-getenv "WORKSPACE"))))
;; keep a list of how many tests we've got
(num-tests 0)
;; keep a list of test names and how many assertions passed
(working-tests (make-hash-table)))
(ensure-directories-exist outfile)
#!/bin/bash
#read from emacs server file what port it is currently listening on
PORT=`egrep -o '127.0.0.1:([0-9]*)' ~/.emacs.d/server/server | sed 's/127.0.0.1://'`
HOST="${@: -1}"
echo "Found host '$HOST'"
ssh "$HOST" "mkdir -m 700 -p ~/.emacs.d/server"
scp -p ~/.emacs.d/server/server $HOST:.emacs.d/server/server
@ryepup
ryepup / index.html
Last active December 19, 2015 22:49
very simple development log app in angular; a poor-mans one-note or org-mode
<!doctype html>
<html lang="en" ng-app>
<head>
<meta charset="utf-8">
<title>Dev log</title>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
</head>
<body>
<div class="container" ng-controller="DevLogController">
<h2>Dev Log</h2>