Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am devster31 on github.
  • I am devster (https://keybase.io/devster) on keybase.
  • I have a public key ASA9TOe1FftRr064ouxzqKdIdFMzNojdIjj1mqNPRGy-MAo

To claim this, I am signing this object:

@devster31
devster31 / dailyprogrammer-278-part1.go
Created August 12, 2016 21:04
r/dailyprogrammer 278 part 1
package main
import (
"bytes"
"fmt"
"strings"
)
type Interleave struct {
opType, first, second string
@devster31
devster31 / batch.ps
Created April 23, 2017 23:04
Convert .mov files into .mp4 files on Windows without re-encoding video
$oldvids = Get-ChildItem -Filter "*.mov" -Recurse
foreach ($oldvid in $oldvids) {
$newvid = [io.path]::ChangeExtension($oldvid.FullName, '.mp4')
ffmpeg -i $oldvid.FullName -y -c:v copy -c:a libvo_aacenc -b:a 256k $newvid
}
@devster31
devster31 / BUGS.R
Last active May 5, 2017 21:20
Bayesian analysis of OPTIMISE trial (OpenBUGS and JAGS versions)
source("~/Doing_Bayesian_Analysis/openGraphSaveGraph.R")
source("~/Doing_Bayesian_Analysis/plotPost.R")
require(BRugs)
modelstring = "
# BUGS model specification begins here...
model {
# Likelihood. Each complication/death is Bernoulli.
for ( i in 1 : N1 ) { y1[i] ~ dbern( theta1 ) }
for ( i in 1 : N2 ) { y2[i] ~ dbern( theta2 ) }
@devster31
devster31 / yml2json
Created August 15, 2017 14:30
oneliner to dump YAML to JSON
#!/usr/bin/ruby
# ruby -ryaml -rjson -e 'puts YAML.load($stdin.read).to_json'
require 'json'
require 'yaml'
puts YAML.load($stdin.read).to_json

Strategies

The trend_ema strategy (default)

  • The default strategy is called trend_ema and resides at ./extensions/strategies/trend_ema.
  • Defaults to using a 2m period, but you can override this with adding e.g. --period=5m to the sim or trade commands.
  • Computes the 26-period EMA of the current price, and calculates the percent change from the last period's EMA to get the trend_ema_rate
  • Considers trend_ema_rate >= 0 an upwards trend and trend_ema_rate < 0 a downwards trend
  • Filters out low values (whipsaws) by neutral_rate, which when set to auto, uses the standard deviation of the trend_ema_rate as a variable noise filter.
  • Buys at the beginning of upwards trend, sells at the beginning of downwards trend
from subprocess import Popen, PIPE
def run_command():
with Popen(['pp3.py'], stdout=PIPE, stderr=PIPE, bufsize=1, universal_newlines=True) as p:
while p.poll() is None:
out = p.stdout.readline()
err = p.stderr.readline()
print(out, end='')
print(err, end='')
@devster31
devster31 / post-script.sh
Created February 25, 2018 16:45
messy post-processing
#!/bin/bash -u
MEDUSA_API_KEY=*****
file=$1 # {f}
location=$2 # {f.dir.dir}
database=${3} # {info.DataBase}
id=${4:-x} # {info.id}
name="${5}" # {info.Name}
if [[ ! -f "$1" ]]; then
@devster31
devster31 / joseph_reagle.bash
Last active February 23, 2019 02:09
ssh-agent automation done well
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
}
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',