This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Euclidean Algorithm | |
function gcd(a,b) { while (b) { var t = b; b = a%b; a = t } return a } | |
function lcm() { return Array.prototype.reduce.call(arguments, function(a,b){ return (a*b)/gcd(a,b) }) } | |
// http://projecteuler.net/problem=5 | |
// lcm(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,1,18,19,20) | |
// but we only need... ehm... primes but from last to first? | |
lcm(20, 19, 18, 17, 16, 15, 14, 13, 12, 11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1kFly.js ~ sadasant.com | |
// http://jsbin.com/aluyax/3 | |
function fly(f,mx,my,gx,gy,tx,ty,b,X,Y,x,y,i,r,M,a,w,W,w1){ | |
with(document){ | |
var h=["☼❤☼"," ❤"], | |
P=M.PI*i,A=M.abs, | |
D=.7+Math.random()*.7, | |
p=createElement('p'),s, | |
o=onmousemove;(s=p.style).fontFamily="monospace";s.position="fixed" | |
body.appendChild(p) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to organize and run your own hackathon by Peter Moran: https://www.youtube.com/watch?v=1nk2zJ2GTkQ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var points; | |
function initialize() { | |
$('#mapModal').modal('show'); | |
points = [{% for point in google.points %} | |
{ | |
center: new google.maps.LatLng({{ point.lat }}, {{ point.lng }}), | |
metrics: [{% for metric in point.metrics %} | |
{ | |
'name': '{{ metric.name }}', | |
'value': '{{ metric.value }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Dependencies. | |
*/ | |
var MongoStore = require('connect-mongo') | |
, mongoose = require('mongoose') | |
, express = require('express') | |
, app = module.exports = express.createServer() | |
/** | |
* Connecting. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?PHP | |
// b | |
// Copyright (C) 2012 Daniel Rodríguez (sadasant.com) | |
// License: GNU General Public License 3.0 | |
// Settings | |
$s = array( | |
'rw_menu_on' => 6 // Number of updates before rewriting the menu session | |
, 'articles_per_page' => 6 // Number of articles per page | |
, 'blog_location' => 'http://sadasant.com/b/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var d1, d0=new Date(); for(var i=0; i<99999; i++);d1=new Date();d1-d0; | |
// 2431 | |
var d1, d0=new Date(); for(var i=0>>0; i<99999>>0; i++);d1=new Date();d1-d0; | |
// 2361 | |
var i=0>>0, l=9999>>0, d1, d0=new Date(); for(; i<l; i++);d1=new Date();d1-d0; | |
// 318 | |
var i=0, l=9999, d1, d0=new Date(); for(; i<l; i++);d1=new Date();d1-d0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Go to https://api.twitter.com/1/favorites.json?count=200&screen_name=sadasant | |
TWEETS = JSON.parse(document.body.firstChild.innerHTML) | |
mapped_tweets = [] | |
function mapper(e){ | |
if(e.user.screen_name==='sadasant') | |
mapped_tweets.push({ | |
id: e.id_str | |
, date: e.created_at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$($('link')[0]||$('style')[0]).remove();$.get('/css/style.css', function(d){$('head').append($('<style/>').html(d))}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert') | |
/* | |
Fizzbuzz | |
*/ | |
function FizzBuzz (number) { | |
if (number % 3 == 0 && number % 5 == 0) return 'fizzbuzz' | |
else if (number % 3 == 0) return 'fizz' | |
else if (number % 5 == 0) return 'buzz' | |
else return number |
OlderNewer