Skip to content

Instantly share code, notes, and snippets.

View twogood's full-sized avatar

David Eriksson twogood

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / sphinx.conf.part
Created January 4, 2012 13:10
sphinx åäö
source loppis_posts
{
type = mysql
sql_host = localhost
sql_user = user
sql_pass = pass
sql_db = loppis_dev
sql_port = 3306 # optional, default is 3306
@twogood
twogood / etc-dokuwiki-local.php
Created February 9, 2012 07:27
/etc/dokuwiki/local.php for multiple DokuWiki installations in Ubuntu
<?php
$host = strtolower($_SERVER['HTTP_HOST']);
$file['local'] = '/etc/dokuwiki/'.$host.'/local.php';
require_once($file['local']);
$prefix = '/var/lib/dokuwiki/'.$host.'/';
$conf['olddir'] = $prefix.'attic';
$conf['cachedir'] = $prefix.'cache';
$conf['lockdir'] = $prefix.'locks';
@twogood
twogood / gist:2820806
Created May 28, 2012 19:29
Uncaught Syntax error, unrecognized expression: [class^='add:the-comment-list':]
--- wp-lists.dev.js.orig 2009-11-29 11:29:12.000000000 +0100
+++ wp-lists.dev.js 2012-05-28 21:56:43.000000000 +0200
@@ -62,7 +62,7 @@
if ( !s ) { return false; }
- if ( !e.is("[class^=add:" + list.id + ":]") ) { return !wpList.add.call( list, e, s ); }
+ if ( !e.is("[class^='add:" + list.id + ":']") ) { return !wpList.add.call( list, e, s ); }
if ( !s.element ) { return true; }
@twogood
twogood / AssertResult.java
Created June 1, 2012 13:16
TestNG Assert helpers for the Result class
import static org.testng.Assert.*;
public class AssertResult
{
static public void assertSucceeded(Result result)
{
assertTrue(result.succeeded(), result.getMessage());
}
static public void assertFailed(Result result)
@twogood
twogood / Result.java
Created June 1, 2012 13:14
The Result class
public class Result
{
public static final Result SUCCESS = new Result(true, "");
private boolean success;
private String message;
private Result(boolean success, String message)
{
this.success = success;