Skip to content

Instantly share code, notes, and snippets.

View Radagaisus's full-sized avatar

Almog Melamed Radagaisus

View GitHub Profile
-- Fibonacci Sequence Abstraction
fib :: Integer -> Integer
fib 0 = 1
fib 1 = 1
fib x = fib (x - 1) + fib (x - 2)
-- Another Fibonacci Sequence Abstraction
fibTuple:: (Integer, Integer, Integer) -> (Integer, Integer, Integer)
fibTuple (x, y, 0) = (x, y, 0)
fibTuple (x, y, index) = fibTuple(y, x + y, index - 1)
@Radagaisus
Radagaisus / prettydate.js
Created September 1, 2011 01:54
Pretty Date
/*
**prettyDate** is based on [John Resig's work][1].
[1]: http://ejohn.org/blog/javascript-pretty-date/ "prettyDate"
*/
/* PrettyDate - http://ejohn.org/blog/javascript-pretty-date/
------------------------------------------------------------------/
/*
* JavaScript Pretty Date
* Copyright (c) 2008 John Resig (jquery.com)
@Radagaisus
Radagaisus / twitterify.js
Created September 1, 2011 02:20
add links to urls, users and hashtags for text from Twitter
function twitterify(text) {
return text
// URLS
.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig,
"<a href='$1'>$1</a>")
// Hashtags
.replace(/\B#([^ ]+)\b/ig,
"<a href='http://twitter.com/#!/search?q=%23$1'>#$1</a>")
@Radagaisus
Radagaisus / animatenums.js
Created September 5, 2011 11:36
Animate Numbers jQuery Plugin
// usage: $(".something").animateNums(300);
(function($) {
$.fn.animateNums = function(options) {
return this.each(function() {
e = $(this);
var max = e.text();
e.text("0");
animateNums();
function animateNums() {
@Radagaisus
Radagaisus / fixed_position_fix.js
Created September 6, 2011 00:37
Mobile fix for position fixed
// iPad fix for position fixed
$(window).scroll(function() {
if (navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod') {
$("footer").css({
position: 'absolute'
top: ($(document).scrollTop() + $(window).height() - $("footer").height()) + "px"
});
}
});
@Radagaisus
Radagaisus / domainr.py
Created September 14, 2011 03:24
Check domains from a list of words using Domai.nr API
#!/usr/bin/env python
# encoding: utf-8
"""
Check all available urls from the word list.
urls that aren't the exact word aren't considered.
"""
import urllib
import json
import re
@Radagaisus
Radagaisus / jquery.vslide.js
Created September 15, 2011 12:46
Vertical Slideshow jQuery Plugin (prototype)
(function($) {
$.fn.vslide = function(options) {
var defaults = {
slide: '.slide',
slide_inner: '.slide-inner'
next: '.next',
prev: '.prev',
slideHeight: 640,
slideWidth: 700,
vertical: true,
@Radagaisus
Radagaisus / loading.coffee
Created December 20, 2011 02:58
Loading Event for Backbone
window.old_sync = Backbone.sync
Backbone.sync = (method, model, options) =>
old_sync(method, model, options)
model.trigger("loading")
@Radagaisus
Radagaisus / yellow_fade.coffee
Created December 20, 2011 03:49
Yellow Fade Technique in Coffee
# $(".something").yellow_fade(1000)
# underscore.js is used. adapted from http://amix.dk/blog/post/19029
(($) ->
$.fn.yellow_fade = (speed) ->
# we call this function repeatedly
decrease_fade = (e, i, speed) ->
shades = ['ff', 'ee', 'dd', 'cc', 'bb', 'aa', '99']
if i # i == 0
e.css 'backgroundColor', "#ffff#{shades[i]}"
@Radagaisus
Radagaisus / nyt.py
Created December 22, 2011 12:43
Correlation between NYT Headlines and Baby Names (there is none)
#!/usr/bin/env python
# encoding: utf-8
"""
Check the number of mentions of each name
from the baby names list in each year new york times
newspapers and search for a coorelation
"""
import urllib
import json