This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery -> | |
# rotate items | |
rotator_builder = (selector, args) -> | |
trans_in = args.trans_in || "fadeIn" | |
trans_out = args.trans_out || "fadeOut" | |
trans_in_dur = args.trans_in_dur || 1000 | |
trans_out_dur = args.trans_out_dur || 400 | |
show_dur = args.show_dur || 7000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
jQuery(function() { | |
var looper, rotator_builder; | |
rotator_builder = function(selector, args) { | |
var $items, cur, loop_fn, num_items, prev, show_dur, trans_in, trans_in_dur, trans_out, trans_out_dur; | |
trans_in = args.trans_in || "fadeIn"; | |
trans_out = args.trans_out || "fadeOut"; | |
trans_in_dur = args.trans_in_dur || 1000; | |
trans_out_dur = args.trans_out_dur || 400; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while read line | |
do | |
echo $line | |
wget $line > /dev/null 2>&1 | |
done < $1 | |
# USAGE: wgets.sh a.txt | |
# Where a.txt is a list of URLs | |
# Pretttty simple. TODO: accept redirected input as well |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery -> | |
window.youtube_iframe = (video_id, args) -> | |
default_options = { | |
width: 853 | |
height: 480 | |
autoplay: 0 | |
rel: 0 | |
class: "youtube-video" | |
frameborder: "0" | |
allowfullscreen: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
to_slug = (str) -> | |
str = str.replace(/^\s+|\s+$/g, "").toLowerCase() # trim and force lowercase | |
from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;" | |
to = "aaaaeeeeiiiioooouuuunc------" | |
for i in [i..from.length] | |
str = str.replace(new RegExp(from.charAt(i), "g"), to.charAt(i)) | |
# remove accents, swap ñ for n, etc | |
str = str.replace(/[^a-z0-9 -]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-") | |
# remove invalid chars, collapse whitespace and replace by -, collapse dashes | |
return str # unnecessary line, but for clarity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Image < ActiveRecord::Base | |
attr_accessible :f | |
mount_uploader :f, ImageUploader | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grr(){ | |
grep -iRn "$*" --include=*.{rb,erb,haml,html,css,scss,sass,json,js,coffee} . | |
} | |
# Put this in your .bashrc or equivalent | |
# then use like this: | |
# $ grr stuff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Just some examples of how to do file validation with javascript | |
# IS NOT BULLETPROOF and should be coupled with server side validation | |
# But, it can help | |
validate_file = -> | |
file = @fileInput.files[0] | |
if "name" of file | |
name = file.name | |
else | |
name = file.fileName | |
if "size" of file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# At CoverHound, we use conditional validations all over the form. However, there is no proper way to do | |
# this in Rails. Instead, we can provide an array of attributes (validated_fields attribute) | |
# and ensure they are the only ones to get validated. | |
# | |
module ConditionalValidations | |
attr_accessor :validated_fields | |
def field_is_required?(field) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sublime Text 3 languages list: | |
ls -1 /Applications/Sublime\ Text.app/Contents/MacOS/Packages/ | |
# Remove all default Sublime Text 3 snippets for Python language | |
export ST3_LANG="Python" | |
mkdir -p ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/$ST3_LANG/ | |
unzip -l /Applications/Sublime\ Text.app/Contents/MacOS/Packages/$ST3_LANG.sublime-package | grep '.sublime-snippet' | awk '{print $4}' | while read f; do touch ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/$ST3_LANG/$f; done | |
unset ST3_LANG |
OlderNewer