Skip to content

Instantly share code, notes, and snippets.

View dtothefp's full-sized avatar

David Fox-Powell dtothefp

  • Flexport
  • United States
View GitHub Profile
// Loop Version
function loopFib(n){
var first = 0;
var second = 1;
var sum;
for(var i = 2; i <= n; i++){
sum = first + second;
first = second;
second = sum;
}
class FibSequence
def initialize
@first = 0
@second = 1
end
def find_fib(n)
i = 2
print @first.to_s + " "
print @second.to_s + " "
@dtothefp
dtothefp / A-Pen-by-David-Fox-Powell.markdown
Created January 17, 2014 05:18
A Pen by David Fox-Powell.
@dtothefp
dtothefp / directive-draggable
Created February 20, 2014 22:51
Vanilla JS Draggable Directive
module = angular.module 'draggable', []
module.controller "dragDropCtrl", ($scope) ->
$scope.dropPosition = null
module.directive 'pixbiDraggable', ($timeout) ->
restrict: 'A'
controller: 'dragDropCtrl'
scope: {
dropPosition: "="
@dtothefp
dtothefp / gist:9202480
Last active August 29, 2015 13:56
Mario Pyramid
puts "Enter the pyramid height"
input = gets.chomp.to_i
while input < 1 || input > 69
puts "Please enter a number between 1 and 69"
input = gets.chomp.to_i
end
puts "Your input is #{input}"
@dtothefp
dtothefp / class_cons.rb
Created April 3, 2014 12:39
Classes & Prototypes
class Car
def initialize(name)
@name = name
end
def name
@name
end
@dtothefp
dtothefp / angular_grunt.js
Created April 3, 2014 18:26
angular production grunt
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
files: {
desktopSrc: ['public/js/config/*.js', 'public/js/factories/*.js', 'public/js/controllers/*.js', 'public/js/directives/*.js'],
mobileSrc: ['public_mobile/js/config/*.js', 'public_mobile/js/factories/*.js', 'public_mobile/js/controllers/*.js', 'public_mobile/js/directives/*.js'],
desktopImg: ['public/images/{,**/}*.{jpg,png,gif}', 'public/video/**/{,**/}*.{jpg,png,gif}'],
@dtothefp
dtothefp / lex_v_dyanamic
Last active August 29, 2015 14:00
Lexical vs. Dynamic Scope
// Lexical
(function(){
function addIt(){
var x = 100;
function addInside(){
return x += 5;
}
@dtothefp
dtothefp / JS Singleton
Last active August 29, 2015 14:01
private methods and vars
//http://www.crockford.com/javascript/little.html
var singleton = (function(){
var privateHello = "hello";
function privateFunction(something){
privateHello = privateHello + " " + something;
}
return {
changeSomething: function(a){
privateFunction(a);
@dtothefp
dtothefp / angular_anim
Created May 25, 2014 17:30
Angular Animation
.sharer-message-container {
// finished state when visible
position: absolute;
top: 0%;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.9);
z-index: 100;
padding: 20px 10px;