Skip to content

Instantly share code, notes, and snippets.

@ericgj
ericgj / gist:1c091837431c7f0ec230
Created February 22, 2015 04:11
npm install error
This file has been truncated, but you can view the full file.
8004 http fetch 200 https://registry.npmjs.org/growl/-/growl-1.8.1.tgz
8005 silly fetchAndShaCheck shasum 4b2dec8d907e93db336624dcec0183502f8c9428
8006 verbose addTmpTarball /tmp/npm-949-95ba9a63/registry.npmjs.org/growl/-/growl-1.8.1.tgz not in flight; adding
8007 verbose addTmpTarball already have metadata; skipping unpack for growl@1.8.1
8008 silly cache afterAdd growl@1.8.1
8009 verbose afterAdd /home/egjertsen/.npm/growl/1.8.1/package/package.json not in flight; writing
8010 silly gunzTarPerm extractEntry lib/babel/build-helpers.js
8011 verbose afterAdd /home/egjertsen/.npm/growl/1.8.1/package/package.json written
8012 info preinstall source-map@0.1.34
8013 http 200 https://registry.npmjs.org/jade
@ericgj
ericgj / gist:759570
Created December 30, 2010 07:50
notes on s1-final

Demonstration of copy-on-write behavior in Ruby arrays

(No shared state between arrays)

input = [[1,2,3,4],[11,12,13,14]]
rows = input
cols = []; rows[0].each_index {|i| cols << rows.map {|r| r[i]}}
pp cols    
#  [[1, 11], [2, 12], [3, 13], [4, 14]]

initially the object values and references are the same

class Table
def initialize(data = [], options = {})
check_type data
data.each do |row|
check_type row
check_length row, data.first.length
end
@header_support = options[:headers]
@ericgj
ericgj / alt_select_columns.rb
Created January 30, 2011 15:51
A non-destructive implementation of Table#select_columns that creates a new table (note this is not tested)
class Table
def max_y
@rows[0].length
end
def select_columns
selected = (0..(max_y - 1)).map do |i|
col = @rows.map {|row| row[i] }
@ericgj
ericgj / draft.rb
Created June 15, 2011 14:25
rails app template for RbMU
# Usage:
# rails new myapp --template=path/to/this/file.rb -J
appname = File.expand_path(Dir.new('.')).split('/').last
#--------------- Gem setup
# Note this is mostly copied from puzzlenode
#
file 'Gemfile', <<_____
source 'http://rubygems.org'
@ericgj
ericgj / 1-version_info.rb
Created September 14, 2011 02:23
version_info.rb
require 'version_info/data'
require 'version_info/tasks'
module VersionInfo
# current segments or defaults
def self.segments
@segments ||= [:major, :minor, :patch]
end
@ericgj
ericgj / 1-README.markdown
Created September 27, 2011 19:24
Todoer

My key requirements were

  • the syntax should be as close to simply writing a note to yourself as possible
  • it has to be easy to add or remove something from a todo list wherever you are in the filesystem
  • it should be easy to add or remove a task based on previous tasks added
  • it should not make changes to a file that you are editing manually
  • it should not rewrite the file each time a change is made, if possible

The commands to add and remove tasks are one-liner bash scripts to echo the command line to ~/.todo, basically. ++ is add, xx is remove. (You can name them whatever you like, of course.)

@ericgj
ericgj / 0-INDEX.md
Created January 9, 2012 15:03
Several things I learned this week: 9 Jan
  1. Trollop command-line parser lets you parse any array of tokens, not just ARGV. (todoer)
    1b. Bonus: how to have "plug in" options using Trollop
  2. When refactoring, it's often tricky to know where a particular set of changes are going to go. So it pays to look in detail at the code beforehand and not jump into writing specs when you don't even know the subject of the tests yet. But in looking at the code, it doesn't mean you're going in to make changes to it.
  3. You want to run several implementations, with a different set of fixtures, through the same set of specs. One way. (todoer)
@ericgj
ericgj / -natural-languages.md
Created January 19, 2012 19:21
How to Teach Webcraft and Programming to Free-Range Students

Notes on natural-(second) language learning and learning programming languages

1. Notes from a course on teaching English pronounciation and grammar

Summary

I think some of the lessons here are useful to the situation of someone who already has learned some programming concepts (grammatical structure), but is struggling with a new programming language, especially one that is based in a different paradigm. Or someone who has a handle on procedural programming for instance (the basic mechanics of doing something with the language), but now is being introduced to compositional/design issues.

In other words: someone who can get by in the language, but is not fluent, and may need help in any number of areas, depending on their background.

@ericgj
ericgj / template.rb
Created February 1, 2012 05:21
Templating ripped out of Sinatra
# Note: ripped out of Sinatra, minus any `setting` calls, and disabling inline templates
# Template rendering methods. Each method takes the name of a template
# to render as a Symbol and returns a String with the rendered output,
# as well as an optional hash with additional options.
#
# `template` is either the name or path of the template as symbol
# (Use `:'subdir/myview'` for views in subdirectories), or a string
# that will be rendered.