Skip to content

Instantly share code, notes, and snippets.

# this is useful for sending action cable updates to doctors portal
def spam(count, naptime)
patients = Patient.all.sample(count)
patients.each do |patient|
sleep(naptime) if naptime
Doctor.all.each do |doc|
DoctorSchema.subscriptions.trigger('patientUpdates', { doctorId: doc.id }, patient)
end
@chandeeland
chandeeland / perfect_spiral.pde
Created December 17, 2019 23:34
Circles in Circles moving to give the illusion of spirals (processing v3)
// inspired by https://gist.github.com/volfegan/e55decad6814e63fb450379c9bf13a61
// attempt to recreate: https://twitter.com/Borrachas/status/1204855395006763009
float a=0, b=0, x,y;
float shrink, spin_speed;
void setup() {
size(800,800);
shrink = 0.900;
spin_speed = 0.1;

example command to run

$ time ruby xkcd.rb big.txt

@chandeeland
chandeeland / check_number.rb
Created September 14, 2018 19:50
check number
class CheckNumber
ALPHABET = (2..9).to_a + ('a'..'z').to_a - %w[o i]
# ALPHABET = (0..9).to_a + ('a'..'z').to_a + ('A'..'Z').to_a + %w[ @ & ]
def initialize(uuid, size = 4, chunk_size = 4)
@uuid = uuid
@size = size
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
# *) local and remote tag names
require 'uri'
require 'net/http'
require 'json'
require 'pry'
class Brandibble
def initialize(env)
@env = env
end
ids = ['5aa3051901e9de000718f7b2', '5ac7a8106ae1c000075370fa']
locs = Platform::Location.where(:id.in => ids)
300.times do |d|
day = d.days.from_now.beginning_of_day + 1.minute
locs.each { |l| l.business_day_for(day) }
end
@chandeeland
chandeeland / prepare-commit-msg
Last active May 24, 2018 23:01
this will try to detect your Jira ticket id from your branch name and insert it into your commit message
#!/bin/bash
BRANCH_NAME=$(git symbolic-ref --short HEAD)
if [ -z "$BRANCH_NAME" ]; then
exit 0
fi
if [ "master" = "$BRANCH_NAME" ]; then
exit 0
fi
@chandeeland
chandeeland / git-branch.sh
Last active June 23, 2022 15:17
a little bash toy to help find branches easier
#!/bin/bash
GIT=`which git`
FOUND=`$GIT branch | grep $1 | sed -e 's/^[ *] //' | sed -e 's/remotes\/origin\///g' |sort -u`
NUM_FOUND=`echo $FOUND|wc -l`
echo
if [ $NUM_FOUND -gt 1 ]; then
echo 'FOUND THESE MATCHING BRANCHES'
echo
echo "$FOUND"