Skip to content

Instantly share code, notes, and snippets.

var vol = 20;
var t = 0;
function playSample(id) {
$("#player").stop();
vol = 20;
stopSample();
$("#player").setFile("yourfile.mp3");
fadeIn();
[alias]
co = checkout
br = branch
ci = commit
st = status
deploytag = "!git tag deploy-`date \"+%Y%m%d%H%M\"` && git push --tags"
switch = !legit switch \"$@\"
branches = !legit branches
sprout = !legit sprout \"$@\"
unpublish = !legit unpublish \"$@\"
/* lazyload.js (c) Lorenzo Giuliani
* MIT License (http://www.opensource.org/licenses/mit-license.html)
*
* expects a list of:
* `<img src="blank.gif" data-src="my_image.png" width="600" height="400" class="lazy">`
*/
!function(window){
var $q = function(q, res){
if (document.querySelectorAll) {
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
RangeInput
StringInput
TextInput
$('.jp-volume-bar').mousedown(function() {
var parentOffset = $(this).offset(),
width = $(this).width();
$(window).mousemove(function(e) {
var x = e.pageX - parentOffset.left,
volume = x/width
if (volume > 1) {
$("#JPID").jPlayer("volume", 1);
} else if (volume <= 0) {
$("#JPID").jPlayer("mute");
@lustremedia
lustremedia / PagesController.rb
Last active August 29, 2015 14:01
render/redirect_to with flash messages and validation errors in rails 4
class PagesController < ApplicationController
def contact
if request.post? #POST
logger.info("I am a POST")
@entrant=Entrant.new(entrant_params)
@event = Event.find(1)
=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')
// Handle previous/next navigation
$(function() {
// Requires jQuery 1.7+ to utilize the new "on" event attachment
$("#contentPadding").on("click", "a.prev, a.next", function (event) {
$.pjax({
"url": $(this).attr("href"),
"fragment": "#contentPadding",
"container": "#contentPadding",
"complete": function(data) {
// Update the className on the BODY tag
#!/usr/local/bin/perl
use strict;
use warnings;
my $pi = 3.1415;
my $focDist = 700; #e.g. 10000mm = 1m Focus Distance
my $cropFactor = 1.6;
my $focLen = 24*1.6; #e.g. 50mm
my $actualFocLen = $focLen * $cropFactor;
my $fstop = 2.8; # 1, 1.4 , 2 , 2.8, 4, 5.6
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby