Skip to content

Instantly share code, notes, and snippets.

View anqurvanillapy's full-sized avatar

Anqur anqurvanillapy

View GitHub Profile
@anqurvanillapy
anqurvanillapy / lambda.sh
Created March 19, 2018 16:48
Fake lambda in Bash
#!/usr/bin/env bash
echo 42 | (_() { read __; echo $((__ + 1));}; _) | (_() { read __; echo $((__ * 2));}; _)
@anqurvanillapy
anqurvanillapy / DistributionCenter.java
Last active January 8, 2017 23:44
A distribution center using producer-consumer pattern with 2 threads
import java.lang.*;
public class DistributionCenter {
public static void main(String[] args) {
PackageContainer center = new PackageContainer(100);
PackageSender sender = new PackageSender(center);
PackageReceiver recver = new PackageReceiver(center);
System.out.println("(max: " + center.getCapacity() + ")");
System.out.println(center.getInventory());
@anqurvanillapy
anqurvanillapy / TextColorizer.java
Last active January 6, 2017 17:27
A simple Observer demo - colorize some text
import java.util.Scanner;
import java.util.Objects;
class ANSIColor {
public static final String RED = "\u001B[31m";
public static final String GREEN = "\u001B[32m";
public static final String BLUE = "\u001B[34m";
public static final String ENDC = "\u001B[0m";
}
@anqurvanillapy
anqurvanillapy / smlmap.py
Last active December 9, 2016 05:10
Standard-ML-like recursive `map()` in py35 (with benchmarks)
import time
from collections import deque
def timing(f):
def wrap(*args):
start = time.time()
ret = f(*args)
elapsed = time.time() - start
print('{}: {:0.3f}ms'.format(f.__name__, elapsed * 1000.0))
@anqurvanillapy
anqurvanillapy / extract_drp.py
Last active October 12, 2016 14:18 — forked from dantarion/DRP extractor v1
Extract a single WiiU DRP file into readable XML (with .bin extension)
#!/usr/bin/env python
import os, sys
import zlib
from struct import pack, unpack
def extractFile(filename):
f = open(filename, "rb")
f.seek(0x14)
@anqurvanillapy
anqurvanillapy / keybase.md
Last active July 27, 2016 08:48
Keybase proof of me on GitHub

Keybase proof

I hereby claim:

  • I am anqurvanillapy on github.
  • I am anqurvanillapy (https://keybase.io/anqurvanillapy) on keybase.
  • I have a public key ASDmT1cEQQsi-_ROMEca-bW36XhW5mexN94m1QurPbqhvwo

To claim this, I am signing this object:

@anqurvanillapy
anqurvanillapy / signature.py
Last active September 1, 2015 09:04
Adding Signature Magic in IPython Notebook
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Most codes graped from Berlin developer
# @yaph (Ramiro Gómez)
# http://ramiro.org/ / https://github.com/yaph
# Copied for learning. Sincerely thanks to his work!
from datetime import datetime
from IPython.core import display