Skip to content

Instantly share code, notes, and snippets.

@apk
apk / svn-merge-break.sh
Created August 11, 2011 07:08
Lose data in svn merge in four steps (branch, move dir here, modify content there, merge: mods lost)
set -xe
rm -rf repo wc
URL=file:///`pwd`/repo
time svnadmin create repo
time svn mkdir $URL/tr -m 'base dir'
time svn checkout $URL/tr wc
cd wc
mkdir A
cat >A/B <<EOF
package A
@apk
apk / tree.rb
Created January 28, 2011 16:48
Converting find output into a tree of hashes (and a funny use of inject)
tree={}
STDIN.each_line do |l|
a=l.strip.split '/'
a.inject(tree) { |t,n| t[n] ||= {} }
end
puts tree.inspect
def rek t, p
t.each_pair do |k, v|
@apk
apk / html.hs
Created January 22, 2011 22:27
Simple trial for html repr in haskell
-- Simple trial for html repr in haskell
data Html = Tag String [String] [Html]
| Text String
res :: [Html]
res = [(Tag "div" []
[
(Text "Hallo"),
(Tag "b" [] [Text "Bold"])
@apk
apk / do-dyndns.sh
Created August 25, 2010 17:02
DynDNS update script for occasionally changing IPs
#!/bin/sh
cd `dirname $0`
exec >>dyndns.log 2>&1
LANG=C
export LANG
date
ip=`/sbin/ifconfig eth3 | sed -ne 's,^.*inet addr:\([0-9.]*\) .*$,\1,p'`
echo ip: $ip
if test X"`cat ip`" = X"$ip"; then
echo Same addr
@apk
apk / Compile in git version...
Created August 24, 2010 10:22
Compile in git version
// Makefile:
// CPPFLAGS += -DGIT_VERSION='"'"`git describe --always --dirty`"'"'
#ifdef GIT_VERSION
char git_version [] = "$" "Git: " GIT_VERSION "$"; // To be picked up by rcsid
#endif
@apk
apk / git-to-cvs.sh
Created April 16, 2010 19:14
Helper to transfer back from git to cvs
# Commit diffs from cvs..master into cvs, one at a time.
# No file additions/removals.
set -x
git log --format=oneline cvs..master | tail -1 | (read commit comment
echo "[commit:'$comment']"
git merge $commit || exit
cvs -q commit -m "$comment" || exit
cvs -q update -kk
git update-index -q --refresh
git status)
@apk
apk / do-cvs-fetch
Created April 14, 2010 06:55
Import cvs tree into git repo
#!/bin/sh
# Arg: path/to/module/in/cvs
# Run git-cvsimport and place result in subdir cvs.path.to.module.in.cvs
# or update git repo there if already existing (incremental fetch should work)
# Fix to your cvs credentials
p="$1"
d="cvs.`echo $p | tr / .`"
test -d "$d" || mkdir "$d"
cd "$d" || exit 1
git cvsimport -p x -v -k -a -d :pserver:me@cvshost:/opt/cvs "$p"
@apk
apk / first.scala
Created February 27, 2010 22:52
Running scala with java libs
#!/bin/sh
exec scala -cp jlibs/commons-logging-1.1.1.jar:jlibs/jas.jar:jlibs/jux.jar "$0" "$@"
!#
import org.iocl.as._
var conn = new AsConnection("tep:7008/172.27.110.41:8234")
println("Res: " + conn.exec("get-history"))
@apk
apk / hide.hs
Created February 25, 2010 16:26
Don't do this in java, or your head may... hiding a string from grep and view
warnline = map (chr.(158-).ord)
"oo~W909,=*9:~8529r~:/~0/*~9:5*~58~%/)~2/(9~%/),~'/,3"
@apk
apk / gist:314680
Created February 25, 2010 16:16
Build svn for git-svn w/o root access
#!/bin/sh
set -xe
rm -rf subversion-1.6.9
tar xzf subversion-deps-1.6.9.tar.gz
tar xzf subversion-1.6.9.tar.gz
cd subversion-1.6.9
./configure --prefix=$HOME/svn19 --with-apache-libexecdir=$HOME/svn19/ale --with-editor=/bin/vi
make
make install
make swig-pl-lib