Skip to content

Instantly share code, notes, and snippets.

@ArtemGr
ArtemGr / alternative, using regex
Created May 21, 2009 16:29
CSV parser in Scala
val pattern = java.util.regex.Pattern.compile ("""(?xs) ("(.*?)"|) ; ("(.*?)"|) (?: \r?\n | \z ) """)
val matcher = pattern.matcher (input)
while (matcher.find) {
val col1 = matcher.group (2)
val col2 = matcher.group (4)
// ...
}
# This is an example of how you can set up screenshots for your
# browser testing. Just run cucumber with --format html --out report.html
#
module Screenshots
def embed_screenshot(id)
%x(scrot #{$ROOT_PATH}/images/#{id}.png)
end
end
World(Screenshots)
@tjluoma
tjluoma / com.apple.Boot.plist
Created April 2, 2012 19:46
Enable the "Apple MacBook Air SuperDrive" on any Mac
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Kernel Flags</key>
<string>mbasd=1</string>
</dict>
</plist>
@wfaler
wfaler / cake-pattern-example.scala
Created October 22, 2012 16:57
simple-cake-pattern-example.scala
// simple example of the cake pattern
// abstract DAO trait
trait Repository[A, B]{
// saves an entity, returns an ID
def save(entity: A): B
// more features..
}
trait RdbmsRepository extends Repository[MyUserCaseClass, Long]{
#!/usr/bin/env sh
cp ~/Library/Application\ Support/Google/Chrome/Default/History /tmp/chrome-history
sqlite3 /tmp/chrome-history "SELECT url FROM urls"
@axtl
axtl / revdeps.py
Created April 9, 2014 05:27
homebrew reverse dependencies
#!/usr/bin/env python
from __future__ import print_function
import subprocess
import sys
if len(sys.argv) < 2:
raise SystemExit('need a brew to check reverse deps for')
@tafkey
tafkey / git_overview
Last active October 19, 2023 15:15
Print git status of all repositories under the current folder
find . -type d -name '.git' | while read dir ; do sh -c "cd $dir/../ && echo -e \"\nGIT STATUS IN ${dir//\.git/}\" && git status -s" ; done
@tliron
tliron / rest.py
Last active January 8, 2022 13:34
Simple and functional REST server for Python (2.7) using no dependencies beyond the Python standard library.
#!/usr/bin/env python
'''
Simple and functional REST server for Python (2.7) using no dependencies beyond the Python standard library.
Features:
* Map URI patterns using regular expressions
* Map any/all the HTTP VERBS (GET, PUT, DELETE, POST)
* All responses and payloads are converted to/from JSON for you