Skip to content

Instantly share code, notes, and snippets.

module Helpers
def sign_in(user)
@user_session = UserSession.create user
end
def fill_in_autocomplete(selector, value)
page.execute_script %Q{$('#{selector}').val('#{value}').keydown()}
end
def choose_autocomplete(text)
@cj
cj / helpers.rb
Created March 8, 2012 21:05 — forked from ogredude/helpers.rb
module Helpers
def sign_in(user)
@user_session = UserSession.create user
end
def fill_in_autocomplete(selector, value)
page.execute_script %Q{$('#{selector}').val('#{value}').keydown()}
end
def choose_autocomplete(text)
# I created this because the headless webkit doesn't handle click/mouse events very well
# so when using jquery events/binds like click/focus/mousedown etc... the tests weren't passing
# because the javascript wasn't being executed because no mosue event was triggered
# this gets around that and works just like fill_in
def jquery_fill_in(selector, options)
page.execute_script %Q{
$('body').focus;
if((selector = $('##{selector}')).length || ($selector = $('label:contains(#{selector})').parent().find(':input')).length) {
$selector.focus().click().val('#{options[:with]}').keydown();
} else {
@DAddYE
DAddYE / hack.sh
Created March 19, 2012 11:31
OSX For Hackers
#!/bin/sh
##
# This is a script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# Run in interactive mode with:
# $ sh -c "$(curl -sL https://raw.github.com/gist/2108403/hack.sh)"
#
# or run it without prompt questions:
@rmw
rmw / hash.rb
Created May 16, 2012 13:50
Extend Ruby Hash with method to return a recursive OpenStruct
class Hash
# options:
# :exclude => [keys] - keys need to be symbols
def to_ostruct_recursive(options = {})
convert_to_ostruct_recursive(self, options)
end
private
def convert_to_ostruct_recursive(obj, options)
result = obj
@randym
randym / example_table_autofilter.rb
Created July 25, 2012 23:21
Example: Setting up auto filters / Table with axlsx
#Using Tables:
#This will add in the sorting filters for you as well as apply default table styling in excel.
#LibraOffice does the filters, but not the styling (as does Google docs if I recall correctly.)
#```ruby
wb.add_worksheet(:name => "Table") do |sheet|
sheet.add_row ["Build Matrix"]
sheet.add_row ["Build", "Duration", "Finished", "Rvm"]
sheet.add_row ["19.1", "1 min 32 sec", "about 10 hours ago", "1.8.7"]
/*
AngularUI for AngularJS
v0.1.0
@link http://angular-ui.github.com/
*/
angular.module("ui.config", []).value("ui.config", {});
angular.module("ui.filters", ["ui.config"]);
@millermedeiros
millermedeiros / osx_setup.md
Last active March 23, 2025 01:23
Mac OS X setup

Setup Mac OS X

I've done the same process every couple years since 2013 (Mountain Lion, Mavericks, High Sierra, Catalina) and I updated the Gist each time I've done it.

I kinda regret for not using something like Boxen (or anything similar) to automate the process, but TBH I only actually needed to these steps once every couple years...

@bryanp
bryanp / pakyow-full.html
Last active August 29, 2015 14:02
Faster View Manip
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Pakyow - Ruby Web Framework</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" media="screen, projection" href="/stylesheets/screen.css">
<link rel="stylesheet" type="text/css" media="print" href="/stylesheets/print.css">
<link rel="shortcut icon" type="image/png" href="/favicon.png">
@albertbori
albertbori / Installation.md
Last active April 9, 2025 08:52
Automatically disable Wifi when an Ethernet connection (cable) is plugged in on a Mac

Overview

This is a bash script that will automatically turn your wifi off if you connect your computer to an ethernet connection and turn wifi back on when you unplug your ethernet cable/adapter. If you decide to turn wifi on for whatever reason, it will remember that choice. This was improvised from this mac hint to work with Yosemite, and without hard-coding the adapter names. It's supposed to support growl, but I didn't check that part. I did, however, add OSX notification center support. Feel free to fork and fix any issues you encounter.

Most the credit for these changes go to Dave Holland.

Requirements

  • Mac OSX 10+
  • Administrator privileges