Skip to content

Instantly share code, notes, and snippets.

View jmealo's full-sized avatar

Jeff Mealo jmealo

View GitHub Profile
@jmealo
jmealo / install-steps
Last active November 6, 2024 14:02
Workaround for JetBrains and Electron-based Apps not rendering (black, pink or white) screen after waking from sleep on MacOS
brew install sleepwatcher
# write restart_apps.sh to ~/.wakeup
chmod +x ~/.wakeup
brew services start sleepwatcher
# your mileage may vary getting sleepwatcher to run the script, but, the script should work if executed manually

test.thing

To create an anchor to a heading in github flavored markdown. Add - characters between each word in the heading and wrap the value in parens (#some-markdown-heading) so your link should look like so:

[create an anchor](#anchors-in-markdown)

@jmealo
jmealo / copy-triggers.sql
Created May 7, 2021 17:50
This trigger copies all the triggers attached to one table to another. If you use the tables name in the trigger, that'll get replaced as well.
CREATE OR REPLACE FUNCTION copy_table_triggers(p_source_tablename text, p_dest_tablename text) RETURNS boolean
LANGUAGE plpgsql
AS
$$
DECLARE
v_sql text;
v_trigger_list record;
BEGIN
-- Triggers
curl -i -H 'Content-type: application/json' -H 'Authorization: key=<your_server_key>' -XPOST https://fcm.googleapis.com/fcm/send -d '{
"registration_ids":["registration_ids", "of the", "target", "devices as array"],
"notification": {
"title":"Title of your notification",
"body":"content of your notification"
},
"data": {
"key1" : "value1",
"key2" : "value2",
"key3" : 23.56565,
@jmealo
jmealo / ccd_schools_to_sql.sh
Created August 15, 2017 15:48
Download CCD schools and load the CSV file into PostgreSQL with reasonable full text searching enabled
#!/bin/bash -e
apt-get install -y wget unzip recode
wget -nc https://nces.ed.gov/ccd/Data/zip/ccd_sch_029_1516_txt_prel_tab.zip
unzip -o ccd_sch_029_1516_txt_prel_tab.zip
recode ISO-8859-15..UTF8 /tmp/ccd_sch_029_1516_txt_prel.tab
#EXPLAIN ANALYZE select sch_name, lea_name, ncessch, website, updated_status, charter_text, ts_rank(search, to_tsquery('simple', 'Michi:*')) AS rank FROM ccd_schools ORDER BY rank DESC LIMIT 100;
#EXPLAIN ANALYZE WITH results AS (select sch_name, lea_name, ncessch, website, updated_status, charter_text, search FROM ccd_schools WHERE search @@ to_tsquery('simple', 'Michi:*')) SELECT *, ts_rank(search, to_tsquery('simple', 'Michi:*')) AS rank FROM results ORDER BY rank DESC LIMIT 100;
@jmealo
jmealo / openresty-nchan-redis-luarocks.sh
Last active January 4, 2020 22:51 — forked from wojons/openresty-luarocks.sh
OpenResty + LuaRocks + Nchan + Redis (with password, graph and bloom modules)
#!/bin/sh
apt-get install -y libreadline-dev libncurses5-dev libpcre3-dev \
libssl-dev perl make build-essential git curl \
unzip
git clone https://github.com/RedisLabsModules/password.git /tmp/password
git clone https://github.com/RedisLabsModules/rebloom.git /tmp/rebloom
git clone https://github.com/RedisLabsModules/redis-graph.git /tmp/redis-graph
@jmealo
jmealo / grade-wired-aq-test.js
Last active February 3, 2017 21:17
Pasting this into the JavaScript console will grade your AQ on Wired: https://www.wired.com/2001/12/aqtest/
// This is an attempt at doing things the most obvious way with an
// emphasis on readability ... It's not clever but it's still not obvious
// what we're doing. It also requires you to know both javascript and
// CSS selectors
var addIfAgreed = [
2, 4, 5, 6, 7, 9, 12, 13, 16, 18, 19, 20, 21, 22, 23, 26, 33, 35, 39, 41,
42, 43, 45, 46
]
#!/bin/bash
set -o errexit
clear
# Set versions. Check http://openresty.org for latest version and bundled version of nginx.
OPENRESTY_VERSION=1.11.2.2
NGINX_VERSION=1.11.2
OPENSSL_VERSION=1.1.0c
NPS_VERSION=1.11.33.4
@jmealo
jmealo / prevent-double-credit-trigger.sql
Created September 28, 2016 16:18
Do not allow a student to open a completed sparkpoint in multiple sections to game pacing
SET search_path = 'mta-staging';
CREATE OR REPLACE FUNCTION ssas_guard_double_completion()
RETURNS trigger AS
$$
BEGIN
-- Do not create a new active sparkpoint record if the sparkpoint has already been completed in another section
PERFORM 1 FROM student_sparkpoint
WHERE sparkpoint_id = NEW.sparkpoint_id
AND student_id = NEW.student_id
@jmealo
jmealo / date-functions.js
Last active September 13, 2016 21:11
Functions for excluding specific dates and weekends from time calculations
const MS_IN_DAY = 86400000;
// Pretend this is the start/end time for a phase
var startDate = new Date("01/24/1989 08:30:23"),
endDate = new Date("01/31/1989 16:32:23"),
// This will be provided by the API -- extracted from a Google Calendar/iCal feed
daysOff = [
new Date("01/26/1989"),
new Date("01/27/1989")