Skip to content

Instantly share code, notes, and snippets.

View amy-langley's full-sized avatar

Amy Langley amy-langley

View GitHub Profile
@amy-langley
amy-langley / keep_running.sh
Created August 14, 2019 16:39
extremely simple script to keep running a thing forever
#!/bin/bash
while :
do
rails c < move_small.rb
done
@amy-langley
amy-langley / move_small.rb
Created August 14, 2019 16:38
like move_internal.rb, but does not loop, just finds the first few and quits immediately. it needs to be fast so that it moves things before reduce workers can pick them up.
# this assumes the rails console has preloaded the resources; accordingly,
# you should invoke this script as
#
# rails c < move_small.rb
begin
args_list = []
jobs_list = []
puts 'finding jobs'
Sidekiq::Queue.new('internal').each do |job|
@amy-langley
amy-langley / move_internal.rb
Created August 14, 2019 16:37
A script to move all TESS reduce worker tasks from the `internal` queue to the `holding` queue
# this assumes the rails console has preloaded the resources; accordingly,
# you should invoke this script as
#
# rails c < move_internal.rb
begin
args_list = []
jobs_list = []
puts 'finding jobs'
Sidekiq::Queue.new('internal').each do |job|
{
"id": 4094,
"reducible": {
"id": 1234,
"type": "Workflow"
},
"data": {
"centers": [
5,
30
def get_page(workflow, last_id) workflow.extracts.where('id > ? and workflow_id = ?', last_id, workflow.id).order(id: :asc).take(10000); end
def eval_page(page) puts "#{page.count}\t#{page.last.id}\n"; [page.count, page.last&.id]; end
def page_thru(id)
wf = Workflow.find(id); last_id=0; count=10000;
count, last_id = eval_page(get_page(wf, last_id)) until count < 10000
end
def time_this() start=Time.now.utc; yield(); Time.now.utc-start; end
@amy-langley
amy-langley / zipper.js
Last active August 2, 2018 18:51
An implementation of zippers over s-expressions represented as nested javascript arrays
class Node {
constructor(value, children) {
this.value = value;
this.children = children;
}
setValue(newValue) {
return new Node(newValue, this.children);
}
import Data.List as List
data Tree a =
Empty |
Leaf a |
Branch (Tree a) a (Tree a) deriving Show
insertT :: Ord a => a -> Tree a -> Tree a
insertT n Empty = Leaf n
{
"annotations": [
{
"task": "init",
"value": 3
},
{
"task": "T4",
"value": [
{
@amy-langley
amy-langley / filmstrip.css
Last active May 7, 2019 01:16
Filmstrip React component
.filmstrip{
padding: 0;
margin: 10px;
display: flex;
}
.navButton{
border: 0;
margin: 0;
height: 100%;
@amy-langley
amy-langley / compile.js
Created December 4, 2015 17:04
TFW you throw together an HTML template compiler b/c you can't use a decent framework
var compile = function(selector){
var r = /(\{\{.+?\}\})/;
var elem = document.querySelector(selector);
var markup = elem.outerHTML;
elem.remove();
markup = markup.replace(/\s+/,' ');
var fragments = markup.split(r);
var template = (function(tpl){