Skip to content

Instantly share code, notes, and snippets.

View terrafied's full-sized avatar
💭
Shopping for cute shoes

Terra Metta terrafied

💭
Shopping for cute shoes
  • The Trans Agenda
  • 62 West Wallaby St., The Shire
View GitHub Profile
@terrafied
terrafied / algo.cs
Created April 10, 2019 04:42
Smoothed z-score algorithm. Peak detection with robust threshold.
public class ZScoreOutput
{
public List<double> input;
public List<int> signals;
public List<double> avgFilter;
public List<double> filtered_stddev;
}
public static class ZScore
{
@terrafied
terrafied / ThresholdingAlgo.py
Created April 10, 2019 04:42 — forked from ximeg/ ThresholdingAlgo.py
Python implementation of smoothed z-score algorithm from http://stackoverflow.com/a/22640362/6029703
#!/usr/bin/env python
# Implementation of algorithm from http://stackoverflow.com/a/22640362/6029703
import numpy as np
import pylab
def thresholding_algo(y, lag, threshold, influence):
signals = np.zeros(len(y))
filteredY = np.array(y)
avgFilter = [0]*len(y)
stdFilter = [0]*len(y)
@terrafied
terrafied / build-gn.sh
Created November 14, 2017 18:35 — forked from mohamed/build-gn.sh
Build Google gn build tool standalone
#!/bin/bash
set -e
set -v
# Get the sources
mkdir gn-standalone
cd gn-standalone
mkdir tools
cd tools
@terrafied
terrafied / build-gn.sh
Created November 14, 2017 18:35 — forked from mohamed/build-gn.sh
Build Google gn build tool standalone
#!/bin/bash
set -e
set -v
# Get the sources
mkdir gn-standalone
cd gn-standalone
mkdir tools
cd tools
@terrafied
terrafied / 0_reuse_code.js
Last active August 29, 2015 14:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@terrafied
terrafied / test_mailer.rb
Created November 24, 2014 19:11
Rails console test email
class TestMailer < ActionMailer::Base
default :from => "me@mysite.com"
def welcome_email
mail(:to => "other@elsewhere.com", :subject => "Test mail", :body => "Test mail body")
end
end
TestMailer.welcome_email.deliver
@terrafied
terrafied / keybase.md
Created September 10, 2014 20:50
Keybase Confirmation

Keybase proof

I hereby claim:

  • I am johnmetta on github.
  • I am johnmetta (https://keybase.io/johnmetta) on keybase.
  • I have a public key whose fingerprint is 3FC1 B761 BA1F 5738 6385 BAB4 443D 4D4F 8F14 DBBF

To claim this, I am signing this object:

@terrafied
terrafied / gist:9962075
Created April 3, 2014 20:17
Zeus not recognizing that block is closed

Given a block method which takes an argument and an optional hash, zeus cannot recognize the block on the commandline if paretheses are used.

To wit, on the commandline

2.1.0 > def test(sym, opts={}, &block)
2.1.0?>     puts "starting #{sym} with options #{opts.to_s}"
2.1.0?>     yield
2.1.0?>     puts "ending #{sym}"
2.1.0?>   end
@terrafied
terrafied / active_record.md
Last active January 2, 2016 12:58
ActiveRecord to_a madness

Same console, same codebase, different database connections. Result: different object types returned.

Example classes

class User < ActiveRecord::Base
   ...
end

class Series < ActiveRecord::Base
 establish_connection postgres_database_hash
@terrafied
terrafied / active_record_mappings.rb
Last active December 28, 2015 10:59
Helper class for finding all ActiveRecord relation mappings in a database (mostly for use outside of the context of ActiveRecord)
# Non-Rails version that pulls mappings without using ActiveRecord. Externally pulls data and stores on filesystem.
class ActiveRecordMappings
attr_accessor :database, :command
# Initialize with a database name and a mysql commandline string
# e.g. arm = ActiveRecordMappings.new(command: "mysql -u john -p", database: "my_stuff")
def initialize(opts={})
opts.assert_valid_keys :database, :command
@database = opts[:database]