Skip to content

Instantly share code, notes, and snippets.

View yanatan16's full-sized avatar

Jon Eisen yanatan16

View GitHub Profile
@yanatan16
yanatan16 / Makefile.golang
Created June 18, 2012 22:26
Makefile for Golang projects
# Makefile for a go project
#
# Author: Jon Eisen
# site: joneisen.me
#
# Targets:
# all: Builds the code
# build: Builds the code
# fmt: Formats the source files
# clean: cleans the code
@yanatan16
yanatan16 / AuthHandler.go
Created July 16, 2012 02:21
The AuthHandler Interface for goauth2
// These handlers should basically perform like a simple form submission.
// Once complete, notify the client using the redirects.
// As always, see http://tools.ietf.org/html/draft-ietf-oauth-v2-29 for reference.
// AuthHandler performs authentication with the resource owner
// It is important they follow OAuth 2.0 specification. For ease of use,
// A reference to the Store is passed in the OAuthRequest.
type AuthHandler interface {
// Authorize a client using the Authorization Code Grant Flow
@yanatan16
yanatan16 / round_down_multiples.md
Created October 3, 2012 12:47
Excel function to round down to multiples of .2
A1-MOD(A1*10,2)/10
@yanatan16
yanatan16 / gist:4770459
Last active December 12, 2015 12:09
Proposed Rule Change: FAAB

Philosophy of the FAAB Rule Change

The Free Agent Acquisiion Budget (FAAB) system has more nuance and "chess-like" qualities that we love about our auction-style draft than the first come first serve basis. Teams are able to pay the value of a player, so for instance Desmond Jennings could command up to $40 when he comes to the majors, whereas Reed Johnson would only cost $1. This will allow teams to scheme more about their purchases and in general, provide more intrigue to the season.

Teams will still have an opportunity to replace lost players after they have exhausted their FAAB, but at a reduced leverage point (i.e. after the auction closes). Players to be purchased still follow any othe rules in our Baseball Rules document, this only affects the acquisition system. By the way, FAAB is pronounced as in faabulous!

Proposed Rule Change

Section IV

Paragraph A (replacement)

@yanatan16
yanatan16 / spsa.py
Last active March 15, 2024 19:05
Simultaneous Perturbation Stochastic Approximation code in python
'''
Simultaneous Perturbation Stochastic Approximation
Author: Jon Eisen
License: MIT
This code defines runs SPSA using iterators.
A quick intro to iterators:
Iterators are like arrays except that we don't store the whole array, we just
store how to get to the next element. In this way, we can create infinite
iterators. In python, iterators can act very similar to arrays.
@yanatan16
yanatan16 / copy_rsync.rb
Created May 17, 2013 00:54
Copy and Rsync Strategy for capistrano. This may not work immediately, as I had to strip out some of my app-specific code.
require 'capistrano/recipes/deploy/strategy/base'
require 'fileutils'
require 'tempfile' # Dir.tmpdir
# Copy with Rsync capability.
class CopyRsync < Capistrano::Deploy::Strategy::Base
# Obtains a copy of the source code locally (via the #command method),
# compresses it to a single file, copies that file to all target
# servers, and uncompresses it on each of them into the deployment
@yanatan16
yanatan16 / README.md
Last active December 17, 2015 18:29
A Sass partial to create diagonal lines

Diagonal Lines in Sass

You can use _diagonal-line.scss to create arbitrary diagonal lines using CSS3. This implementation is compatible with all major browsers and IE9 or greater. An example usage of this partial is given in lines.scss. The compiled css file was included for display purposes.

Usage

To compile the sass file, you will need to use the additional functions provided in math.rb:

sass --watch path/to/sass:path/to/css -r ./math.rb
@yanatan16
yanatan16 / README.md
Last active December 18, 2015 04:59
hitAll.js - A jquery plugin which loads up iframes to a list of servers.

hitAll.js

A jquery plugin that renders iframes for different servers. Very useful for eye-testing after deployments.

// Initialize the hit-all
$('.some-div').hitAll({
  servers: ['server1.your-site.com', 'server2.your-site.com'],
  path: '/path/to/test',
 protocol: 'https' // optional. default http
@yanatan16
yanatan16 / xml_x2j_jsonq.go
Created June 12, 2013 13:47
XML usage in Go
package main
import (
"fmt"
"encoding/xml"
"github.com/clbanning/x2j"
"github.com/jmoiron/jsonq"
)
type Example struct {
@yanatan16
yanatan16 / mongo_indexes_presentation.md
Last active December 18, 2015 15:09
All about mongoDB indexes - a presentation

Much ado about Indexing

by Jon Eisen

Overview

Indexes are awesome because:

  • take a linear search and make it logarithmic (i.e. search through 8 items in 3 steps instead of 8).
  • eliminate in-memory sorts.
  • reduce hard drive lookups and page faulting.