Skip to content

Instantly share code, notes, and snippets.

Avatar
✔️
Verified

Garrett T film42

✔️
Verified
View GitHub Profile
View proxy.go
package main
import (
"fmt"
"net"
"bufio"
"net/http"
"net/http/httputil"
"io"
"time"
View async_controller.rb
class YoloController < ApplicationController
include ::AsyncResponse
def index
async do
sleep 2
@yolo = "I AM ASYNC"
resume_render
View simple_test.c
//////////////////////////////////
// Test Runner Code
//////////////////////////////////
#include <stdio.h>
typedef int (test_fn_t)(void);
struct test_t {
char * name;
View async-publisher-benchmark
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)
View ar.go
package main
import (
"bytes"
"strconv"
)
////
// Query Builder
//
View encrypt.scala
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 Dec 29, 2015
Why Clojure is so dang amazing. Number from 1 to 1000, applied 5th power, and multiplied together. BigInt test.
View big-numbers.clj
(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 Nov 1, 2013
Here's a little static class that just does a post and get, for a school project.
View HttpClient.java
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 Oct 16, 2013
Use an array of any size to add any two numbers.
View Counter.java
public class Counter {
private int[] seq = null;
public Counter(int size) {
this.seq = new int[size];
}
public Counter() {
this.seq = new int[10];
@film42
film42 / comcast.log
Created Oct 15, 2013
Terrible service from comcast
View comcast.log
64 bytes from 74.125.239.104: icmp_seq=13110 ttl=55 time=40.722 ms
64 bytes from 74.125.239.104: icmp_seq=13111 ttl=55 time=39.809 ms
64 bytes from 74.125.239.104: icmp_seq=13112 ttl=55 time=39.896 ms
64 bytes from 74.125.239.104: icmp_seq=13113 ttl=55 time=40.093 ms
64 bytes from 74.125.239.104: icmp_seq=13114 ttl=55 time=37.391 ms
64 bytes from 74.125.239.104: icmp_seq=13115 ttl=55 time=39.613 ms
64 bytes from 74.125.239.104: icmp_seq=13116 ttl=55 time=43.986 ms
64 bytes from 74.125.239.104: icmp_seq=13117 ttl=55 time=39.911 ms
64 bytes from 74.125.239.104: icmp_seq=13118 ttl=55 time=38.396 ms
64 bytes from 74.125.239.104: icmp_seq=13119 ttl=55 time=37.916 ms