Skip to content

Instantly share code, notes, and snippets.

View jackfranklin's full-sized avatar

Jack Franklin jackfranklin

View GitHub Profile
require "csv"
CSV.foreach("data.csv", :headers => true) do |row|
slug = row["slug"]
type = row["type"] == "markdown" ? "md" : row["type"]
created_at = Time.at(row["created_on"].to_i)
filename = "#{created_at.strftime("%Y-%m-%d")}-#{slug}.#{type}"
title = row["title"]
body = row["body"]
author = "Jack Franklin"
@jackfranklin
jackfranklin / template.js
Created May 8, 2013 09:15
Really simple template loaded with jQuery.
var Template = function(opts) {
this.name = opts.name;
};
Template.prototype.load = function(cb) {
var self = this;
cb = cb || function() {};
var req = $.ajax({
url: "/templates/" + this.name + ".handlebars"
});
var Basket = function() {
this.count = 5;
};
Basket.prototype.count = 1;
var x = new Basket();
console.log(x.count); // 1 or 5? (and why?)
// and
def is_playing?
if @player.status == :playing
true
else
false
end
end
# or:

So I've got three digital copies of my book, "Beginning jQuery", to give away!

Please note: this is aimed at folks who have written little-to-no JavaScript or jQuery. If that's not you, please don't try and win a copy! I'd like the copies to go to people who will really find them useful.

To win, you need to email me ( jack at jackfranklin dot net ) and answer these three questions, all of which are easily answered via Google.

  1. At which Bar Camp did John Resig reveal the first version of what would become jQuery?
  2. What is jQuery's tagline? (Hint: four words, prominent on the jQuery home page)
  3. Who is the executive director of the jQuery Project?
/***
*
* I want to execute someFunc() if the variable x is greater than 5
* how would you rewrite the below to NOT use a conditional? (EG no "if" used)
*
* **/
if(x > 5) {
someFunc():
}
// what are the key differences between:
var foo = function() {
alert("Hello World");
};
// and
function foo() {
alert("Hello World");
@jackfranklin
jackfranklin / gist:4511417
Last active December 10, 2015 23:39
Ruby operator precedence
a = "foo" && b = "bar"
a = ("foo" && b = "bar")
"bar"
# returns "bar"
a == "bar" # true
a = "foo" and b = "bar"
(a = "foo") and b = "bar"
"bar"
# returns "bar"
app.Modules.myModule = {
init: function(){
this.bindEvents();
},
bindEvents: function(){
var self = this;
app.Events.on('user:added', self.userAdded());
this.username = $('#username');
},
x = "hello"
x.upcase!
x # "HELLO"