Skip to content

Instantly share code, notes, and snippets.

@phylake
phylake / openssl.md
Last active February 4, 2019 20:25
openssl help

Assignment in most other languages could be thought of as a stateful computation. For instance, when we do x = 5 in an imperative language, it will usually assign the value 5 to the variable x and it will also have the value 5 as an expression. If you look at that functionally, you could look at it as a function that takes a state (that is, all the variables that have been assigned previously) and returns a result (in this case 5) and a new state, which would be all the previous variable mappings plus the newly assigned variable.

http://learnyouahaskell.com/for-a-few-monads-more#state

@phylake
phylake / Main.as
Last active December 16, 2015 17:29
closure challenge
package
{
import flash.display.Sprite;
import flash.events.Event;
/**
* 1. What will be printed to the console (via the trace statement)?
* 2. What is the value of this inside of nested()
*/
public class Main extends Sprite
@phylake
phylake / logicalOR_replacement.md
Last active December 16, 2015 04:49
reg ex goodies

Replace all logical or assignment A ||= B with A || (A = B)

([^\s]+) \|\|= (.*);

$1 || ($1 = $2);

@phylake
phylake / .gemrc
Created February 29, 2012 20:18
gemrc
gem: --no-rdoc --no-ri
@phylake
phylake / vigenere.rb
Created February 9, 2012 23:35
1.61803398874.com solution
l = "xfbhlqtlj".split('').collect {|c| c[0] - 97}
k = [6,1,8,0,3,3,9,8,8]
l = l.zip(k).collect do |p|
t = (p[0] - p[1]) % 26
t += 97
t.chr
end
p l.join('')