Skip to content

Instantly share code, notes, and snippets.

View r10r's full-sized avatar

Ruben Jenster r10r

  • Drachenfels GmbH
  • Pforzheim
View GitHub Profile
@r10r
r10r / backup_git_repos.sh
Created October 17, 2011 13:22
Github backup script
#!/usr/bin/env ruby
require 'json'
require 'open-uri'
require 'fileutils'
require 'net/smtp'
BACKUP_DIR='/home/git/github-backup'
USERNAME='my_username'
URL_REPOS="https://api.github.com/users/#{USERNAME}/repos"
@r10r
r10r / .bashrc
Created March 25, 2012 20:18
Make adding paths to $PATH and exporting environment variables easy
# Add all paths listed in ~/.path to the PATH variable
# ----------------------------------------------------------
# first check if the file is available
if [ -f $HOME/.path ]; then
# read file line-by-line
for p in $(cat $HOME/.path); do
# check if line is a comment
if ! echo $p | grep -q ^[[:space:]]*\#; then
# check if the directory exists
if [ -d "$HOME/$p" ]; then
@r10r
r10r / sources.list
Created March 25, 2012 20:44
Fast german linuxmint LMDE repositories
# faster repositories LMU
deb http://linuxmint.bio.lmu.de/debian-latest testing main contrib non-free
deb http://linuxmint.bio.lmu.de/debian-latest/multimedia testing main non-free
deb http://linuxmint.bio.lmu.de/debian-latest/security testing/updates main contrib non-free
@r10r
r10r / gist:2305091
Created April 4, 2012 19:49
embed SWT widget into Swing JFrame
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.browser.Browser;
@r10r
r10r / jhw-assets.md
Created May 16, 2012 17:40 — forked from lamikae/jhw-assets.md
Jasmine headless testing on Rails 3 asset pipeline

Jasmine headless testing on Rails 3 asset pipeline

  • assets and specs can be CoffeeScript
  • 3rd party JS can be placed to vendor/assets/javascripts or vendor gems
  • detects gem-vendored JS via application.js require
  • uses jasmine-headless-webkit to run the suite outside the browser
    • this requires Qt4.7 installation
@r10r
r10r / skitch2png.rb
Created May 29, 2012 06:11
Extract PNG data from .skitch SVG files
#!/usr/bin/env ruby
# extracts the embedded PNG data from .skitch SVG files
require 'nokogiri'
require 'base64'
IMAGE_HEADER = "data:image/png;base64,"
ARGV.each do |filename|
svg_document = Nokogiri::XML(File.open(filename))
@r10r
r10r / "parent child" data
Created June 3, 2012 19:08 — forked from ToulBoy/"parent child" data
Elasticsearch 0.18.6 : My example of "parent child"
curl -s -XPOST localhost:9200/_bulk?pretty=true --data-binary '
{ "index" : { "_index" : "parent_child", "_type" : "store", "_id" : "store1" } }
{ "name" : "auchan", "owner" : "chris" }
{ "index" : { "_index" : "parent_child", "_type" : "department", "_id" : "department1", "parent" : "store1" } }
{ "name" : "toys", "numberOfProducts" : 150 }
{ "index" : { "_index" : "parent_child", "_type" : "product", "_id" : "product1", "parent" : "department1", "routing" : "store1" } }
{ "name" : "gun", "trademark" : "tiger", "price" : 9, "store_id" : "store1" }
'
@r10r
r10r / nginx-elasticsearch-proxy.conf
Created June 3, 2012 20:08 — forked from karmi/nginx-elasticsearch-proxy.conf
Route requests to ElasticSearch to authenticated user's own index with an Nginx reverse-proxy
# Run me with:
#
# $ nginx -p /path/to/this/file/ -c nginx.conf
#
# All requests are then routed to authenticated user's index, so
#
# GET http://user:password@localhost:8080/_search?q=*
#
# is rewritten to:
#
# ========================================
# Testing n-gram analysis in ElasticSearch
# ========================================
curl -X DELETE localhost:9200/ngram_test
curl -X PUT localhost:9200/ngram_test -d '
{
"settings" : {
"index" : {
"analysis" : {
@r10r
r10r / "parent child" data
Created June 3, 2012 22:29 — forked from ToulBoy/"parent child" data
Elasticsearch 0.20.0.Beta1-SNAPSHOT with has_parent merged : Search for childs with "has_parent"
curl -s -XPOST localhost:9200/_bulk?pretty=true --data-binary '
{ "index" : { "_index" : "parent_child", "_type" : "store", "_id" : "store1" } }
{ "name" : "auchan", "owner" : "chris" }
{ "index" : { "_index" : "parent_child", "_type" : "department", "_id" : "department1", "parent" : "store1" } }
{ "name" : "toys", "numberOfProducts" : 150 }
{ "index" : { "_index" : "parent_child", "_type" : "product", "_id" : "product1", "parent" : "department1", "routing" : "store1" } }
{ "name" : "gun", "trademark" : "tiger", "price" : 9, "store_id" : "store1" }
'