Skip to content

Instantly share code, notes, and snippets.

View gacha's full-sized avatar

Gatis Tomsons gacha

  • eazyBI
  • Ventspils, Latvia
View GitHub Profile
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=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')
@gacha
gacha / overlay.js
Created July 22, 2010 05:25
overlay your form while Ajax in progress
// 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()
@gacha
gacha / headless
Last active September 24, 2015 08:58
With this you can run cucumber with selenium without seeing browser window. Add it to PATH and chmod +x
#!/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
$@
@jaspervdj
jaspervdj / volume.rb
Created February 7, 2011 16:17
Set pulseaudio volume from the command line
#!/usr/bin/ruby
# Pulseaudio volume control
class Pulse
attr_reader :volumes, :mutes
# Constructor
def initialize
dump = `pacmd dump`.lines
@volumes = {}
@bentruyman
bentruyman / express-stylus.html
Created February 13, 2011 19:27
Using Stylus Middleware with Express
<!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>
@pfleidi
pfleidi / fiberchat.rb
Created February 19, 2011 18:51
A naive socket chat using select() and ruby fibers
require 'rubygems'
require 'socket'
include Socket::Constants
class ChatServer
def initialize
@reading = Array.new
@writing = Array.new
@clients = Hash.new
# 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:
@andrewsardone
andrewsardone / design.js
Created October 21, 2011 22:14
CouchDB list function for an icalendar format
// 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
//
@spalladino
spalladino / can_destroy.rb
Created January 31, 2012 14:42
How to check if object can be destroyed if it has dependent restrict associations
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
@mourner
mourner / TileLayer.Common.js
Created February 11, 2012 23:11
Leaflet shortcuts for common tile providers
// 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 () {