Skip to content

Instantly share code, notes, and snippets.


Fabio Yamate fabioyamate

View GitHub Profile
View 2048.clj
(defn transpose [m]
(apply mapv vector m))
(defn rotate-left [m]
(apply mapv vector (map reverse m)))
(defn- combine [[x y & xs :as row]]
(cond (empty? row) nil
(nil? y) (list x)
(= x y) (cons (* x 2) (combine xs))
View pageshow.html
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>jQuery Snippet</title>
<a href="event">event</a>
<ul id="container">
fabioyamate / lazy.js
Last active Aug 29, 2015
Lazy evaluation implemented in Javascript (well just because it has strict evalution)
View lazy.js
function empty_list() {
return null;
// concat :: [[a]] -> [a]
function concat(xs) {
return foldr(append, empty_list, xs);
// foldr :: (a -> b -> b) -> b -> [a] -> b
fabioyamate / promise.js
Created Jun 9, 2014
Promise polyfill with jQuery Deferreds
View promise.js
function Promise(fn) {
this.promise = $.Deferred(function(dfd) {
Promise.prototype.then = function(done, fail) {
this.promise.then(done, fail);
fabioyamate / maybe.html
Created May 21, 2014
Playground for a monad maybe implementation in Javascript
View maybe.html
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>jQuery Snippet</title>
<div id="container"></div>
<script src=""></script>
<script src=""></script>
View struct_fn.c
struct my_struct lookup(int count, const struct my_struct coll[], char value[]) {
int i;
for (i = 0; i < count; ++i) {
if (strcmp(coll[i].attr, value) == 0) {
return coll[i];
return NULL;
fabioyamate / shota.rb
Created Apr 27, 2014
Google Code Jam 2014 Round 1A
View shota.rb
require 'scanf'
def flip(mask, os) { |o| mask ^ o }
Infinity = 1.0/0
def solve(n, l, flows, required_flows)
outlets = flows.split(" ").map { |f| f.to_i(2) }
fabioyamate / overlay.js
Created Nov 22, 2013
A simple lib to create popup/tooltips
View overlay.js
(function(window, $) {
var containers = [];
// Public: position a container overlayed close to the target
// container - the container id
// callback - a function callback that receives 'container' and 'target'
// Examples
View blog.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>Hello world</title>
<link rel="stylesheet" href="">
<div class="pure-g-r" id="layout">
<div class="pure-u-1">
fabioyamate / apache.conf
Last active Dec 26, 2015
Apache2 assets config
View apache.conf
# a2enmod headers expires
SetEnv no-gzip
<LocationMatch "^/assets/.*\.(css|js)$">
RewriteEngine on
# Make sure the browser supports gzip encoding before we send it,
# and that we have a precompiled .gz version.
RewriteCond %{HTTP:Accept-Encoding} \b(x-)?gzip\b