Skip to content

Instantly share code, notes, and snippets.

View jeroenransijn's full-sized avatar
:atom:

Jeroen Ransijn jeroenransijn

:atom:
  • San Francisco
View GitHub Profile
@neptunius
neptunius / recursion.py
Last active March 31, 2016 00:44
Comparison of iterative and recursive functions
import unittest
def factorial(n):
"""factorial(n) returns the product of the integers 1 through n for n >= 0,
otherwise raises ValueError for n < 0 or non-integer n"""
# implement factorial_iterative and factorial_recursive below, then
# change this to call your implementation to verify it passes all tests
# return factorial_iterative(n)
return factorial_recursive(n)
@Ben-G
Ben-G / CoreDataStack.swift
Last active August 29, 2016 08:49
CoreDataStack Swift
//
// CoreDataStackInMemory.swift
// TripPlanner
//
// Created by Benjamin Encz on 7/20/15.
// Copyright © 2015 Make School. All rights reserved.
//
// Structure is inspired by: http://martiancraft.com/blog/2015/03/core-data-stack/, Thanks!
@salmanwahed
salmanwahed / api.py
Created May 1, 2015 15:23
REST Api with Flask-Restful and MongoDB
# -*- coding: utf-8 -*-
from flask import Flask, jsonify, url_for, redirect, request
from flask_pymongo import PyMongo
from flask_restful import Api, Resource
app = Flask(__name__)
app.config["MONGO_DBNAME"] = "students_db"
mongo = PyMongo(app, config_prefix='MONGO')
APP_URL = "http://127.0.0.1:5000"
@PatrickJS
PatrickJS / factory-shared.es5.js
Last active May 17, 2024 03:37
Different examples of OOP "class" with "inheritance" done using JavaScript including languages that transpile into js. Take notice to the amount of boilerplate that's needed in ES5 compared to ES6. These examples all have the same interface with pros/cons for each pattern. If they seem similar that's whole point especially the difference between…
var EventEmitter = require('events').EventEmitter;
var _ = require('lodash');
// Factory shared
var makePerson = function() {
var person = {};
EventEmitter.call(person);
person.wallet = 0;
_.extend(person, personMethods)
return person;
@tagr
tagr / server.js
Created September 28, 2014 20:22
Node.js/Express: Add Expires header to /images and /stylesheets directories
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = require('http')
, path = require('path');
@tfrank64
tfrank64 / AppDelegate.swift
Created June 8, 2014 17:32
Swift UITabBar Programmatically
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
// Override point for customization after application launch.
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
var nav1 = UINavigationController()
var first = FirstViewController(nibName: nil, bundle: nil)
nav1.viewControllers = [first]
var second = SecondViewController(nibName: nil, bundle: nil)
var nav2 = UINavigationController()
@jquave
jquave / SwiftTable
Created June 2, 2014 20:58
Example code for Table View in Swift
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
@TurplePurtle
TurplePurtle / sourceFromFile.js
Created October 27, 2012 21:36
Load sound from local file for Web Audio API
// Audio Buffer Source
var fileInput = $("#audio-file");
bufferSource.gain.value = 1;
bufferSource.loop = true;
bufferSource.connect(oscillatorGain);
fileInput.addEventListener("change", function() {
var reader = new FileReader();
reader.onload = function(ev) {
context.decodeAudioData(ev.target.result, function(buffer) {
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/