Skip to content

Instantly share code, notes, and snippets.

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Vector;
@mikelikesbikes
mikelikesbikes / gist:1007228
Created June 3, 2011 21:43
Fibonacci with Inject!
def fib(n)
(0..n).inject([1,0]) { |(a,b), _| [b, a+b] }[0]
end
@mikelikesbikes
mikelikesbikes / update_attribute_callbacks_broken.rb
Last active January 24, 2017 00:26
Demonstrates a bug in ActiveRecord 5.0 where callbacks are not invoked as part of calling `update_attribute`
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "rails", github: "rails/rails"
@mikelikesbikes
mikelikesbikes / dynamic.clj
Created October 17, 2012 18:32 — forked from bjeanes/dynamic.clj
Change Maker in clojure
(ns katas.change-maker)
(defn num-pairs
"Returns all combinations of [x y] and (<= x y) where (= cents (+ x y))"
[cents]
(for [x (reverse (range 1 (inc (quot cents 2)))) ;; use the range from midpoint to 1 so that we walk the
;; shortest side of the tree first
:let [y (- cents x)]]
[x y]))
var babby = {
response: "wahhhh",
hello: function() {
console.log(this.response)
}
}
babby.hello();
babby.hello.call({response: "I'm Stewie Griffin. Hello. </britishaccent>"})
@mikelikesbikes
mikelikesbikes / gist:8290978
Created January 6, 2014 22:28
Programming Learning Resources
http://projectmona.com/bits-of-brilliance-session-five/
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="./zoo.js"></script>
</head>
<body>
</body>
</html>
@mikelikesbikes
mikelikesbikes / index.html
Last active December 27, 2015 18:59 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
@mikelikesbikes
mikelikesbikes / gist:6585607
Created September 16, 2013 19:47
Unicornify Create a bookmark, make the following the URL.
javascript:(function(){var d=document,j=d.getElementById('__cornify_nodes'),k=null;var file='https://gist.github.com/mikelikesbikes/4766d1815476568f4212/raw/990e81435eba381592b3396db38b5b068b444117/gistfile1.txt';if(j){cornify_add();}else{k=d.createElement('div');k.id='__cornify_nodes';d.getElementsByTagName('body')[0].appendChild(k);j=d.createElement('script');k.appendChild(j);j.onload=function(){console.log("woo");cornify_add();};j.src=file;}})();