Skip to content

Instantly share code, notes, and snippets.

@williamstein
williamstein / replace
Created October 23, 2015 14:31
A simple replace script that I wrote long ago
#!/usr/bin/python
import os, sys
argv = sys.argv
if len(argv) < 4:
print "*********\nThis is the replace command, by William Stein (was@math.harvard.edu)\n*********"
print "\tUsage: %s [-f] <from> <to> [file 1] [file 2] ..."%argv[0]
print "Optional argument -f is to not ask for confirmation.";
sys.exit(0)
def f(n):
return n * n
def foo(n):
return n*n + 1
def f(n):
return n * n
@williamstein
williamstein / syncdoc.coffee
Created November 14, 2014 22:30
BSD-licensed Differential Synchroniziation code with synchronized database built on top.
###################################################################
#
# Code to support simultaneous multiple editing
# sessions by different clients of a single object. This uses
# the Differential Synchronization algorithm of Neil Fraser,
# which is the same thing that Google Docs uses.
#
# * "Differential Synchronization" (by Neil Fraser).
# * http://neil.fraser.name/writing/sync/
# * http://www.youtube.com/watch?v=S2Hp_1jqpY8
~$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import regs_180k_200k_conca
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "regs_180k_200k_conca.py", line 5484