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( $ ){ | |
/* | |
A cleaner approach to jquery plugins. Separate the code for the plugin's functionality from | |
the assignment into the jQuery namespace. | |
Taken from various articles/presos by Alex Sexton and Paul Irish, and #jquery IRC chats. | |
With enthusiasm for Object.create() toned down after http://news.ycombinator.com/item?id=2594521 | |
*/ |
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
var loadScript = function(url,callback,async){ | |
if(!url){ return false; } | |
var script = document.createElement('script'), | |
head = document.getElementsByTagName('head')[0]; | |
script.src = url; | |
script.async = async ? true : false; | |
/* bind a callback for all browsers */ |
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
;; from https://gist.github.com/2250340 | |
(defun frame-bufs-switch-buffer () | |
"Switch buffer, within buffers associated with current frame (`frame-bufs-buffer-list')" | |
(interactive) | |
(if (and (fboundp 'frame-bufs-mode) | |
frame-bufs-mode) | |
(let* ( (buffers (mapcar 'buffer-name (frame-bufs-buffer-list (selected-frame)))) | |
(buffers-rotated (append (cdr buffers) (cons (car buffers) nil))) | |
(target (ido-completing-read "Buffer: " buffers-rotated)) ) | |
(switch-to-buffer target)) |
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 () { | |
if (!(window.postMessage && window.localStorage && window.JSON)) return; | |
var a = { | |
setItems: function (event, i) { | |
if (!g({ | |
write: 1 | |
}, event.origin)) return false; | |
var j = i.length, | |
k = []; | |
for (var l = 0; l < j; l++) { |
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
# first, fetch the latest refs for all branches. And be sure we have latest master, etc | |
git checkout master | |
git fetch | |
# If any changes from remote, catch our local version up | |
git rebase origin/master | |
# could also be done as |
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
##### Gemfile | |
gem 'sinatra-activerecord' | |
... | |
group :development, :test do | |
gem 'sqlite3' | |
# gem 'mysql2', '0.3.11' | |
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
function Foo(el, options){ | |
if(!el) throw new Error("'el' is a required param"); | |
this.$el = el.jquery ? el : $(el); | |
this.options = options || {}; | |
} | |
Foo.prototype = { | |
messageStart: "Phuket, ", | |
getContent: function(){ |
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
// js scoping primer | |
// util | |
var _log = function(){ | |
var slice = [].slice, | |
args = slice.call(arguments), | |
len = args.length, | |
i = 0; | |
for(;i<len;i++) console.log(args[i]) | |
}; |
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
/* ######################### | |
2 - SCOPE - CLOSURES | |
hide from global by using a closure | |
*/ | |
(function(n){ // param | |
var myURL = 'google.com'; | |
_log( n === 4 ) // 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
/* ######################### | |
3 - SCOPE - Define a function in a closure, return an object that has access to that function. | |
*/ | |
(function(){ | |
// accessible via the object we return | |
var o = (function(){ | |
// local | |
function _f(){ _log( 'danneh' ); } |
OlderNewer