Skip to content

Instantly share code, notes, and snippets.

View kylefritz's full-sized avatar

Kyle Fritz kylefritz

View GitHub Profile
require("../configure_enzyme");
//
// setup a mock for a function that depends on the current system time
//
import { pastDeadline } from "menu/pastDeadline";
jest.mock("menu/pastDeadline", () => {
let areWePastDeadline = true;
function __setPastDeadline(newValue) {
areWePastDeadline = newValue;
@kylefritz
kylefritz / s3.rake
Created April 15, 2020 17:25
Download blobs from s3 so can serve from active_storage.service = :local
require 'aws-sdk-s3'
namespace :s3 do
desc "Download blobs from s3 so can serve from active_storage.service = :local"
task :download => :environment do
s3 = Aws::S3::Client.new
bucket = '<bucket_name>' # TODO: your bucket name here
objects = s3.list_objects(bucket: bucket).contents
@kylefritz
kylefritz / gist:2159e6c1c8d6fb4971a5cc0e43497d01
Last active November 22, 2019 19:10
run command `arc lint` on each file changed in a branch
git diff -z --name-only master | xargs -0 -I FILE_PATH arc lint FILE_PATH
# -z delimits files with null character
# -0 gobbls the null character
# -I ANYTHING declares ANYTHING as the replacement token (to be filled with 1 file name)
#!/usr/bin/env bash
# set -x will make bash print/debug commands before it runs them.
set -eux -o pipefail
echo "yo"
exec ls -la ~/Desktop
@kylefritz
kylefritz / game.py
Created October 16, 2018 14:58
Alien shuffle for pygame zero
import random
alien = Actor('alien')
alien.topright = 0, 10
# these pieces of state needed to be attached to an actor to be updated...
alien.score = 0
alien.screen_color = 128, 80, 0
bad_alien = Actor('alien')
bad_alien.topright = 400, 10
select
date_trunc('day', enqueued_at) as enqueued_at
,last_stage
,count(*)
,round(percentile_cont(0.50) WITHIN GROUP (ORDER BY duration_minutes)) as p50
,round(percentile_cont(0.75) WITHIN GROUP (ORDER BY duration_minutes)) as p75
,round(percentile_cont(0.90) WITHIN GROUP (ORDER BY duration_minutes)) as p90
,round(percentile_cont(0.95) WITHIN GROUP (ORDER BY duration_minutes)) as p95
from queue_stat
@kylefritz
kylefritz / notebook.py
Created November 12, 2017 03:46
Basic Plotting on jupyter notebook
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
x = np.linspace(0, 10, 100)
y = np.cos(x)
plt.plot(x,y)
grid = np.zeros((20,20))
@kylefritz
kylefritz / index.html
Created October 4, 2016 01:36
check if local webpack server is running; fallback to real s3 asset
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>hello world</title>
<script>
const makeTag = function(src){
let scriptTag = document.createElement('script')
scriptTag.src = src
return scriptTag
@kylefritz
kylefritz / some_api_controller.rb
Created April 27, 2016 14:59
Websocket subscriptions with a "traditional" database
class SomeApiController
def mutate_data_action
new_object = parse_params()
save_to_db(new_object)
Pusher.broadcast('channel_name', new_object.to_json)
end
end
@kylefritz
kylefritz / squeezebox.coffee
Last active October 23, 2015 14:38
Control Squeezebox Through Hubot [Must be a firmware version pre "UE Smart Radio"; e.g. must work with http://www.mysqueezebox.com]
# Description:
# Allows Hubot to control pandora on a squeezebox music player.
# Also plays a generic internet radio station via play.
#
# Dependencies:
# none
#
# Configuration:
# SQUEEZE_BOX_EMAIL (for mysqueezebox.com)
# SQUEEZE_BOX_PASSWORD