Skip to content

Instantly share code, notes, and snippets.

View tmountain's full-sized avatar

Travis Whitton tmountain

View GitHub Profile
(defn- get-chars
"gets the next char(s) in the sequence"
[s offset]
(if (>= offset (count s))
(let [div-val (dec (int (/ offset (count s))))
mod-val (mod offset (count s))]
(apply str (get-chars s div-val) (get-chars s mod-val)))
(subs s offset (inc offset))))
(def chars "abcdefghijlkmnopqrstuvwxyz")
(defn get-chars
"gets the next char(s) in the sequence"
[s offset]
(if (>= offset (count s))
(let [div-val (dec (int (/ offset (count s))))
mod-val (mod offset (count s))]
(apply str (get-chars s div-val) (get-chars s mod-val)))
(subs s offset (inc offset))))
#!/usr/local/bin/clj
(use 'clojure.contrib.str-utils)
(def breads ["rye" "whole wheat" "pita" "pancake" "pumpernickel" "olive loaf"
"nut loaf" "egg loaf" "sweet potato" "ice cream" "wheat gluten"
"banana" "sprouted grain"])
(def toppings ["bleu cheese" "jalapeno" "olive" "maple syrup" "cucumber"
"chipotle" "onion" "mushroom" "swiss cheese" "cheddar cheese"
"pickle" "head cheese" "hot dog" "bratwurst" "mustard" "ketchup"
#!/usr/local/bin/clj
(use 'clojure.contrib.str-utils)
(def breads ["rye" "whole wheat" "pita" "pancake" "pumpernickel" "egg loaf"
"sweet potato" "wheat gluten" "banana" "sprouted grain"
"ice cream"])
(def toppings ["bleu cheese" "jalapeno" "olive" "maple syrup" "cucumber"
"chipotle" "onion" "mushroom" "swiss cheese" "cheddar cheese"
"pickle" "hot dog" "bratwurst" "mustard" "ketchup"
public class T {
public static void main(String[] args) {
Thread t = new Thread(new Runnable() {
public void run() {
int i = 5 / 0;
}
});
t.start();
System.out.println("Oh I'm... I I... I'm still alive");
}
public class T {
public static void main(String[] args) {
Thread t = new Thread(new Runnable() {
public void run() {
int i = 5 / 0;
}
});
t.start();
try {
Thread.sleep(1000);
public class T {
private static class ThreadWithArg extends Thread {
private int x;
public ThreadWithArg(int x) {
this.x = x;
}
public void run() {
System.out.println("x = " + String.valueOf(this.x));
public class T {
public static void main(String[] args) {
int x = 3;
final Object[] foo = { x };
Thread t = new Thread(new Runnable() {
public void run() {
System.out.println(String.valueOf(foo[0]));
}
});
import java.io.*;
class FileRead {
public void readEachLine(String filename) {
try {
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream(filename);
// Get the object of DataInputStream
travis@travis-desktop:/tmp/menu$ cat MenuItem.java
class MenuItem {
private String item;
public abstract void run();
public MenuItem(String item) {
item = item;
}
}