Skip to content

Instantly share code, notes, and snippets.

Avatar

Tim Ruffles timruffles

View GitHub Profile
@spion
spion / 01-fractal-weird-design.md
Last active Nov 2, 2019
Node streams - a fractal of weird design
View 01-fractal-weird-design.md

Node streams - a fractal of weird design

and a potential refactor that could fix that

This is a list of issues and confusions I've encountered with node streams, and things I wish were designed and implemented differently. If promise-streams is ever going to change to a design that doesn't build on top of node streams, this would be a list of mistakes to avoid

  1. enc parameter - Why is encoding always passed together with the data? It should be a separate concern. It doesn't even make sense in objectMode
  2. eventemitter base - This encourages a lot of random events to be "attached" by other authors which doesn't work. Best to have an uniform (typed) interface so that everyone knows what to expect.
  3. relying on nextTick etc for execution order - This is very unreliable and causes all sorts of unpredictable rules for implementers which are not documented anywhere. When you attach listeners determines what will happen.
  4. no error propagation - we need the
@drbrain
drbrain / nightmares.rb
Last active Jul 25, 2017
A method that has a default argument that defines a method that contains a here-document
View nightmares.rb
def a l = def b; <<-NIGHTMARES; end; puts send l; end
😱😱😱
NIGHTMARES
a
@anaisbetts
anaisbetts / analytics.js
Created Jan 7, 2015
Google Analytics in Atom Shell
View analytics.js
// Pretend that cookies work
(function (document) {
var cookies = {};
document.__defineGetter__('cookie', function () {
var output = [];
for (var cookieName in cookies) {
output.push(cookieName + "=" + cookies[cookieName]);
}
return output.join(";");
});
@dscape
dscape / books.txt
Last active Aug 29, 2015
Books for the YLD Office
View books.txt
Predictably Irrational: The Hidden Forces that Shape Our Decisions
Quiet: The power of introverts in a world that can't stop talking
Business Adventures
Zero to One
Beyond Budgeting
Winning Decisions: Getting It Right the First Time
Creativity Inc
Good to Great
Surviving & Thriving in a Relationship with an Entrepreneur
First, Break All the Rules
View riak_backend.ex
defmodule Beamie.Store.RiakHTTP do
def put(bucket, key, value) do
IO.puts "storing value #{inspect value} with key #{key} in bucket '#{bucket}'"
put_req(bucket, key, value)
end
def get(bucket, key) do
IO.puts "retrieving value for key #{key} from bucket '#{bucket}'"
get_req(bucket, key)
end
View CYPHERLINK.md
@banaslee
banaslee / XGH - en.txt
Last active Dec 19, 2020
eXtreme Go-Horse Process
View XGH - en.txt
eXtreme Go Horse (XGH) Process
Source: http://gohorseprocess.wordpress.com
1. I think therefore it's not XGH.
In XGH you don't think, you do the first thing that comes to your mind. There's not a second option as the first one is faster.
2. There are 3 ways of solving a problem: the right way, the wrong way and the XGH way which is exactly like the wrong one but faster.
XGH is faster than any development process you know (see Axiom 14).
@andkerosine
andkerosine / raskell.rb
Created Aug 15, 2012
Haskell-like list comprehensions in Ruby
View raskell.rb
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@alco
alco / gist:2165064
Created Mar 22, 2012
Count the number of non-blank SLOC in an Elixir project
View gist:2165064
git ls-files | egrep '\.erl|\.ex[s]$' | xargs cat | sed '/^$/d' | wc -l
View gist:1975644
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
You can’t perform that action at this time.