Skip to content

Instantly share code, notes, and snippets.

View jescalan's full-sized avatar

Jeff Escalante jescalan

View GitHub Profile
@zspecza
zspecza / modernizr.styl
Last active August 29, 2015 14:02
modernizr helper mixins for stylus
/* private modernizr mixin
*
* downside - only works on single-element selectors. nesting still works though.
*
* @param features - a list of modernizr test classes e.g.: csstransitions opacity OR csstransitions, opacity
* @param declaration - the {block} of content passed by the block mixins +yep()/+nope()
* @param support - boolean, true if testing support, false if testing no support
*
* 1. if testing for support, set selector to empty string
* if testing for no support, set selector to ".no-js" appended by
@tmilewski
tmilewski / jquery.textcounter.js.coffee
Created January 16, 2012 19:43
Manages character counts for a textarea
# Usage
$("textarea").counter
elements:
counter: '.note-area p.counter'
# Manages Character Counts
jQuery.fn.counter = (opts) ->
defaults =
elements:
counter: '.counter'
@robertjwhitney
robertjwhitney / digits.rb
Created January 25, 2012 04:05
get de digits
#http://thehackerolympics.com/
key = 'qwertyuiop'
string = 'iirytroyppytpeppowuiyoiuypipiyuyotyoiwiytorouqyiepyirueuiprpptwyiroqwtuyipourrrourorwipowiorutpwtwruuioquteorioriyutwqyyprptuqqquuituyywyuoewtrppqwrtiiruirpwyptpuoyyoeyerpqiotuieripurouwuwyuwrworowitoepoypeipeypiireeorrwripuuteoitpuutturruwiyryeetyrioweytueqrrrtotrpiqetoyepoipiwrwpppiritupwipruooiepoweypiuwrqywuuwyiroqpqpruioopuiuerputpwwuuiqwpiroewrtwiqerteoyeqtutwoeoipioiuqiiiouuoqtuuwtuwiiqwppqitywuqpuutrqiyoeuuutwrwtoqrqyoeyoiporuuioiwryoeruypreprqroiyuqwtuyoytoerwqryeeripryieypiwqirtriurueypiuyuypriuiwptywppupoioyrewooytreteeriiwroietuwypieeeeeqpiiiwrirtppoeyiwpooyyporpruwuoriiyowuytiwpwpryeywotoyirqypyypoeptiuwwoyprquoetepptorwiewprpiywwtuieeiweytrrwiqtwotioryoiptyyyuriiqiyroeeiqepwteuwptpruuypipieuoiiuuweeuryuuowporrooyywyyrryriqyirooitirueruptotpryoqtipippyptiurwyiryooywtryyuurtrutwqiqiiiqwouyeooueoturuowiuwrtruwwiupwopwweoo'
#split into unique pairs
array = string.scan(/../)
unique_pairs = array.keep_if {|letters| array.count(letters) == 1}
@johnkpaul
johnkpaul / getComputedStylePropertyValue.js
Created February 10, 2012 16:42
Shim for getComputedStyle in old IEs
(function(window, undefined){
window.getComputedStylePropertyValue = function(el,cssProperty){
if(!window.getComputedStyle){
if(document.defaultView && document.defaultView.getComputedStyle){
return document.defaultView.getComputedStyle.getPropertyValue(cssProperty);
}
else{
var camelCasedCssProperty = getCamelCasedCssProperty(cssProperty);
if(el.currentStyle){
return el.currentStyle(camelCasedCssProperty);
@robertjwhitney
robertjwhitney / loadHtml.coffee
Created March 15, 2012 19:47
well that was silly
loadHtml = (elem, url) ->
$.ajax
url: url
context: document.body
dataType: "html"
success: (data) ->
elem.html data
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
@samccone
samccone / gist:2919791
Created June 12, 2012 20:02
JS Style
// CONDITIONALS
if (foo && bar) {
}
if () {
} else {
}
@cyberwombat
cyberwombat / CORS Configuration
Created November 1, 2012 19:18
JQuery file upload plugin (blueimp) with NodeJs Express3 directly to Amazon S3 with public access
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
@maccman
maccman / canvas.physics.coffee
Created April 11, 2013 02:52
A canvas physics engine in 160 lines of CoffeeScript.
class Point
constructor: (@x = 0, @y = 0) ->
if isNaN(@x) or isNaN(@y)
throw new Error('Invalid coords')
add: (point) ->
@x += point.x
@y += point.y
subtract: (point) ->
git_packages:
pkg.installed:
- names:
- libssl-dev
- git
- pkg-config
- build-essential
- curl
- gcc
- g++