Skip to content

Instantly share code, notes, and snippets.

View InPermutation's full-sized avatar

Jacob Krall InPermutation

View GitHub Profile
@InPermutation
InPermutation / gist:a1359101e01070966b31
Created October 29, 2015 19:10
Slackbot responses for games of chance
d6, roll a die
==============
rolls a 1
rolls a 2
rolls a 3
rolls a 4
rolls a 5
rolls a 6
d12
@InPermutation
InPermutation / regex_shortener.py
Created October 15, 2014 20:29
Shorten a regex, allowing false positives
s = 'amsterdam|london|tokyo|indianapolis|new york|shanghai|toronto|san francisco'
rg = s.split('|')
# count: the length of the shortest word
count = len(min(rg, key=len))
# v: list of sets. v[0] is the set of all the first letters, etc.
v = []
for i in range(0,count):
v.append(set(w[i] for w in rg))
@InPermutation
InPermutation / anonymous_method.cs
Created July 16, 2014 01:33
Stupid C# anonymous objects tricks
// First declare the "type" of Contact
var Contact = new
{
First = (string)null,
Last = (string)null,
FullName = (Func<string>)null,
};
// Then, assign a closure over Contact to FullName to implement the "method"
Contact = new
{
@InPermutation
InPermutation / keybase.md
Created April 16, 2014 15:20
keybase.md

Keybase proof

I hereby claim:

  • I am inpermutation on github.
  • I am inpermutation (https://keybase.io/inpermutation) on keybase.
  • I have a public key whose fingerprint is 9DD6 1265 C7C7 351A 195B 8FBF 9DAB 2EE3 2923 AB

To claim this, I am signing this object:

@InPermutation
InPermutation / stack_edsl.cs
Last active August 29, 2015 13:57 — forked from brendanzab/stack_edsl.rs
A statically typed, concatenative EDSL in C#.
/// <summary>Used to enforce type nesting</summary>
public interface HList { }
public class Empty : HList { }
public class Stack<T, TChild> : HList where TChild : HList
{
public T Item { get; private set; }
public TChild Child { get; private set; }
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Undercover communication
It should be obvious by now, that the only way to communicate
stealthily and securely is to avoid raising suspicion to the
level at which the authorities might consider it worthwhile
to put you under active surveillance (e.g., park a van with
TEMPEST equipment by your apartment).
@InPermutation
InPermutation / rot13.bf
Created October 24, 2013 15:18
wondering what Brainfuck syntax highlighting even looks like
-,+[ Read first character and start outer character reading loop
-[ Skip forward if character is 0
>>++++[>++++++++<-] Set up divisor (32) for division loop
(MEMORY LAYOUT: dividend copy remainder divisor quotient zero zero)
<+<-[ Set up dividend (x minus 1) and enter division loop
>+>+>-[>>>] Increase copy and remainder / reduce divisor / Normal case: skip forward
<[[>+<-]>>+>] Special case: move remainder back to divisor and increase quotient
<<<<<- Decrement dividend
] End division loop
]>>>[-]+ End skip loop; zero former divisor and reuse space for a flag
@InPermutation
InPermutation / gist:6625573
Created September 19, 2013 15:55
Check if a treeish is a ref or a (partial) sha
$treeish = "my_tag"
# $treeish = "my_branch"
# $treeish = "900fe0a22ea332fcbfdb4b0bc7136760ea30cc19"
# $treeish = "900fe0a22"
$exists = [bool](git rev-parse --quiet --verify $treeish)
$ref = [bool](git show-ref $treeish)
$sha = -not $ref
# Check if it's a tag. (Careful; --list uses shell wildcard syntax)
using System;
using System.Threading;
class A {
static Point currentPos = new Point(1,2);
class Point {
public int x;
public int y;
public Point(int x, int y) {
this.x = x;
@InPermutation
InPermutation / mini-profiler-histogram.js
Created July 16, 2013 20:38
MiniProfiler .profiler-label histogram hack
(function(){
var common={};
$("td.profiler-label").each(function(){var txt= $(this).text().trim(); if(!(txt in common))common[txt]=0; common[txt]++; });
var rg=[];
for(var c in common)
rg.push({name: c, val: common[c]});
rg.sort(function(a,b){return b.val-a.val;});
return rg;})();