Skip to content

Instantly share code, notes, and snippets.

View film42's full-sized avatar
✔️
Verified

Garrett Thornburg film42

✔️
Verified
View GitHub Profile
@film42
film42 / fluxbox.conf
Created November 24, 2016 04:21
Fluxbox with mac keyboard
# super-tab
Mod4 Tab :NextWindow {groups} (workspace=[current])
Mod4 Shift Tab :PrevWindow {groups} (workspace=[current])
### TILING WINDOWS ###
#1920 / 2 = 960
#1080 / 2 = 540
Control KP_0 :Minimize
Control KP_1 :MacroCmd {ResizeTo 958 540} {MoveTo 00 00 LowerLeft}
Control KP_2 :MacroCmd {ResizeTo 1920 540} {MoveTo 00 00 LowerLeft}
package main
import (
"fmt"
"net"
"bufio"
"net/http"
"net/http/httputil"
"io"
"time"
class YoloController < ApplicationController
include ::AsyncResponse
def index
async do
sleep 2
@yolo = "I AM ASYNC"
resume_render
//////////////////////////////////
// Test Runner Code
//////////////////////////////////
#include <stdio.h>
typedef int (test_fn_t)(void);
struct test_t {
char * name;
Benchmark.measure { 10_000.times { ActionSubscriber::Publisher.publish("test", "test", "test") } }
5.590000 2.110000 7.700000 ( 14.262266)
Benchmark.measure { 10_000.times { ActionSubscriber::Publisher.publish_async("test", "test", "test") } }
0.030000 0.000000 0.030000 ( 0.025184)
package main
import (
"bytes"
"strconv"
)
////
// Query Builder
//
val cipher = Map('a' -> 'а', 'b' -> 'б', 'c' -> 'ц', 'd' -> 'д', 'e' -> 'е', 'f' -> 'ф', 'g' -> 'г',
'h' -> 'ч', 'i' -> 'и', 'j' -> 'й', 'k' -> 'к', 'l' -> 'л', 'm' -> 'м', 'n' -> 'н',
'o' -> 'о', 'p' -> 'п', 'q' -> 'я', 'r' -> 'р', 's' -> 'с', 't' -> 'т', 'u' -> 'у',
'v' -> 'в', 'w' -> 'ш', 'x' -> 'х', 'y' -> 'ы', 'z' -> 'з', ' ' -> '@')
lazy val reverse_cipher = cipher.map(_.swap)
def encrypt(word: String) =
word.flatMap(x => cipher(x.toLower).toString)
@film42
film42 / big-numbers.clj
Last active December 29, 2015 16:39
Why Clojure is so dang amazing. Number from 1 to 1000, applied 5th power, and multiplied together. BigInt test.
(defn power-of [x n]
(loop [i 0, acc 1]
(if (not (< i n))
acc
(recur (inc i) (* acc x)))))
(def thousand (range 1 1001))
(def big-thousand (map #(power-of (bigint %1) 5) hundred))
(print (reduce * big-thousand))
@film42
film42 / HttpClient.java
Created November 1, 2013 02:26
Here's a little static class that just does a post and get, for a school project.
package servertester.modules;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
/**
* Created with IntelliJ IDEA.
* User: film42
@film42
film42 / Counter.java
Created October 16, 2013 20:33
Use an array of any size to add any two numbers.
public class Counter {
private int[] seq = null;
public Counter(int size) {
this.seq = new int[size];
}
public Counter() {
this.seq = new int[10];