Skip to content

Instantly share code, notes, and snippets.

View TheEmpty's full-sized avatar

Myles Best TheEmpty

  • USA
View GitHub Profile
class A
def isVisable
true
end
def method_missing(m, *args, &block)
if m =~ /eh$/i
merica = "is" + m.to_s.capitalize.split(/eh$/i).first
if self.respond_to?(merica)
return self.send(merica)
// ಠ_ಠ.scala
object ಠ_ಠ {
// ಠ_ಠ really "Replace user"
def really(str : String) = {
System.err.println(str)
}
// ಠ_ಠ ¬_¬ "Can't provide --log and --no-log"
def ¬_¬(str : String) = {
class Point {
var x : Int = 0
var y : Int = 0
def apply(newX : Int, newY : Int) : Point = {
x = newX
y = newY
this
}
trait Node {
var prev : Node = null
var next : Node = null
def ✂ : Node = { delete }
def unary_~ : Node = { delete }
def ⇠ : Node = { prev }
def ⇢ : Node = { next }
def ⇠? : Boolean = { prev == null }
def ⇢? : Boolean = { prev == null }
(defun factorial (n)
(if (<= n 1)
1
(* n (factorial (- n 1)))))
(dotimes (x 10)
(let ((n (+ x 1)))
(format t "factorial ~2D = ~D~%" n (factorial n))))
; output
public class AnExample {
public static void main(String[] args) {
System.out.println(
ColoredString.s("Such ANSI, Easy Color. Many wow.").bold().cyan().blink();
);
}
}
@TheEmpty
TheEmpty / gist:7258361
Last active December 27, 2015 03:19
Color fading for Java UI
int[] rgb = {0,0,0};
int i = 0; // current working index
int step = 25;
while(true) {
// so raise R, raise G, drop R, raise B, drop G, etc?
int p = (i + 2) % 3; // previous index
if(rgb[i] >= 255 && rgb[p] > 0) {
rgb[p] -= step;
if(rgb[p] < 0) rgb[p] = 0;
@TheEmpty
TheEmpty / Output
Last active December 26, 2015 17:08
Quick Sort in Erlang
$ erl
1> c(misc_lib). % compile module
{ok,misc_lib}
2> misc_lib:quickSort([1, 9, 6, 3, 0, 5, 2, 5082, 5, 2]).
[0,1,2,2,3,5,5,6,9,5082]
@TheEmpty
TheEmpty / crypt.py
Last active December 16, 2015 11:28
PGP Example (using static values)
def crypt(mod, key, data, hashes = 50):
encrypted = []
for v in data:
for i in range(0, hashes + 1):
v = (v ** key) % mod
encrypted.append(v)
return list(map(int, encrypted))
# My keys (p and q are intermediates)
p = 11
@TheEmpty
TheEmpty / main.py
Last active December 16, 2015 11:28
Python PGP (attempt)
import pgp
print("Generating keys...")
p = pgp.generateLargePrime(1024)
q = pgp.generateLargePrime(1024)
mod = p * q
print("Generating public key...")
public = pgp.generatePublic(p, q)
print("Generating private key...")
private = pgp.generatePrivate(p, q, public)