Skip to content

Instantly share code, notes, and snippets.

# Fluent Interface Definition
class sql:
class select:
def __init__(self, dbcolumn, context=None):
self.dbcolumn = dbcolumn
self.context = context
def select(self, dbcolumn):
return self.__class__(dbcolumn,self)
# Demo
@bodiam
bodiam / uninstall_gvm.sh
Created October 24, 2013 23:18
Uninstall GVM
#!/bin/bash
if [ ! -d ~/.gvm ]; then
echo "No .gvm directory found in home directory. Are you sure GVM is installed?"
exit 1
fi
rm -rf ~/.gvm
for file in '.bashrc' '.bash_profile' '.zshrc'
do
@bodiam
bodiam / gist:7552076
Created November 19, 2013 20:34
Raspberry Pi WIFI
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "ssid"
package java8tests ;
import java.util.function.BiFunction ;
import java.util.function.Function ;
public class Currying {
public void currying() {
// Create a function that adds 2 integers
BiFunction<Integer,Integer,Integer> adder = ( a, b ) -> a + b ;
@Grapes(
@Grab(group='org.joda', module='joda-money', version='0.9')
)
import org.joda.money.*
def $(amount) {
CurrencyUnit usd = CurrencyUnit.of("USD");
Money.of(usd, amount);
}
@bodiam
bodiam / gist:8415239
Created January 14, 2014 08:55
Spring annotation configuration bean scanning
@Configuration
@ComponentScan(
value = "com.actions",
includeFilters = @ComponentScan.Filter(value = ActionBean.class)
)
public class ApplicationConfiguration {
public static void main(String[] args) {
final AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(ApplicationConfiguration.class);
final OrderAction bean = annotationConfigApplicationContext.getBean(OrderAction.class);
@bodiam
bodiam / install.sh
Created January 20, 2014 19:01
Install Django 1.6.1 using virtual env wrapper
sudo apt-get install python3-pip
sudo pip3 install virtualenvwrapper
export WORKON_HOME=~/Envs
mkdir -p $WORKON_HOME
source /usr/local/bin/virtualenvwrapper.sh
mkvirtualenv quotes
workon quotes
@bodiam
bodiam / semantic-ui.html
Created January 20, 2014 20:20
semantic-ui example
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.12.0/css/semantic.min.css">
</head>
<body>
<div class="ui buttons">
<div class="ui button">Cancel</div>
<div class="or"></div>
<div class="ui positive button">Save</div>
</div>
@bodiam
bodiam / semantic-ui-formatting.html
Created January 20, 2014 20:24
Semantic ui with formatting
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Open+Sans:300italic,400,300,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.12.0/css/semantic.min.css">
<link rel="stylesheet" type="text/css" href="http://semantic-ui.com/stylesheets/semantic.css">
</head>
<body id="example" class="button">
<div class="ui buttons">
<div class="ui button">Cancel</div>
@bodiam
bodiam / semantic-ui.com-turned-off.html
Created January 20, 2014 20:44
semantic-ui with semantic-ui.com website turned off.
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Open+Sans:300italic,400,300,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.12.0/css/semantic.min.css">
<!--
<link rel="stylesheet" type="text/css" href="http://semantic-ui.com/stylesheets/semantic.css">
-->
</head>
<body id="example" class="button">