Skip to content

Instantly share code, notes, and snippets.

@somaholiday
somaholiday / sketch_00_rect_follows_mouse.pde
Last active May 23, 2021 17:15
Seamlessly Looping Art • Code Samples
int rectSize = 100;
void setup() {
size(500, 500);
}
void draw() {
// This will draw a rectangle with a top-left corner where your mouse cursor is.
rect(mouseX, mouseY, rectSize, rectSize);
}
@eliotsykes
eliotsykes / todo.js
Last active January 28, 2020 04:32
JSON API with jQuery AJAX and Rails
// Wrap in anonymous function to avoid adding variables to global scope needlessly.
(function($) { // $ is jQuery
function addTodoToDOM(data) { // 'data' is object built from response JSON
// id will be needed when adding delete functionality dynamically.
// var todoId = data.todo.id;
// Add HTML for new todo to document
var tableRow = '<tr><td>' + data.todo.description + '</td></tr>';
@skipjac
skipjac / global.css
Created November 25, 2014 00:36
Changing the size of HelpCenter nesty fields.
.nesty-input {
max-width: 555px;
}
@donnierayjones
donnierayjones / LICENSE
Last active March 26, 2024 01:51
Render Bootstrap as "small" layout when printing
Copyright (C) 2016 Donnie Ray Jones
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:
@matthewmueller
matthewmueller / osx-for-hackers.sh
Last active April 21, 2024 03:30
OSX for Hackers (Mavericks/Yosemite)
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
@WattsInABox
WattsInABox / .gitignore
Last active March 28, 2024 04:31
Generate Static HTML Website Using Ruby on Rails
# Ignore static version of the site (used to upload error pages to S3 for Heroku errors)
/out
@michaelglass
michaelglass / alerts_and_confirms.rb
Last active September 24, 2019 10:15
test alerts & confirms in poltergeist & capybara webkit
module AlertConfirmer
class << self
def reject_confirm_from &block
handle_js_modal 'confirm', false, &block
end
def accept_confirm_from &block
handle_js_modal 'confirm', true, &block
end
@melekes
melekes / companies.rb
Created November 13, 2013 15:05
Writing tests using FactoryGirl and validating presence of nested attributes (http://homeonrails.com/2012/10/validating-nested-associations-in-rails/) P.S. code not tested
require 'factory_girl'
FactoryGirl.define do
factory :company do
name "Twitter Corp."
before(:create) do |company, evaluator|
offices_attributes = []
3.times do # 3 offices per company
offices_attributes << attributes_for(:office)
@tomas-stefano
tomas-stefano / Capybara.md
Last active May 21, 2024 02:09
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@SabretWoW
SabretWoW / rspec_model_testing_template.rb
Last active March 7, 2024 03:56
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems: