Skip to content

Instantly share code, notes, and snippets.

View yanatan16's full-sized avatar

Jon Eisen yanatan16

View GitHub Profile
@yanatan16
yanatan16 / for_var_scoping.js
Created August 8, 2014 20:17
Where js's for-loop var leaking is bad
var arr = [1,2,3,4];
for (var i = 0, len = arr.length; i < len; i++) {
var el = arr[i];
setTimeout(function () {
console.log(el);
}, 10);
}
@yanatan16
yanatan16 / gist:b0876cacee93dddf074b
Last active August 29, 2015 14:04
widget notes
# widget
## Customizable layout/templates
- Customization really involves every aspect of user interaction
- embed code embeds both template and configuration
- config might be shortcoded, encoded, or plain
_PUSHED_ Custom Entry Options
@yanatan16
yanatan16 / scale.md
Created July 27, 2014 02:29
Presentation on Scale

Scale

Scale is a buzzword for growth in the tech industry, but it has so many meanings. Let's dig into them to see what scale really means!

Scaling means you are increasing the responsibility or load of a system.

How do we, as web developers, handle the increased load?

  1. Increase Concurrency
  2. Distribute load across mulitple servers
@yanatan16
yanatan16 / README.md
Created June 12, 2014 19:22
Testing engine.io-client 1.0 on android
  • Clone engine.io-client
git clone https://github.com/Automattic/engine.io-client
cd engine.io-client
npm install
  • Start a test server
ZUUL_PORT=8080 node test/support/server.js
@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 / _modules-ufw.py
Last active March 15, 2019 17:07
Making Clean and Reusable Salt States Lessons - Custom Salt States
"""
Execution module for UFW.
"""
def is_enabled():
cmd = 'ufw status | grep "Status: active"'
out = __salt__['cmd.run'](cmd)
return True if out else False
def set_enabled(enabled):
@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 / transistor_function_combinations.py
Created May 21, 2014 17:43
Calculate the number of ability combinations from function usage in Transistor. (answer: 22 billion)
#!/usr/bin/env python3
from math import factorial
def combinations(n):
''' Given n functions to be selected, return how many combinations for selecting those functions there are '''
return int(factorial(16) / factorial(16-n))
def get_all_combinations():
'''
@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");
@yanatan16
yanatan16 / README.md
Last active January 19, 2016 03:07
Fixing The Witcher Enhanced Edition for OSX Mavericks
  • Install The Witcher Enhanced Edition via Steam on OSX
  • Update wineskin version using this walkthrough with the following modification:
    • Use the latest edition of wineskin: I used 1.7.17
    • Don't run the game at the end of the walkthrough, theres more to do
  • Now we will setup XQuartz as our X11 server instead of using the crap wineskin one
    • Download and install XQuartz
    • While its downloading and installing (or after):
      • Open up Wineskin from inside Witcher.app (as you did in the update walkthrough)
      • Go to Advanced -> Options
  • Check the box "Force the use of XQuartz"