Skip to content

Instantly share code, notes, and snippets.

@SinisterLight
SinisterLight / re.clj
Created April 15, 2017 14:08 — forked from clojens/re.clj
A few clojure java regex samples
(def ptrn
{
:a {:pattern #"a(?!b)"
:purpose "Only allow a if it is not preceded by a 'b' (negative lookahead)"
:samples ["acdefg" ; ok
"abcdef" ; nil
]}
:b {:pattern #"(?i)(<title.*?>)(.+?)(</title>)"
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@SinisterLight
SinisterLight / Links
Last active August 29, 2015 14:00
Links
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import SocketServer
class S(BaseHTTPRequestHandler):
def _set_headers(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
def do_GET(self):
# Total Commits per author
git shortlog -sn
# Author total addition and substraction
git log --numstat --pretty="%H" --author="Sinister Light" | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d, -%d\n", plus, minus)}'
# Number of lines per author
git ls-files | xargs -n1 -d'\n' -i git blame {} | perl -n -e '/\s\((.*?)\s[0-9]{4}/ && print "$1\n"' | sort -f | uniq -c -w3 | sort -r
@SinisterLight
SinisterLight / Fedora UI
Created October 3, 2013 09:00
Changing Fedora font rendering to be Ubuntu like
su -c 'yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
su -c "yum install freetype-freeworld"
gsettings "set" "org.gnome.settings-daemon.plugins.xsettings" "hinting" "slight"
gsettings "set" "org.gnome.settings-daemon.plugins.xsettings" "antialiasing" "rgba"
echo "Xft.lcdfilter: lcddefault" > ~/.Xresources
#reboot
#xrdb -query
#Xft.antialias: 1
function success(position) {
}
function error() {
}
if (navigator.geolocation) navigator.geolocation.getCurrentPosition(success, error);
else error();
@SinisterLight
SinisterLight / JS Patterns
Created May 30, 2013 12:56
Standard JS helpers
function asyncForEach(array, iterator, then) {
function loop(i) {
if (i < array.length) {
iterator(array[i], function() {
loop(i + 1);
}
else {
then();
}
}
(function quine() { console.log('(' + quine.toString() + ')()') })()
@SinisterLight
SinisterLight / gist:5655901
Last active December 17, 2015 18:49
Install rbenv | moving from rvm to rbenv
rvm implode
brew update
brew install rbenv
brew install ruby-build
rbenv init -
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
rbenv install 1.9.3-p429
rbenv rehash