Skip to content

Instantly share code, notes, and snippets.

@mikepaszkiewicz
mikepaszkiewicz / gist:b8759fab46b23c3964192047cbd5cac5
Created March 8, 2023 15:51
join users with their latest device by created_at
SELECT
u.*,
row_to_json(d.*) device
FROM
users u
INNER JOIN (
SELECT
user_id,
MAX(created_at) MaxDate
FROM
Bug:
python 2.7, pip 8.1.1, Ubuntu 16.04
pip install as jenkins user throws:
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-eHn5Qu-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/cryptography
Storing debug log for failure in /root/.pip/pip.log
The command '/bin/sh -c cd /src; pip install -r requirements.txt' returned a non-zero code: 1
Build step 'Execute shell' marked build as failure
const zuppler = 'c6b348e0-6d49-11ea-9d4d-db9d78913103'
const vendor = '05a3b881-ee42-11eb-a309-21dcd8197474'
const time = moment()
.add({ hours: 2 })
.startOf('hour')
.toISOString()
//quote payload
const q = {
bag_count: 1,
//note ready_at in /quotes and ready_by in /orders are the same value
POST /quotes
{
origin:
'2000 Market Street, 2000 Market St, Philadelphia, PA 19103, USA',
destination:
'1999 North 52nd Street, , Philadelphia, PA, 19131, United States',
vendor_id,
@mikepaszkiewicz
mikepaszkiewicz / verify-mocha.sh
Created April 18, 2022 20:03
Scan mocha directory for it.only, fail pre-commit hook
#!/bin/bash
# Scans /tests directory for instances of 'it.only',
# If found, cancel commit and log files that need to be fixed.
TEST_ERRORS=$(grep -s it.only ../tests/*/** | wc -l)
echo "Verifying all tests are enabled...";
if [ $TEST_ERRORS -gt 0 ]
then
@mikepaszkiewicz
mikepaszkiewicz / migration-example.ts
Created February 4, 2022 17:58
Migration example
import { Knex } from 'knex'
import { Territory } from '../packages/types'
exports.up = async function (knex: Knex) {
await knex.schema.hasTable('operators').then(async hasTable => {
if (hasTable) {
await knex.schema
.hasColumn('operators', 'send_tracker_link')
.then(async hasColumn => {
if (!hasColumn) {
await knex.schema.table('operators', t => {
function deriveRunnerLaborHours(pred: CapacityPreds, max_callout_rate: number) {
if (pred.runner_hours_predicted === 0) {
return { finalCapacity: 0 }
}
let predictedDrhWithLimits: number = null
if (pred.drh_predicted < MIN_DRH) {
predictedDrhWithLimits = MIN_DRH
} else if (pred.drh_predicted > MAX_DRH) {
Applying hasura data to:
https://worthy-leech-90.hasura.app/v1/graphql
{"level":"info","msg":"Help us improve Hasura! The cli collects anonymized usage stats which\nallow us to keep improving Hasura at warp speed. To opt-out or read more,\nvisit https://hasura.io/docs/1.0/graphql/manual/guides/telemetry.html\n","time":"2021-01-13T22:34:07Z"}
{"level":"debug","msg":"global config file exisits, verifying contents","time":"2021-01-13T22:34:07Z"}
{"level":"debug","msg":"global config is pre-set to \u0026cli.GlobalConfig{UUID:\"ebb072c2-9126-4302-af5c-c1598c9ad5f9\", EnableTelemetry:true, ShowUpdateNotification:true, CLIEnvironment:\"default\"}","time":"2021-01-13T22:34:07Z"}
{"level":"debug","msg":"global config: uuid: ebb072c2-9126-4302-af5c-c1598c9ad5f9","time":"2021-01-13T22:34:07Z"}
{"level":"debug","msg":"global config: enableTelemetry: true","time":"2021-01-13T22:34:07Z"}
{"level":"debug","msg":"global config: showUpdateNotification: true","time":"2021
@mikepaszkiewicz
mikepaszkiewicz / user-data.sh
Created December 11, 2020 14:28 — forked from abhilash1in/user-data.sh
Install nvm and NodeJS using AWS EC2 user data script
#!/bin/bash
apt-get -y update
cat > /tmp/subscript.sh << EOF
# START UBUNTU USERSPACE
echo "Setting up NodeJS Environment"
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.9/install.sh | bash
echo 'export NVM_DIR="/home/ubuntu/.nvm"' >> /home/ubuntu/.bashrc
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> /home/ubuntu/.bashrc
# Dot source the files to ensure that variables are available within the current shell
. /home/ubuntu/.nvm/nvm.sh
@mikepaszkiewicz
mikepaszkiewicz / .sh
Last active October 8, 2020 14:41
Bash Cheat Sheet
##FILESYSTEM
# append all .csv files in only one and ignore headers in subsequent files.
#!/bin/bash
OutFileName="X.csv" # Fix the output name
i=0 # Reset a counter
for filename in ./*.csv; do
if [ "$filename" != "$OutFileName" ] ; # Avoid recursion
then
if [[ $i -eq 0 ]] ; then