Skip to content

Instantly share code, notes, and snippets.

Oliver Switzer oliverswitzer

Block or report user

Report or block oliverswitzer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:7c1387e28e3a2791330fbf52fd109b16
# Intro
Writing changeable code: three different skills
- 1. understand OO design. Code that is easy to change IS well designed.
- 2. skilled at refactoring. Quote from Fowler
--> also maybe insert quote from Kent Beck:
"make the change easy (warning: this may be hard), then make the easy change"
- refactoring is how you morph code to accommodate new requirements. Prefactor vs refactor?
- 3. High value tests!
- Good tests don't need to be changed when you refactor.
@oliverswitzer
oliverswitzer / includes_module.rb
Last active Aug 29, 2015
A simple gist demonstrating how Ruby looks up module methods when they've been included in a class
View includes_module.rb
module Engine
def run
puts "GRRRRRRRRR"
end
end
class Vehicle
@oliverswitzer
oliverswitzer / mixpanel_api.js
Created Mar 27, 2014
A node script to get data from mixpanel API and output it to a CSV
View mixpanel_api.js
// mixpanel_export.js
// node modules
http = require('http');
Mixpanel = require('mixpanel');
md5 = require('MD5');
jsoncsv = require('jsoncsv');
fs = require('fs');
stringify = require('csv-stringify');
@oliverswitzer
oliverswitzer / example-data.json
Created Mar 27, 2014
The crappy JSON I got back from Mixpanel's API
View example-data.json
{"event":"first visit","properties":{"time":1389806707,"distinct_id":"14398a6d7eb77-0308ffb76-6e1a2776-384000-14398a6d7ec2b4","$browser":"Chrome","$city":"New York","$initial_referrer":"$direct","$initial_referring_domain":"$direct","$os":"Mac OS X","$region":"New York","date":{},"mp_country_code":"US","mp_lib":"web","url":"http://devolate.com/"}}
{"event":"first visit","properties":{"time":1389806825,"distinct_id":"14398a8a47aa-094bd1e04-6e1a2776-384000-14398a8a47b421","$browser":"Chrome","$city":"New York","$initial_referrer":"$direct","$initial_referring_domain":"$direct","$os":"Mac OS X","$region":"New York","date":{},"mp_country_code":"US","mp_lib":"web","url":"http://devolate.com/"}}
@oliverswitzer
oliverswitzer / barchart_update.rb
Created Mar 5, 2014
Updated working (sort of) barchart for BetaNYC Timeline Group!
View barchart_update.rb
<html>
<head>
<style>
.bar {
fill: steelblue;
}
.axis text {
font: 10px sans-serif;
@oliverswitzer
oliverswitzer / callingANodeModule.js
Created Feb 24, 2014
Example of calling my own custom module in Node
View callingANodeModule.js
var dirListModule = require('./dirListModule.js')
var dirPath = process.argv[2];
var extFilter = process.argv[3];
dirListModule(dirPath, extFilter, function(err, filteredList) {
filteredList.forEach(function(value) {
console.log(value);
});
});
@oliverswitzer
oliverswitzer / nonModuleDirList.js
Created Feb 24, 2014
An example of a script that will filter files with certain extensions in Node.js
View nonModuleDirList.js
// asynchDirList.js
var fs = require('fs'); //require node filesystem module
var path = require('path'); //require node path module (a couple of tools for reading path names)
var pathSupplied = process.argv[2];
var extFilter = process.argv[3];
function extension(element) {
var extName = path.extname(element);
@oliverswitzer
oliverswitzer / module.js
Created Feb 24, 2014
Node.js Module Example!
View module.js
// dirListModule.js
var fs = require('fs'); //require node filesystem module
var path = require('path'); //require node path module (a couple of tools for reading path names)
module.exports = function filterDirFiles(pathSupplied, extFilter, callback) {
function extension(element) {
var extName = path.extname(element);
return extName === '.' + extFilter;
};
View jQuery.js
$('div').on("click", function() {
console.log("I'm a callback function and I'm currently getting called!");
});
@oliverswitzer
oliverswitzer / module.rb
Created Feb 24, 2014
An example of a module!
View module.rb
module MyModule
def first_module_method
end
end
You can’t perform that action at this time.