Skip to content

Instantly share code, notes, and snippets.

@dsimard
dsimard / index.html
Created February 10, 2012 16:10
Modular javascript
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="module_a.js"></script>
<script src="module_b.js"></script>
<script src="xtending_modules.js"></script>
<meta charset=utf-8 />
<title>Modular js</title>
<!--[if IE]>
@dsimard
dsimard / modular.js
Created February 10, 2012 16:08
Question from Dragos
var a = function() {
//code here
}();
var b = function() {
// code here
return {
//code here
}
@dsimard
dsimard / heroku_node.js
Created December 22, 2011 18:59
Node.js on Heroku : "Process bound to port 3000, should be 12345"
var port = process.env.PORT || 3000;
app.listen(port);
@dsimard
dsimard / ubuntu11.10_snapopen.sh
Created October 19, 2011 17:48
Install SnapOpen on Ubuntu 11.10 (Oneiric Ocelot)
# Go to your your plugin directory (create it if it doesn't exist)
cd ~/.local/share/gedit/plugins
# Clone the git repository with the patch
git clone git://github.com/MadsBuus/gedit-snapopen-plugin.git
# Create the links
ln -s gedit-snapopen-plugin/snapopen.plugin .
ln -s gedit-snapopen-plugin/snapopen .
@dsimard
dsimard / heroku_change_stack.sh
Created October 5, 2011 18:01
Update Heroku stack and change repository URL
# Create a new stack
heroku create --stack cedar
# it will reply something like this
# Creating stark-moon-1526... done, stack is cedar
# http://stark-moon-1526.herokuapp.com/ | git@heroku.com:stark-moon-1526.git
# Change repository URL
git remote set-url heroku git@heroku.com:stark-moon-1526.git
@dsimard
dsimard / README
Created September 22, 2011 14:30
Find in all files
# Clone this gist
git clone git://gist.github.com/1234911.git ~/your/path/to/faf
# Change rights
chmod 755 ~/your/path/to/faf/fah.sh
# Add this line to your ~\.bashrc
alias faf='~/your/path/to/faf.sh'
# Close your terminal and open a new one
@dsimard
dsimard / fiddle.html
Created September 13, 2011 13:25
Redefine undefined outside the scope
<p>First, undefined is defined to <em id="step1"></em></p>
<p>Then, undefined is redefined to <em id="step2"></em></p>
@dsimard
dsimard / fiddle.html
Created September 11, 2011 17:43
Redefined undefined with a self-invoking function
<p>First, undefined is defined to <em id="step1"></em></p>
<p>Then, undefined is redefined to <em id="step2"></em></p>
@dsimard
dsimard / shortns.js
Created September 5, 2011 14:08
Short form namespaces
var Animal = {
Dog : {/* Lots of stuff here */},
Cat : (function() {
var c = {
list : ["Mistigri", "Felix"],
show : function() {
/* Using the 'c' alias is much shorter */
console.log(c.list.join());
}
}
@dsimard
dsimard / longns.js
Created September 5, 2011 14:07
Long form namespaces
var Animal = {
Dog : {/* lots of stuff here */},
Cat : {
list : ["Mistigri", "Felix"],
show : function() {
/* This is where it gets long */
console.log(Animal.Cat.list.join());
}
}
};