Skip to content

Instantly share code, notes, and snippets.


Fabio Yamate fabioyamate

View GitHub Profile
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) }
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 / 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
View pageshow.html
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>jQuery Snippet</title>
<a href="event">event</a>
<ul id="container">
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 nth-last-child.html
<!doctype html>
<html lang="en">
<meta charset="utf-8">
li:nth-last-child(3) { background-color: red; }
<div id="container">
View affix-sandbox.html
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>jQuery Snippet</title>
<link rel="stylesheet" href="">
#text {height: 100%; background-color: pink}
#header { background-color: red; }
#header.affix {
fabioyamate / event_target.js
Created Dec 19, 2014
EventTarget mixin module
View event_target.js
// draft
(function(exports) {
var ArrayProto = Array.prototype;
var nativeSlice = ArrayProto.slice,
nativeFilter = ArrayProto.filter;
/* Internal: filters the collection. (extracted from underscore.js)
View .screenrc
# Turn off start message
startup_message off
termcapinfo rxvt-unicode 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007'
term screen
# Message to display in the status line when activity is detected in a
# monitored window.
fabioyamate / core.clj
Created Aug 31, 2015
Stub HTTP server
View core.clj
(ns stubhttp.core
(:require [ring.adapter.jetty :as r]
[ring.middleware.json :as json]
[ring.util.response :as response]))
(def state (atom {}))
(defn register! [{uri "uri" {:strs [status headers body]} "response"}]
(swap! state assoc uri {:status status :headers headers :body body}))