Skip to content

Instantly share code, notes, and snippets.

@dpfrakes
dpfrakes / wod.js
Created March 17, 2017 03:56
API Hacking: Workout of the Day
$.get('https://api.spartan.com/v6/api/get_page/?route=spartan.training.wod&secondary=spartan-wod&primary=1', function(data) {
var workoutHtml = data.wods[0].post_content;
workoutHtml = workoutHtml.split('jpg').join('x');
workoutHtml = workoutHtml.split('png').join('x');
document.write(workoutHtml);
$('img').hide();
});
// Sass map of social platform primary colors
// @see https://brandcolors.net/
$social-colors: (
facebook: #3b5998,
twitter: #1da1f2,
instagram: #405de6,
googleplus: #dd4b39,
linkedin: #0077b5,
pinterest: #bd081c,
vk: #45668e,
#!/bin/python
# http://docs.python-guide.org/en/latest/writing/logging/
import logging
logger = logging.getLogger()
handler = logging.StreamHandler()
formatter = logging.Formatter(
'%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
@dpfrakes
dpfrakes / install_box2d.sh
Last active November 18, 2019 23:34
Install Box2D
### Install Box2D from source
# Mac
brew install swig
# Linux
sudo apt-get install build-essential python-dev swig
# Download source
cd ~/dev
import os
from datetime import datetime as dt
import numpy as np
def save_results(agent, arr):
# Save array of Q updates (or anything else) and accompanying agent metadata
filename = '{}_{}'.format(dt.now().strftime('%H%M%S'), agent.algo_name)
@dpfrakes
dpfrakes / Remove CSS
Created May 11, 2018 17:34
bookmarklet to remove internal styles and external stylesheets
javascript:((function() {document.querySelectorAll("link[rel='stylesheet']").forEach(function(l) {l.remove();});document.querySelectorAll("style").forEach(function(s) {s.remove();});})())
Vagrant.configure("2") do |config|
# config.vm.box = "ubuntu/trusty64"
# config.vm.box = "ubuntu/xenial64"
# config.vm.box = "bento/ubuntu-14.04"
config.vm.box = "bento/ubuntu-16.04"
# NB: this value is used in ansible playbook and inventory.
config.vm.define 'ubuntu-16-vm'
config.vm.synced_folder '../', '/home/vagrant/src', nfs: true, mount_options: ['rw', 'vers=3', 'tcp', 'fsc' ,'actimeo=2']
config.vm.synced_folder '../../', '/home/vagrant/external'
@dpfrakes
dpfrakes / test.html
Last active June 1, 2018 06:14
testing html canvas gist embed
<svg></svg>
<script>
var height = 400;
var width = 800;
function fn(x) {
return (x * 0.1) * Math.sin(x / 8);
}
@dpfrakes
dpfrakes / sublime_indentation.md
Last active August 30, 2018 17:54
Debugging sublime indentation

Sublime indentation

  1. Sublime Text > Preferences > Settings : "translate_tabs_to_spaces": [true|false]
  2. Sublime Text > Preferences > Settings - Syntax Specific : "translate_tabs_to_spaces": [true|false]
  3. View > Indentation > Indent using spaces : toggle
  4. Open .editorconfig if it exists : update indent_style = [space|tab|ignore]
@dpfrakes
dpfrakes / multithread.py
Created October 11, 2018 11:18
Simple multithreading implementation
"""
https://stackoverflow.com/questions/2846653/how-to-use-threading-in-python
https://stackoverflow.com/questions/5442910/python-multiprocessing-pool-map-for-multiple-arguments/5443941#5443941
"""
import itertools
from multiprocessing import Pool
def _func_run_task(x):
return do_task(*x)