Skip to content

Instantly share code, notes, and snippets.

View jpfuentes2's full-sized avatar

Jacques Fuentes jpfuentes2

  • Chime
  • Richmond, VA
View GitHub Profile
@jpfuentes2
jpfuentes2 / ipd.clj
Last active August 29, 2015 13:56
Iterated Prisoner's Dilemma
(defn prisoner [name strategy]
{:name name :strategy strategy :moves '() :scores '() :total-score 0})
(defn defect [moves] (conj moves 0))
(defn coop [moves] (conj moves 1))
(defn AlwaysDefect [mover opponent]
(defect mover))
@jpfuentes2
jpfuentes2 / riemann_server.go
Created February 5, 2014 15:03
Barebones Riemann server for integration tests
package main
import (
pb "code.google.com/p/goprotobuf/proto"
msg "github.com/amir/raidman/proto"
"log"
"net"
)
func createRiemannServer() {
@jpfuentes2
jpfuentes2 / match.rb
Created January 22, 2014 03:44
Horribly inefficient, mostly incorrect, and underwhelming pattern matching in Ruby
class Any; end;
class Pattern
attr :values
def initialize(*args)
@values = args
@matchers = []
end
@jpfuentes2
jpfuentes2 / clojure_lists_and_maps.clj
Created December 24, 2013 19:58
Clojure example of lightweight data modelling - based on https://gist.github.com/amontalenti/8114383
(doseq [item '(1 2 3 4)]
(println item))
(doseq [[k v] {:ST "started", :IP "in progress", :DN "done"}]
(println (str k " => " v)))
irb(main):001:0> require 'msgpack'
=> true
irb(main):002:0> msg = {Command: "Handshake", Seq: 0}
=> {:Command=>"Handshake", :Seq=>0}
irb(main):003:0> msg = MessagePack.pack(msg)
=> "\x82\xA7Command\xA9Handshake\xA3Seq\x00"
irb(main):004:0> MessagePack.unpack(msg)
=> {"Command"=>"Handshake", "Seq"=>0}
# client = MarilynRPC::NativeClient.connect_tcp('localhost', 7373)
@jpfuentes2
jpfuentes2 / Vagrantfile
Last active December 28, 2015 18:59
Latest stable docker + Ubuntu Precise (12.04) 64bit
#!/usr/bin/env ruby
# -*- mode: ruby -*-
# vi: set ft=ruby :
def machine_exists?
!Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").empty?
end
Vagrant::Config.run do |config|
#!/usr/bin/env ruby
require "clap"
@branch = "master"
@remote = "production"
Clap.run ARGV,
"--branch" => ->(b) { @branch = b },
"--remote" => ->(e) { @remote = e }
(ns labrepl.ipd)
;; moves and utils
(defn defect [moves] (conj moves 0))
(defn coop [moves] (conj moves 1))
(defn defect? [move] (= move 0))
#!/usr/bin/env ruby
ip = `ip addr | grep eth0 | grep inet | awk '{print $2}' | cut -f1 -d"/"`
pid_file = "/var/run/serf.pid"
if File.exists? pid_file
pid = File.read pid_file
Process.kill "INT", pid rescue nil
end

Pushodoro

Pushodoro combines the Pomodoro Technique with a quick and simple calisthenics routine, starting with push-ups, to get your butt in shape.

We're killing ourselves

The awful truth: we sit on our butts toiling away at computers far too long -- and it's killing us. It makes us unhealthy, stupid, and we're 40% more likely to die within 15 years. The benefits from 30 minutes of rigorous exercise is completely erased if you sit for 6 hours.

Let's fix this problem