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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button 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
// Usage: | |
// | |
// simply show it: | |
// $('#content .my_form').overlay().show() | |
// | |
// show with custom CSS options: | |
// $('#content .my_form').overlay().show({width: '500px',opacity: 0.5}) | |
// | |
// hide it: | |
// $('#content .my_form').overlay().hide() |
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/sh | |
if [ $(pidof -x Xvfb| wc -w) -eq 0 ]; then | |
Xvfb -ac -screen scrn 1024x768x24 :12.0 > /dev/null 2>&1 & | |
fi | |
export DISPLAY=:12.0 | |
$@ |
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
#!/usr/bin/ruby | |
# Pulseaudio volume control | |
class Pulse | |
attr_reader :volumes, :mutes | |
# Constructor | |
def initialize | |
dump = `pacmd dump`.lines | |
@volumes = {} |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<title>My Web Page</title> | |
<meta charset="utf-8"> | |
<link href="/stylesheets/main.css" rel="stylesheet"> | |
</head> | |
<body> | |
</body> | |
</html> |
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 'socket' | |
include Socket::Constants | |
class ChatServer | |
def initialize | |
@reading = Array.new | |
@writing = Array.new | |
@clients = Hash.new |
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
# These are my notes from the PragProg book on CoffeeScript of things that either | |
# aren't in the main CS language reference or I didn't pick them up there. I wrote | |
# them down before I forgot, and put it here for others but mainly as a reference for | |
# myself. | |
# assign arguments in constructor to properties of the same name: | |
class Thingie | |
constructor: (@name, @url) -> | |
# is the same as: |
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
// http://localhost:5984/db/_design/doc/_list/ics/events | |
// | |
// HTTP/1.1 200 OK | |
// Vary: Accept | |
// Transfer-Encoding: chunked | |
// Server: CouchDB/1.1.0 (Erlang OTP/R14B03) | |
// Etag: "6A5G0HZINBK0F6S0NSE7KHM2M" | |
// Date: Fri, 21 Oct 2011 22:11:15 GMT | |
// Content-Type: text/calendar | |
// |
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
class ActiveRecord::Base | |
def can_destroy? | |
self.class.reflect_on_all_associations.all? do |assoc| | |
assoc.options[:dependent] != :restrict || (assoc.macro == :has_one && self.send(assoc.name).nil?) || (assoc.macro == :has_many && self.send(assoc.name).empty?) | |
end | |
end | |
end |
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
// Lefalet shortcuts for common tile providers - is it worth adding such 1.5kb to Leaflet core? | |
L.TileLayer.Common = L.TileLayer.extend({ | |
initialize: function (options) { | |
L.TileLayer.prototype.initialize.call(this, this.url, options); | |
} | |
}); | |
(function () { | |
OlderNewer