This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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} ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'padrino' | |
class App < Padrino::Application | |
register Padrino::Mailer | |
register Padrino::Helpers | |
get("/") { "index" } | |
get("/index") { "index" } | |
get("/index", :provides => :html) { "index" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra' | |
$: << '..' | |
# prepare for using the Funnel library | |
require 'funnel' | |
include Funnel | |
# configure pin(s) of the Arduino board |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define SYNC_INTERVAL 60 | |
@interface AppDelegate : NSObject <UIApplicationDelegate> { | |
// ... | |
NSMutableDictionary *mocs; | |
NSMutableDictionary *mocThreads; | |
// ... | |
} | |
@property (nonatomic, retain) NSMutableDictionary *mocs; | |
@property (nonatomic, retain) NSMutableDictionary *mocThreads; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I wanted a proof-of-concept for streaming binary data from a MongoDB document with Mongoose. | |
// I'm using express as web framework here but you should be able to pipe to anything that expects a stream. | |
// Based on https://gist.github.com/1403797 | |
//// [ other express app stuff... ] | |
app.get('/files/:file', function(req, res, next) { | |
var queryfileId = req.params.file; | |
var GrabBinaryForField = require('./streamformatters').GrabBinaryForField; | |
// "buffer" is the field on my model that stores the binary data |
OlderNewer