Skip to content

Instantly share code, notes, and snippets.

View yanatan16's full-sized avatar

Jon Eisen yanatan16

View GitHub Profile
@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 / README.md
Created June 9, 2014 20:54
Making Clean and Reusable Salt States - Generic App Deployments Structure

Generic App Deployments

This is an outline of how to setup a generic app deployment using Salt Stack and all its features:

  • Configure apps in the pillar
  • Override git revisions with grains
  • Setup box configurations with grains
  • Resolve configurations with custom modules
  • Generate states with jinja
@yanatan16
yanatan16 / .mongorc.js
Last active June 27, 2022 09:03
My .mongorc.js file
(function () {
rcversion = '1.0';
load('underscore.min.js')
// NOTES
// Basics, wrap the whole thing in a function
// Set a version for sanity's sake
// Load underscore, a must in any javascript environment
@yanatan16
yanatan16 / load-balancer.conf
Created April 11, 2014 22:54
Example nginx load balancer
## Global parameters
## StatsD Plugin: https://github.com/zebrafishlabs/nginx-statsd
statsd_server statsd.domain.tld;
# Stop proxying to an upstream if any of these happen
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
# Setup standard forwarding headers
proxy_set_header Accept-Encoding "";
@yanatan16
yanatan16 / Gruntfile.js
Created September 11, 2013 23:08
Grunt System to build angular projects
module.exports = function ( grunt ) {
/**
* Load required Grunt tasks. These are installed based on the versions listed
* in `package.json` when you do `npm install` in this directory.
*/
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
@yanatan16
yanatan16 / client.js
Last active June 3, 2020 23:29
Your own http://usetorpedo.com clone. Automagically disappearing secrets. No file uploads here but that can be done too.
var secret = window.prompt('Enter your secret')
var xmlhttp = new XMLHttpRequest()
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = JSON.parse(xmlhttp.responseText)
window.alert('secret saved at: ' + obj.url)
}
}
xmlhttp.open('POST', 'http://mysecrets.mydomain.tdl/p', true)
xmlhttp.setRequestHeader("Content-type","application/json");

help

this

out

@yanatan16
yanatan16 / app-config.json.jinja
Last active January 11, 2020 22:54
Making Clean and Reusable Salt States Lessons - Jinja Imports
{%- from 'macros.jinja' import mongocfg with context -%}
{
"mongo": {{mongocfg_json()}}
}
@yanatan16
yanatan16 / pullreq.sh
Last active January 11, 2020 22:53
pullreq - A bash function to make a pull request.
# Push your current branch to origin and open a pull request to upstream:$1 or upstream:master
pullreq()
{
local browser=google-chrome # replace with your browser command
local regex='(https?://|git://|git@)([a-zA-Z0-9\.]+)[:/]([a-zA-Z0-9]+)/(.+)?'
local origin=$(git remote -v | grep origin | grep push | cut -f2 | cut -d' ' -f1)
local upstream=$(git remote -v | grep upstream | grep fetch | cut -f2 | cut -d' ' -f1)
local params=$(python -c "import sys;import re;print ':'.join(re.match('${regex}',sys.argv[1]).groups()[1:])" $origin)
local site=$(echo $params | cut -d':' -f1)
@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