View vi_vs_emacs.txt
vi | |
automating actions through repetition and composition | |
with strengths to ubiquity and use through the terminal | |
"programmable editing" | |
emacs | |
extensibility by way of the power of lisp | |
make the editor do everything that you want in the way you want | |
make these functionalities easy to put in and pull out | |
a truly "programmable" editor |
View .vimrc
colo elflord |
View png_to_console.rb
require 'chunky_png' # viewable at: http://i.imgur.com/C9Utu2N.png | |
palette = ["X","O","#","*","o","%","=","-","."] | |
puts ChunkyPNG::Image.from_file("poke_red.png").pixels.map {|p| p/256 % 256}.each_slice(160).map {|r| r.map {|n| palette[9-n/10*100/256]}.join("") }.join("\n") | |
=begin | |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
View install-tmux
# Install tmux on Centos release 6.5 | |
# install deps | |
yum install gcc kernel-devel make ncurses-devel | |
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL | |
curl -OL https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz | |
tar -xvzf libevent-2.0.21-stable.tar.gz | |
cd libevent-2.0.21-stable | |
./configure --prefix=/usr/local |
View maybe_monad.java
import java.util.function.Function; | |
// Maybe is a monad. Why is it a monad? It is a monad because it: | |
// A) wraps a value | |
// B) provides a way of applying functions/calling methods on the wrapped value | |
// C) always returns an instance of itself when it does this. | |
class Maybe<T> { | |
private T value; | |
public Maybe(T value) { |
View maybe_for.rb
class Maybe | |
def initialize(value) | |
@value = value | |
end | |
def map(&block) | |
Maybe.new(bind &block) | |
end | |
def bind |
View security_monad_oop.rb
class User | |
attr_reader :hashed_pass | |
def initalize | |
@hashed_pass = "" | |
end | |
def change_profile_pic(other_pic) | |
@profile_pic = other_pic | |
end | |
end |
View security_monad.rb
db = [{name: "Jim", secret: "I peed my pants.", super_secret: "I love Nickleback."}] | |
user = {name: "Jim"} | |
get_secret = -> user { secret = db.find {|db_user| db_user[:name] == user[:name]}[:secret]; user.merge({secret: secret}) } | |
get_super_secret = -> user { super_secret = db.find {|db_user| db_user[:name] == user[:name]}[:super_secret]; user.merge({super_secret: super_secret}) } | |
bind = -> x, f { x[:secure] ? f[x[:value]].merge({secure: true}) : x } # security-aware manner of calling functions/methods | |
unit = -> n { {secure: false, value: n} } # makes objects security-aware | |
lift = -> f { -> x { unit[f[x]] } } # makes functions/methods security-aware |
View currying.cpp
// Run online: https://eval.in/506636 | |
#include <iostream> | |
#include <functional> | |
// curries any function from (int, int) -> int into int -> (int -> int) | |
auto curry(int (*func)(int, int)) -> std::function<std::function<int (int)> (int)> { | |
return [func] (int x) { | |
return [func, x] (int y) { | |
return func(x, y); | |
}; |
View not_match.rb
irb(main):010:0> Parser::CurrentRuby.parse("\"123\" =~ /1/") | |
=> (send | |
(str "123") :=~ | |
(regexp | |
(str "1") | |
(regopt))) | |
irb(main):011:0> Parser::CurrentRuby.parse("\"123\" !=~ /1/") | |
=> (send | |
(str "123") :!= | |
(send |