Skip to content

Instantly share code, notes, and snippets.

View andrzejsliwa's full-sized avatar

Andrzej Śliwa andrzejsliwa

View GitHub Profile
# Assuming you're on Ubuntu or OSX
#
GIT=$(dirname `which git`)
sudo install -m 755 git-lh.rb $GIT/git-lh
sudo install -m 755 git-lh-push.sh $GIT/git-lh-push
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
# Send a request to recaptcha to verify the user's input.
#
# The first argument must be an object containing four parts:
# privatekey: Your recaptcha private key.
# remoteip: The IP of the user who submitted the form.
# challenge: The challenge value from the recaptcha form.
# response: The user's response to the captcha.
#
# Example usage (express):
#
# Copyright (c) 2010 Sabin Iacob <iacobs@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in

CRUD requires jquery.deepjson.js to work so it should be included

<script type="text/javascript" src="js/jquery.deepjson.js"></script>

Then you can assign whatever's in crud.json to a variable or you can put crud.json into your evently directory and let couchapp push it to your application.

Simplest way to use it is

#!/usr/local/bin/ruby -w
require 'rubygems'
ERLC_FLAGS = "-Ideps +warn_unused_vars +warn_unused_import"
####
# SETUP
####
# Cleaning up and extending the Gemfile
remove_file 'Gemfile'
create_file 'Gemfile', <<-GEMFILE
source 'http://rubygems.org'
gem 'rails', '3.0.1'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'haml', '~> 3.0.12'
@andrzejsliwa
andrzejsliwa / gist:778535
Created January 13, 2011 20:29
list all available cucumber steps - (rake cucumber:steps)
# based on http://www.natontesting.com/2010/01/11/updated-script-to-list-all-cucumber-step-definitions/
#
desc 'List all defined steps'
task :steps do
require 'hirb'
extend Hirb::Console
puts "CUCUMBER steps:"
puts ""
step_definition_dir = "features/step_definitions"
Feature: Validate moves
Scenario: Moving the knight illegally
Given the following board:
| | | | | | | | |8|
| | | | | | | | |7|
| | | | | | | | |6|
| | | | | | | | |5|
| | | |♞| | | | |4|
| | | | | | | | |3|
|♙| | | | | | | |2|
[error] [<0.631.0>] attempted upload of invalid JSON (set log_level to debug to log it)
[debug] [<0.631.0>] Invalid JSON: <<"{\"vendor\": {\"couchapp\": {\"evently\": {\"profile\": {\"profileReady\": {\"after\": \"function(e, p) {\\n $$(this).profile = p;\\n};\", \"data\": \"function(e, p) {\\n return p\\n}\", \"mustache\": \"<div class=\\\"avatar\\\">\\n {{#gravatar_url}}<img src=\\\"{{gravatar_url}}\\\"/>{{/gravatar_url}}\\n <div class=\\\"name\\\">\\n {{nickname}}\\n </div>\\n</div>\\n<p>Hello {{nickname}}!</p>\\n<div style=\\\"clear:left;\\\"></div>\"}, \"noProfile\": {\"data\": \"function(e, userCtx) {\\n return userCtx;\\n}\", \"mustache\": \"<form>\\n <p>Hello {{name}}, Please setup your user profile.</p>\\n <label for=\\\"nickname\\\">Nickname \\n <input type=\\\"text\\\" name=\\\"nickname\\\" value=\\\"\\\"></label>\\n <label for=\\\"email\\\">Email (<em>for <a href=\\\"http://gravatar.com\\\">Gravatar</a></em>)\\n <input type=\\\"text\\\" name=\\\"email\\\" value=\\\"\\\"></label>\