Skip to content

Instantly share code, notes, and snippets.

View Integralist's full-sized avatar
🎯
Making an impact

Mark McDonnell Integralist

🎯
Making an impact
View GitHub Profile
// Why you don't need arguments.callee:
var factorial = function callee(n) {
if (n === 0) {
return 1;
}
return n * callee(n - 1);
};
// In a standard compliant ES3 or ES5 implementation:
@Integralist
Integralist / Description.md
Created April 15, 2012 09:23
Relative Sizing

If you set the <body> element to have font-size: 100% then you are effectively setting the pixel size base line to be 16px.

So now 1em equals 16px.

To size either our text or our layouts to match what the designer has specified in pixels we use the following calculation:

target / context = result

This means if your target font size for a <h1> is 24px and your 'context' (the container) is 16px then you calculate this as:

@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@Integralist
Integralist / placeholder.js
Created April 27, 2012 15:44
HTML5 Placeholder Polyfill
var doc = document,
body = doc.body,
inputs = doc.getElementsByTagName("input"),
txtarea = doc.getElementsByTagName("textarea"),
combined = [],
len,
placeholder,
lastInputSelected;
/**
@Integralist
Integralist / ordered.md
Created May 15, 2012 10:31
Ordered Lists
ol {
	counter-reset: section;
	list-style-type: none;
}

ol li:before {
	counter-increment: section;
	content: counters(section, ".") " ";
}
@Integralist
Integralist / 1. sinatra-basic-with-comments.rb
Last active November 9, 2019 20:10
Create basic site using Ruby and Sinatra (and external templates)
#!/usr/bin/env ruby
=begin
install Sinatra: gem install sinatra
install Shotgun: gem install shotgun (this auto-reloads sinatra on every http request - which means every time you make a change in your code you don't have to stop then start sinatra)
To just run your code using Sinatra: ruby name-of-file.rb
To run your code using Shotgun (which is just Sinatra but with ability to auto-reload when changes are made to files): shotgun name-of-file.rb
The following examples are run using Shotgun and the URL is: http://127.0.0.1:9393/
@Integralist
Integralist / pass.js
Created July 27, 2012 08:02
JavaScript pass by value/reference example
var my_num = 123;
var my_str = 'abc';
var my_obj = { name: 'mark' };
var my_arr = ['a', 'b', 'c'];
var my_bool = true;
var new_num = my_num;
var new_str = my_str;
var new_obj = my_obj;
var new_arr = my_arr;
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@sdepold
sdepold / LICENSE.txt
Created August 15, 2012 05:50 — forked from 140bytes/LICENSE.txt
140byt.es -- addObserverMethods
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Sascha Depold http://depold.com
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@gfranko
gfranko / app.build.js
Last active October 12, 2015 14:58
Backbone-Require-Boilerplate (BRB) Mobile and Desktop Build Configuration with almond.js
// Node.js - Require.js Build Script
// To run the build type the following: node app.build.js
// Loads the Require.js Optimizer
var requirejs = require('../public/js/libs/r.js');
// Sets up the basic configuration
var baseConfig = {