This file contains hidden or 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
// a simple custom wrapper | |
var Widget = new Class(Element, { | |
initialize: function(raw_element) { | |
// calling the Element's constructor | |
this.$super(raw_element, { | |
'class': 'my-widget' | |
}); | |
}, | |
// some other custom methods |
This file contains hidden or 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 is_IE8_or_less() { | |
try { | |
document.createElement('<input/>'); | |
// IE8 or less | |
return true; | |
} catch(e) { | |
// IE9 or a W3C browser | |
return false; | |
} | |
} |
This file contains hidden or 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
sudo -s | |
gem install rubygems-update -v 1.3.7 | |
gem uninstall rubygems-update -v 1.5.0 | |
update_rubygems |
This file contains hidden or 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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> | |
<html lang="en"> | |
<head> | |
<title>Draggable Issue</title> | |
<script type="text/javascript" src="http://cdn.rightjs.org/right.js"></script> | |
<script type="text/javascript" src="http://cdn.rightjs.org/plugins/dnd.js"></script> | |
</head> | |
<body> | |
<div style="margin: 10px auto;max-width:1180px;position:relative;height:710px;clear:both;overflow:scroll;background-color:grey"> | |
<div rel="draggable" style="position: absolute; right: 0; background-color: green; width: 100px; height: 100px"></div> |
This file contains hidden or 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
// hacking jasmine over | |
var jasmine = require('jasmine-node'); | |
var original_it = it; | |
var original_expect = expect; | |
var original_describe = describe; | |
global.it = function(desc, callback) { | |
if (typeof(desc) !== 'string') { | |
for (var key in desc) { |
This file contains hidden or 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
/** | |
* Cubic Bezier CSS3 transitions emulator | |
* | |
* See this post for more details | |
* http://st-on-it.blogspot.com/2011/05/calculating-cubic-bezier-function.html | |
* | |
* Copyright (C) 2011 Nikolay Nemshilov | |
*/ | |
function Bezier(p1,p2,p3,p4) { | |
// defining the bezier functions in the polynomial form |
This file contains hidden or 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
# | |
# Recursively converts an object into a query string | |
# | |
to_query_string = (data)-> | |
map = (hash, prefix='')-> | |
result = [] | |
for key, value of hash | |
key = if prefix is '' then key else "#{prefix}[#{key}]" |
This file contains hidden or 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
# | |
# RJS handler was kicked out of Rails 3.1 along with Prototype | |
# so, here is a little substitute coz we use it here and there | |
# | |
# Just save it in some file in the `config/initializers` | |
# | |
module ActionView | |
module Template::Handlers | |
class RJS | |
# Default format used by RJS. |
This file contains hidden or 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
# | |
# Making BCrypt to use minimal cost so that the specs run faster | |
# | |
# place this in the spec/support/bcrypt.rb file | |
# | |
require 'bcrypt' | |
module BCrypt | |
class Engine | |
class << self |
This file contains hidden or 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
# | |
# Save this in `lib/mongoid/counter_cache.rb` | |
# | |
# Then define your relations kinda like that | |
# | |
# class Comment | |
# belongs_to :post, counter_cache: true # 'comments_count' | |
# belongs_to :user, counter_cache: 'my_field_name' | |
# end | |
# |