Skip to content

Instantly share code, notes, and snippets.

@rcmoret
rcmoret / vrc
Created Sep 15, 2016
Script for opening a rails console for an app within vagrant
View vrc
#! /bin/bash
if [[ -z $1 ]]; then
APP_NAME=$(basename `pwd`)
else
APP_NAME=$1
fi
echo "Opening Rails Console for $APP_NAME in vagrant..."
cd ~/vagrant && vagrant ssh -c "cd /pub/$APP_NAME/current && bundle exec rails console"
View essential-javascript-links.md
@pjrvs
pjrvs / newslettercookie.html
Last active Nov 7, 2017
a jquery cookie that shows a signup form for people that aren't signed up and an alternate message for people that came from the list or signed up.
View newslettercookie.html
<!DOCTYPE html>
<html>
<head>
<title>jQuery Cookie + MailChimp</title>
<meta charset="utf-8">
</head>
<body>
<form action="XXX" method="post" class="signup">
@kyletcarlson
kyletcarlson / rspec_model_testing_template.rb
Last active Apr 19, 2021
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…
View rspec_model_testing_template.rb
# 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:
@mfilej
mfilej / db_terminate_backend.rake
Created Jul 7, 2013
Rake task to terminate idle postgresql connections that prevent a database to be dropped
View db_terminate_backend.rake
# http://stackoverflow.com/questions/5108876/kill-a-postgresql-session-connection
namespace :db do
desc "Fix 'database is being accessed by other users'"
task :terminate => :environment do
ActiveRecord::Base.connection.execute <<-SQL
SELECT
pg_terminate_backend(pid)
FROM
pg_stat_activity
WHERE
@wnstn
wnstn / beautiful.scss
Last active Dec 19, 2015
I love you Sass
View beautiful.scss
.feed-section-header {
margin: 0;
font-size: 1.1em;
$groups: community $community \70, teams $teams \72, college $college \71, for-you $gray \6b;
@each $group in $groups {
&.#{nth($group, 1)} {
color: #{nth($group, 2)};
.feed-icon {
@dcalhoun
dcalhoun / cs-pattern-library.md
Last active Dec 18, 2015
Centresource Pattern Library List
View cs-pattern-library.md

Centresource Pattern Library Guide

Below are elements that are expected to be in a Photoshop pattern library file.

Typography

  • Headers (h1 - h5)
  • Paragraphs
  • Lead Copy
  • Unordered List
@bval
bval / .htrouter.php
Created Feb 19, 2013
This is a router for Drupal and other PHP apps that rely on mod_rewrite rules for "clean URLs" so that those same apps can be run under PHP 5.4's built-in webserver which doesn't support mod_rewrite.
View .htrouter.php
<?php
/**
* @file
* The router.php for clean-urls when use PHP 5.4.0 built in webserver.
*
* Usage:
*
* php -S localhost:3000 .htrouter.php
*
*/
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@nordyke
nordyke / MultiSortCollection.js
Created Dec 27, 2011
Multi-sort on any number of Backbone Collection attributes. Sort happens from arguments[0] to arguments[n]
View MultiSortCollection.js
var MultiSortCollection = Backbone.Collection.extend({
/**
* Sort by supplied attributes. First param is sorted first, and
* last param is final subsort
* @param {String} sortAttributes
* @example collection.sortBy("last_name","first_name")
*/
sortBy : function(sortAttributes){
var attributes = arguments;