Skip to content

Instantly share code, notes, and snippets.

View jackfranklin's full-sized avatar

Jack Franklin jackfranklin

View GitHub Profile
var array = [1,2,3,4];
array = array.map(function(x) {
return x*x;
})
console.log("regular array", array); // [1,4,9,16]
function foo() {
array = arguments.map(function(x) {
@jackfranklin
jackfranklin / freelance-rates-2012.csv
Created December 6, 2012 15:10 — forked from cole007/freelance-rates-2012.csv
Freelance Rates 2012 data under Creative Commons license (http://creativecommons.org/licenses/by/2.0/uk/)
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 4.
Released under Creative Commons license (http://creativecommons.org/licenses/by/2.0/uk/)
Timestamp,Where are you based in the UK?,How would you describe what you do,Is your primary skill set ,How old are you?,How many years have you been a web professional?,What is your day (not hourly) rate?,Average,How many years have you been freelance?,How do you charge clients?,Do you normally require a deposit before starting work on a project?,Do you normally use a contract?,Do you primarily work …,What is the average value of projects you work on?,What is your gender?
7/26/2012 8:59:32,South East,Front-end Designer / Developer,Mixture of all three,15-19,0-1,240,240,2-3,By the hour,10-25% of project value,Yes,"directly with clients, in partnership with other freelancers, subcontracting for agencies",£1001-2000,Male
5/18/2012 10:04:17,East Midlands,"Graphic Design, Front End Developer",Design ,25-29,6-7,220,220,2-3,By the hour,10-25% of project value,Yes,"directly with clients, in partnership with other freelancers, su
@jackfranklin
jackfranklin / gist:4205352
Created December 4, 2012 15:47
Xcake Aug 2012 Talk

JavaScript & Mobile

About

  • developer at Kainos, on placement year from University
  • @Jack_Franklin
  • javascriptplayground.com

Developing for Mobile

@jackfranklin
jackfranklin / gist:4194664
Created December 3, 2012 12:18
Checking for NaN in JS
var x = parseFloat("notanumber");
x // NaN
x === NaN // false
isNaN(x) // true
// isNaN seems like it works, but doesn't actually because of type coercion:
@jackfranklin
jackfranklin / hang.js
Created November 30, 2012 14:44 — forked from remy/hang.js
How to hang JavaScript (useful - to me - for slowing down code and testing)
function hang(n) {
var x = new XMLHttpRequest();
x.open('GET', 'http://hang.nodester.com/script.js?' + n, false);
x.send();
}
// usage: hang(2 * 1000);
@jackfranklin
jackfranklin / pr.md
Created November 27, 2012 11:47 — forked from piscisaureus/pr.md
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 = git@github.com: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:

@jackfranklin
jackfranklin / gist:4145446
Created November 25, 2012 21:26
call() and apply() in JS
/***
* Call and Apply in JavaScript
***/
var me = {
firstName: "Jack",
lastName: "Franklin",
fullName: function(title, middleName) {
return title + ". " + this.firstName + " " + middleName + " " + this.lastName;
}
@jackfranklin
jackfranklin / gist:4124906
Created November 21, 2012 13:45
What to look for when choosing a JS Plugin / Widget / etc

Is it on Github?

Maybe this is incredibly unfair of me, but I immediately discount any plugins that only let you download via a zip. There's no excuse for it not to be on Github, completely in the open.

Is it active?

If the last commit in the repository was more than 6 months or so ago, there's a decent change it's out of date, but I still might take a quick look. Any repository not updated in 12 months is immediately discarded.

Does it have tests (and are they well written)?

Once again, no real excuse not to test code with JS these days. There's a plethora of libraries and resources available. Tests let me know with confidence that this plugin does do what it says it does. No tests = discarded, with the slight exception of some plugins or polyfills. For example, this Full Screen polyfil by Sindre is an example of a library without tests, that I'd be happy to use.

@jackfranklin
jackfranklin / gist:3787094
Created September 26, 2012 09:53
Ruby object filtering in arrays
my_data = [
{
:foo => 1
#etc
},
{
:foo => 2
#etc
},
{
Tas::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true