Skip to content

Instantly share code, notes, and snippets.

View pwittchen's full-sized avatar
🎯
Focusing

Piotr Wittchen pwittchen

🎯
Focusing
View GitHub Profile
@pwittchen
pwittchen / EventBus.java
Created February 25, 2016 14:57 — forked from benjchristensen/EventBus.java
EventBus.java
import rx.Observable;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
import rx.subjects.Subject;
/**
* Simple pass-thru event bus with error handling and reconnect.
*/
public class EventBus {
@pwittchen
pwittchen / MyAdapter.java
Created February 16, 2016 20:42 — forked from niusounds/MyAdapter.java
How to simplify RecyclerView.Adapter and RecyclerView.ViewHolder
import android.content.Context;
import org.androidannotations.annotations.EBean;
public class MyAdapter extends SimpleListAdapter<String, TextView> {
public MyAdapter(Context ctx) {
super(ctx);
}
@pwittchen
pwittchen / App.java
Created January 13, 2016 22:40 — forked from davepkennedy/App.java
SQLite + JDBI
public class App
{
private static final String JDBC_DRIVER = "org.sqlite.JDBC";
private static final String CONNECTION_STRING = "jdbc:sqlite:/tmp/testdb.db";
public static void main( String[] args ) throws SQLException, ClassNotFoundException {
SQLiteDataSource ds = new SQLiteDataSource();
ds.setUrl("jdbc:sqlite:/tmp/data.db");
DBI dbi = new DBI(ds);
Handle h = dbi.open();
@pwittchen
pwittchen / myappindicator_v5.py
Created January 9, 2016 10:38 — forked from candidtim/myappindicator_v5.py
Ubuntu AppIndicator to show Chuck Norris jokes
# This code is an example for a tutorial on Ubuntu Unity/Gnome AppIndicators:
# http://candidtim.github.io/appindicator/2014/09/13/ubuntu-appindicator-step-by-step.html
import os
import signal
import json
from urllib2 import Request, urlopen, URLError
from gi.repository import Gtk as gtk
@pwittchen
pwittchen / base64.js
Created December 29, 2015 09:04 — forked from whatnickcodes/base64.js
How to Encode and Decode Strings with Base64 in JavaScript
// Create Base64 Object
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r
@pwittchen
pwittchen / git-branch-simplify.md
Created December 28, 2015 08:08 — forked from datagrok/git-branch-simplify.md
How to simplify the graph produced by git log --graph

Ideas for improvements to git log --graph

I will maybe someday get around to dusting off my C and making these changes myself unless someone else does it first.

Make the graph for --topo-order less wiggly

Imagine a long-running development branch periodically merges from master. The git log --graph --all --topo-order is not as simple as it could be, as of git version 1.7.10.4.

It doesn't seem like a big deal in this example, but when you're trying to follow the history trails in ASCII and you've got several different branches displayed at once, it gets difficult quickly.

@pwittchen
pwittchen / endpoints.md
Created December 20, 2015 18:55 — forked from derhuerst/_.md
List of HAFAS API Endpoints
@pwittchen
pwittchen / gist:28c2e6fe4f874bec2f84
Created December 8, 2015 19:46 — forked from deepak/gist:5933685
Set ENV in Dockerfile with string interpolation
# DOCKER-VERSION 0.4.8
FROM ubuntu:12.04
# install essentials
RUN apt-get install -y -q git
# Install rbenv
RUN git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
RUN echo '# rbenv setup' > /etc/profile.d/rbenv.sh
@pwittchen
pwittchen / Main.java
Created November 23, 2015 21:06 — forked from pron/Main.java
package jmodern;
import com.codahale.metrics.*;
import com.codahale.metrics.annotation.*;
import com.fasterxml.jackson.annotation.*;
import com.google.common.base.Optional;
import feign.Feign;
import feign.jackson.*;
import feign.jaxrs.*;
import io.dropwizard.Application;
@pwittchen
pwittchen / tmux-cheatsheet.markdown
Last active September 19, 2015 15:45 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname