Skip to content

Instantly share code, notes, and snippets.

@lfborjas
lfborjas / ugh.rb
Created March 5, 2013 01:59
fugly foobar
eval(
(%w[
1 0
1 0 0
]).zip(%w[
o d
e v n
]).map{ |(to, fro)|
%Q{
#{to}.upto(9) do |#{fro}|
@lfborjas
lfborjas / fun.js
Last active December 14, 2015 08:48 — forked from syntacticsugar/gist:5059926
//The fun solution: using array methods
var ary = [];
for(var i = 1; i <= 1000; i++){ ary.push(i); }
console.log(
ary.filter(function(item){
return (item % 3 == 0 || item % 5 == 0)
}).reduce(function(memo, current){
return memo + current
}, 0)
);
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Brainfuck</title>
<script type="text/javascript" charset="utf-8">
/*
Google HTML5 slides template
Authors: Luke Mahé (code)
@lfborjas
lfborjas / words.txt
Created December 6, 2012 05:20
egrep "^g.{3}a$" /usr/share/dict/words > words.txt #yay computers!
galea
galla
gamba
gamma
ganga
ganja
ganta
ganza
geira
gemma
var wrapped = function( obj ){
this.self = obj;
};
wrapped.prototype.maybe = function( prop ){
return this.self.hasOwnProperty( prop ) ? this.self[prop] : this.self;
}
var _ = function( obj ){
return new wrapped( obj );
@lfborjas
lfborjas / cat.js
Created November 1, 2012 21:52
kittehs
sys = require("child_process");
var Cat = function( name ){
this.name = name;
};
Cat.prototype.meow = function(){
sys.exec('say "' + this.name + ' says MEEEEOOOOOOOOOWOWOWOW"');
};
@lfborjas
lfborjas / hash.py
Created October 22, 2012 20:05
dicts that can merge in python
class hash: pass
hash.merge = lambda self, **b: dict(self.items() + b.items())
[:h1 "Hello world, etc."]
[:p
[:strong " this is the least"]
[:em " I "]
"could write"]
@lfborjas
lfborjas / .clj_completions
Created September 28, 2012 03:43
How I got my clojure readline working (assuming clojure was installed via homebrew)
sorted-map
;I have this stored in /usr/local/Cellar/clojure/1.3.0/.clj_completions
read-line
re-pattern
keyword?
unchecked-inc-int
val
chunked-seq?
find-protocol-impl
vector-of
@lfborjas
lfborjas / validate.coffee
Created August 13, 2012 01:47
some validations for a credit card form
jQuery ->
for id, callback of Model.validations
[selector, event] = id.split("on")
$(selector).on(event, callback)
Model =
error_template: _.template(
'<span class="billing-error"><%= msg %></span>'
)