Skip to content

Instantly share code, notes, and snippets.

View pwittchen's full-sized avatar

Piotr Wittchen pwittchen

View GitHub Profile
@pwittchen
pwittchen / git-merged.sh
Created February 15, 2016 14:33
checking if commit was merged to develop
git rev-list 59848ab..develop --ancestry-path | grep -f <(git rev-list 59848ab..develop --first-parent) | tail -1
curl 'http://powietrze.gios.gov.pl/pjp/current/getAQIDetails' --data 'id=778&param=AQI' --compressed | pretty-json | colorize
Display JSON data from sample station measuring air pollution in poland.
Main website: http://powietrze.gios.gov.pl/pjp/current, http://powietrze.gios.gov.pl/pjp/maps/measuringstation
new ReactiveNetwork().observeWifiSignalLevel(context)
.subscribeOn(Schedulers.io())
... // anything else what you can do with RxJava
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<WifiSignalLevel>() {
@Override public void call(WifiSignalLevel signalLevel) {
// do something with signalLevel
}
});
new ReactiveNetwork().observeWifiSignalLevel(context, numLevels)
.subscribeOn(Schedulers.io())
... // anything else what you can do with RxJava
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<Integer>() {
@Override public void call(Integer level) {
// do something with level
}
});
@pwittchen
pwittchen / git-changing-remotes.sh
Created January 28, 2016 11:12
Changing one remote to another one
$ git remote rename origin old
$ git remote add origin ssh://[email protected]:7999/repo/repo.git
$ git remote remove old
$ git remote -v
@pwittchen
pwittchen / program-exsists.sh
Created January 24, 2016 19:48
Check if program exists on Linux
#!/usr/bin/env bash
if which programname >/dev/null; then
echo program exists
else
echo program does not exist
fi
@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 / get-manpages-for-zsh.sh
Created January 5, 2016 20:09
Downloads and installs missing manpages for zsh
#all in one manual fix for Ubuntu 14.04 with zsh-5.0.2 (based on mchelen's one-liner):
# get zsh tar file and uncompress its Doc folder to /usr/share/man/man1
wget -qO- "http://downloads.sourceforge.net/project/zsh/zsh/5.0.2/zsh-5.0.2.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fzsh%2Ffiles%2Fzsh%2F5.0.2%2F&ts=1407408881&use_mirror=superb-dca3" | sudo tar xvz -C /usr/share/man/man1/ --wildcards "zsh-5.0.2/Doc/*.1" --strip-components=2
# fix permissions
sudo chown root:root /usr/share/man/man1/zsh*.1
sudo chmod 0644 /usr/share/man/man1/zsh*.1
# gzip the new zsh man pages (all others are gzipped as well)
@pwittchen
pwittchen / starwars.sh
Last active January 3, 2016 14:26
Star Wars in terminal via telnet without cursor
#!/usr/bin/env bash
tput civis -- invisible && telnet towel.blinkenlights.nl 23