Skip to content

Instantly share code, notes, and snippets.

View guenter's full-sized avatar

Tobi Knaup guenter

View GitHub Profile
@guenter
guenter / api.feature
Created June 24, 2010 17:55
Snippets for testing REST APIs with Cucumber and friends
Feature: API
In order to use the service from third party apps
As a user
I want to be able to use an API
Background:
Given a user exists # Pickle
And I login as the user using basic auth
Scenario Outline: Get a ticket
@guenter
guenter / mysql_commands_i_always_forget.sql
Created September 1, 2010 15:58
MySQL commands I forget all the time
-- Reset the query cache
RESET QUERY CACHE;
-- Closes all open tables, forces all tables in use to be closed, and flushes the query cache.
FLUSH TABLES;
-- Show character set in use by client, server, etc.
SHOW VARIABLES LIKE 'character_set%';
@guenter
guenter / move_to_rds.rb
Created November 11, 2010 02:14
A quick and dirty script to move a database into Amazon RDS (or any other database). Can transfer part of the data beforehand.
require 'fileutils'
start_time = Time.now
SOURCE_DB = {
:name => 'db_name',
:user => 'db_user',
:password => 'db_pass',
:host => 'localhost'
@guenter
guenter / gist:1424333
Created December 2, 2011 18:39
Lucene Facets Drill Down
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.facet.index.CategoryDocumentBuilder;
import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
import org.apache.lucene.facet.index.params.FacetIndexingParams;
import org.apache.lucene.facet.search.DrillDown;
import org.apache.lucene.facet.search.FacetsCollector;
import org.apache.lucene.facet.search.params.CountFacetRequest;
import org.apache.lucene.facet.search.params.FacetRequest;
import org.apache.lucene.facet.search.params.FacetSearchParams;
package airbnb.cascading.sessions;
import cascading.flow.Flow;
import cascading.flow.FlowConnector;
import cascading.flow.hadoop.HadoopFlowConnector;
import cascading.pipe.Pipe;
import cascading.scheme.hadoop.TextLine;
import cascading.tap.SinkMode;
import cascading.tap.Tap;
import cascading.tap.hadoop.Hfs;
@guenter
guenter / using-twitter-commons-sample.sh
Created March 1, 2013 23:07
Using Twitter Commons sample app
# Clone the repo:
$ git clone git://github.com/airbnb/twitter-commons-sample.git
# Build using Maven:
$ mvn package
# Run:
$ bash run_local.bash
# Like a place:
@guenter
guenter / http.py
Created November 14, 2013 17:01
Simple Python HTTP server
import sys
port = 8080
if sys.version_info.major == 3:
import http.server
import socketserver
handler = http.server.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(("",port), handler)
elif sys.version_info.major == 2:
@guenter
guenter / Main.scala
Last active September 17, 2020 11:25
A simple Mesos "Hello World": downloads and starts a Python web server on every node in the cluster.
import mesosphere.mesos.util.FrameworkInfo
import org.apache.mesos.MesosSchedulerDriver
/**
* @author Tobi Knaup
*/
object Main extends App {
@guenter
guenter / .bashrc
Created December 10, 2013 01:03
Show git branch in prompt
# Git
source /usr/local/etc/bash_completion.d/git-prompt.sh
if [ "$USER" = "root" ]; then
PS1='\e[1;31m[\u@\h \W[\033[34m\]$(__git_ps1 " (%s)")\[\033[00m\]\$\e[0m '
else
PS1='\u@\h \w$(__git_ps1 " (%s)")\$ '
fi
alias g='git'
alias gpr='git pull --rebase'
Index: Rakefile
===================================================================
--- Rakefile (revision 1572742)
+++ Rakefile (working copy)
@@ -36,7 +36,7 @@
Dir.glob('*.md').each { |doc|
puts "working on: #{doc}"
IO.write(doc, File.open(doc) { |f|
- f.read.gsub(/\((.*)(\.md)\)/, '(\1)')
+ f.read.gsub(/\((.*)(\.md)\)/, '(/documentation/latest/\1/)')