This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'ap' | |
exts = {} | |
File.readlines("/etc/mime.types").each do |line| | |
next if line[0] == '#' | |
f = line.split(/\s+/, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function paddit($str, $grouplen=3, $chr='x') { | |
if ( (strlen($str) % $grouplen) == 0 ) | |
return $str; | |
$count = ($grouplen - (strlen($str) % $grouplen)); | |
for ($i = 0; $i < $count; $i++) { | |
$str .= $chr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package testing; | |
import java.io.*; | |
import java.net.*; | |
/** | |
* Lord please forgive me for the code I'm about to write. | |
* | |
* I know not what I do. I know my sins have separated me from you. | |
* I am truly sorry, and now I want to turn away from my past sinful life toward you. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env groovy | |
def files = new File('.').list().toList().findAll { f -> | |
new File(f).isFile() && f[0] != "." | |
} | |
files.each { f -> println f } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env groovy | |
/* | |
* Slurp those twits! | |
*/ | |
if (! args) { | |
println "Usage: groovy twit <username>" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env groovy | |
class Articles { | |
static dir | |
static def each(Closure c) { | |
new File(dir).eachFile { f -> c.call(f.text) } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env groovy | |
class Animal { | |
def type | |
def name | |
String toString() { | |
StringBuffer str = new StringBuffer() | |
str << "Type: $type" | |
if (name) { str << ", Name: $name" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'mysql2' | |
require 'ap' | |
client = Mysql2::Client.new( | |
:username => 'injekt', | |
:password => 'foo', | |
:database => 'test_one' | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'epoxy' | |
require 'pg' | |
require 'ap' | |
conn = PGconn.open(:dbname => 'rdbi', :user => 'rdbi') | |
conn.exec("DROP TABLE IF EXISTS users") | |
conn.exec("CREATE TABLE users ( id SERIAL PRIMARY KEY, name VARCHAR, pass VARCHAR )") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'mysql2' | |
conn = Mysql2::Client.new(:database => 'rdbi', :username => 'rdbi') | |
class Statement | |
def initialize(conn, query) | |
@conn = conn | |
@name = "abcd" |