Skip to content

Instantly share code, notes, and snippets.

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import "fmt"
// Send the sequence 2, 3, 4, ... to channel 'ch'.
func generate(ch chan int) {

Keybase proof

I hereby claim:

  • I am patcoll on github.
  • I am patcoll (https://keybase.io/patcoll) on keybase.
  • I have a public key whose fingerprint is 440C 9946 B7C6 D95E 66B9 AF79 CD15 A5E4 D60B 08AD

To claim this, I am signing this object:

@patcoll
patcoll / twig.php
Created March 2, 2010 15:53
Command-line script to process YAML frontmatter with Twig templates.
<?php
/**
* twig.php
*
* Command-line script to process YAML frontmatter with Twig templates.
* Inspired by Mustache <http://github.com/defunkt/mustache>.
*
* Example template file (test.html):
* ---
* people: [ {name: scott}, {name: laura} ]
Then /^I should be able to change the "(name|teaser_text|full_text)" of the ad with an inline editor$/ do |field|
require 'time'
selector = ".inline-edit em.text .#{field}"
old_value = find(selector).text
value = "New Value #{Time.now.to_i}"
find(selector).click
wait_until { find_field(field) }
fill_in(field, :with => value)
file_content = File.open(datafile).map do |line|
line = line.split(',').map { |n| n.strip }
line.each_index do |i|
line[i] = { labels[i][0] => line[i] }
end
line = line.inject({}) { |merged,n| merged.update(n) }
line = { line.delete('LOGRECNO') => line }
end
puts file_content.to_json
@patcoll
patcoll / gist:706951
Created November 19, 2010 18:56
config.ru
require 'rubygems'
require 'padrino'
class App < Padrino::Application
register Padrino::Mailer
register Padrino::Helpers
get("/") { "index" }
get("/index") { "index" }
get("/index", :provides => :html) { "index" }
@patcoll
patcoll / gist:742421
Created December 15, 2010 18:59
arduino_funnel_sinatra_app.rb
require 'rubygems'
require 'sinatra'
$: << '..'
# prepare for using the Funnel library
require 'funnel'
include Funnel
# configure pin(s) of the Arduino board
@patcoll
patcoll / gist:788526
Created January 20, 2011 20:01
php52-ubuntu-lucid.sh
#!/bin/bash
sed s/lucid/karmic/g /etc/apt/sources.list | tee /etc/apt/sources.list.d/karmic.list
aptitude update -y
cat > /etc/apt/preferences.d/php <<heredoc
Package: php5
Pin: version 5.2.*
Pin-Priority: 991
Package: php5-cli
Pin: version 5.2.*
#!/bin/bash
# installs latest PHPUnit
# use sudo if necessary
pear upgrade PEAR # newest phpunit needs pear 1.9.2
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear channel-discover pear.phpunit.de
pear install phpunit/PHPUnit
@patcoll
patcoll / copy_zf_files.sh
Created April 13, 2011 15:26
Copy only certain Zend Framework libs and their dependencies into a specified directory
#!/bin/bash
#
# Copy only certain Zend Framework libs and their dependencies into a specified directory.
#
# This script was created because copying the entire Zend Framework into an existing project
# is not really necessary if you only want to use part of it. However you fall into dependency
# hell because most sub-libraries use multi-purpose libs like Zend_Exception and Zend_Validate.
#
# Put this script in a fresh copy of ZF's `library` folder and run it as follows:
#