Skip to content

Instantly share code, notes, and snippets.

View twogood's full-sized avatar

David Eriksson twogood

View GitHub Profile
@twogood
twogood / python-compile.sh
Created December 7, 2015 08:31
Check python syntax
python -m py_compile script.py
@twogood
twogood / counter.js
Created May 28, 2015 05:52
Code of the day
function counter(colAdd, rowAdd) {
var count = 1;
var x, y;
for (x = move.col + colAdd, y = move.row + rowAdd;
isOwnedByCurrentPlayer(x, y);
count++, x += colAdd, y += rowAdd) {
}
for (x = move.col - colAdd, y = move.row - rowAdd;
isOwnedByCurrentPlayer(x, y);
count++, x -= colAdd, y -= rowAdd) {
@twogood
twogood / main.cf
Last active August 29, 2015 14:18
Mandril SMTP relay in Postfix
relayhost = smtp.mandrillapp.com:submission
# http://www.zulius.com/how-to/set-up-postfix-with-a-remote-smtp-relay-host/
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = smtpd
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_type = cyrus
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
@twogood
twogood / gist:209aaa495f87a5563fe3
Last active May 17, 2016 15:12
idea phpstorm ibus keyboard fix
ibus restart && sleep 1 && ibus engine xkb:se::swe
@twogood
twogood / user.php
Created February 20, 2015 08:22
Get user information from Turf API
<?php
$postdata = json_encode(array(
array('name'=>'TBIT'),
));
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/json',
@twogood
twogood / gtk.css
Created November 10, 2014 10:08
Terminal tab colors in ~/.config/gtk-3.0/gtk.css
.notebook tab {
background-color: #c0c0c0;
color: black;
}
.notebook tab:active {
background-color: #f0f0f0;
color: black;
}
@twogood
twogood / EnumSingleton.java
Created March 3, 2014 11:50
What do you think about this singleton pattern?
public enum EnumSingleton
{
_INSTANCE;
public static EnumSingleton of()
{
return _INSTANCE;
}
@twogood
twogood / update-repo-from-snapshot.sh
Created August 22, 2013 13:56
Download an OpenShift snapshot and update the repository with changes made on the server. Don't forget to push afterwards!
#!/bin/sh
set -e
set -x
cd `dirname $0`
DIR=`pwd`
NAME=`basename $DIR`
SNAPSHOT_TARBALL=`mktemp --tmpdir "$NAME-XXX.tar.gz"`
rhc snapshot-save -a "$NAME" --filepath "$SNAPSHOT_TARBALL"
tar --wildcards --strip-components=5 -xvf "$SNAPSHOT_TARBALL" './*/app-root/runtime/repo/php'
git add -A php
@twogood
twogood / gist:5676613
Last active December 17, 2015 21:39
Reset unity
dconf reset -f /org/compiz/
dconf write /org/compiz/profiles/unity/plugins/unityshell/launcher-capture-mouse false
https://www.facebook.com/appcenter/XXXX?fb_source=dialog_permission