Skip to content

Instantly share code, notes, and snippets.

@tystr
tystr / wma_offset.js
Created June 23, 2020 03:24
Tradovate weighted moving average script which allows setting an offset amount
const predef = require("./tools/predef");
const WMA = require("./tools/WMA");
class weightedMovingAverage {
init() {
this.wma = WMA(this.props.period);
}
map(d) {
return this.wma(d.value() - this.props.offset);
@tystr
tystr / chrome_app_mode.sh
Created May 3, 2019 15:30
Bash script to launch chrome in app mode on macOS
#!/bin/bash
# Launches chrome in app mode using the first argument to this command as the url.
if [ -z "$1" ]; then
echo "You must specify a full URL."
exit 1;
elif [[ ! $1 =~ ^https?:\/\/ ]]; then
echo "Url must begin with \"http://\" or \"https://\""
exit 1;
fi
<?php
namespace App\Response;
use Symfony\Component\HttpFoundation\HeaderBag;
use Symfony\Component\HttpFoundation\Response;
class TransparentImagePixelResponse extends Response
{
/**
@tystr
tystr / changelog.sh
Last active October 26, 2017 18:16
Simple script for building a changelog since the last tag
#!/bin/bash
#
# Author: Tyler Stroud <tyler@tylerstroud.com>
# Date: 2017-10-25
#
# This script will build a changelog containing commit messages for all commits since the most recent tag.
# It will prepend a new entry using today's date and the specified tagname followed by the commit messages
# to CHANGELOG.md
#
# Usage:
@tystr
tystr / ModelManager.php
Last active January 5, 2016 00:02
Cache query result per request
<?php
// ...
private $repository;
private $cachedResults = [];
public function findAll()
{
server {
listen 80;
server_name ~(?<parentjob>[^_]+)_(?<childjob>[^.]+)\.mydomain\.dev;
location / {
root /var/lib/jenkins/workspace/$parentjob/$childjob/web;
return 200 $childjob;
try_files $uri /app.php$is_args$args;
}
### Keybase proof
I hereby claim:
* I am tystr on github.
* I am tylerstroud (https://keybase.io/tylerstroud) on keybase.
* I have a public key whose fingerprint is 51CB 684A 14D0 7C2D 3E41 0964 2D84 6E4B 7781 B996
To claim this, I am signing this object:
def get_hosts_for_role(role, puppetmaster="puppetmaster.mydomain.net"):
""" Query the puppetmaster for hosts of nodes whose server_role fact matches the given role """
return yaml.load(local('ssh -T {0} \'curl -s -k -H "Accept: yaml" https://localhost:8140/production/facts_search/search?facts.server_role={1}\' | awk \'!/baseami/\''.format(puppetmaster, role), capture=True)
@tystr
tystr / deploy.sh
Last active December 12, 2017 17:42
Simple bash script to first build then rsync a brunch application to multiple servers
#!/bin/bash
# This script assumes that you have the deployer ssh key in your home directory
# The ./public directory is deployed into the $DEPLOY_TO directory on the remote servers
RSYNC=/usr/bin/rsync
BRUNCH=/usr/local/bin/brunch
PRODUCTION_HOSTNAMES=("host1" "host2")
DEPLOY_TO=/var/www/application/current
DEPLOYER_SSH_KEY=$HOME/.ssh/id_rsa-deployer
LOGFILE=deploy.log
@tystr
tystr / mongo-mms-agent
Last active December 18, 2015 02:09
init script for mongodb mms agent (http://mms.mongodb.com/help/monitoring/install/)
#!/bin/bash
#
# /etc/rc.d/init.d/mms-agent
#
# 10Gen Mongod montiroing service
# must edit the settings.py first and edit this file with the location of agent.py
#
# description: 10Gen monitoring service - need ot fix pid so we can shut it down
# chkconfig: - 90 10