Skip to content

Instantly share code, notes, and snippets.

View arilotter's full-sized avatar

Ari Lotter arilotter

View GitHub Profile
const SquareConnect = require("square-connect");
const admin = require("firebase-admin");
const functions = require("firebase-functions");
exports.catalog = functions.https.onRequest((request, response) => {
admin.auth().verifyIdToken(request.body.idToken)
.then(decodedToken =>
admin.database()
.ref(`/squareAccessToken/${decodedToken.uid}`)
.once("value")
@arilotter
arilotter / main.js
Created April 18, 2018 23:58
This code is GPL
const PitchDetector = require('./module');
const pd = new PitchDetector(1000);
console.log(pd);
"""
Support for the Hitron CODA-4582U, provided by Rogers.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/device_tracker.keenetic_ndms2/
"""
import logging
from collections import namedtuple
import requests
function config(obj, opts) {
Object.keys(opts).forEach(opt => {
obj[`set${opt.charAt(0).toUpperCase() + opt.slice(1)}`](opts[opt]);
});
return obj;
}
def doThing(dic, words):
charsNeeded = [doesIntersect(dic, word) for word in words]
A1 = "Yes" if all(charsNeeded) else "No"
A2 = max(*charsNeeded)
return A1 + " " + str(A2)
def doesIntersect(dic, word):
dic = list(dic)
charsNeeded = 0
for char in word:
@arilotter
arilotter / README.md
Last active September 30, 2016 01:26
Gavino Scripto

splice.sh

This silly script will take two video files, and spit out a new video file with the frames of each interlaces so you can watch two movies at the same time!!! It also puts the audio from each video in one ear.

It'll probably take a ridiculously long time to generate any video file of substance, so I've uploaded a sample video of two movie trailers run through this script: https://my.mixtape.moe/qzddsq.mp4

Some useful stuff:

  • Both the videos MUST have identical framerates
  • The longer the videos, the longer it takes to generate the combined one (though that's kinda a given)
@arilotter
arilotter / 00_warning.md
Created September 26, 2016 21:09 — forked from joepie91/00_warning.md
Asynchronous fs.exists

Important warning

You should almost never actually use this. The same applies to fs.stat.

Checking whether a file exists before doing something with it, can lead to race conditions in your application. Race conditions are extremely hard to debug and, depending on where they occur, they can lead to data loss or security holes. Using the synchronous versions will not fix this.

Generally, just do what you want to do, and handle the error if it doesn't work. This is much safer.

  • If you want to check whether a file exists, before reading it: just try to open the file, and handle the ENOENT error when it doesn't exist.
  • If you want to make sure a file doesn't exist, before writing to it: open the file using an exclusive mode, eg. wx or ax, and handle the error when the file already exists.
public class ChildClass extends ParentClass {
// no interface to fooBar
}
Verifying that +arilotter is my blockchain ID. https://onename.com/arilotter
#!/usr/bin/env python3
import sys
import os
import time
import threading
import subprocess
import fnmatch
POLL_RATE = 1 # polling rate in seconds