Skip to content

Instantly share code, notes, and snippets.

View pjflanagan's full-sized avatar
🚀

Peter James Flanagan pjflanagan

🚀
View GitHub Profile
@pjflanagan
pjflanagan / split.ts
Created November 14, 2023 16:31
A util function like filter that also returns an array that doesn't match
type Split<T> = [T[], T[]];
export function split<T>(arr: T[], isMatch: (item: T) => boolean): Split<T> {
return arr.reduce<Split<T>>((rv: [T[], T[]], item: T) => {
if (isMatch(item)) {
rv[0] = [...rv[0], item];
} else {
rv[1] = [...rv[1], item];
}
return rv;
}, [[], []] as Split<T>);
@pjflanagan
pjflanagan / google-maps-react-overlay-view.tsx
Created January 19, 2023 16:44
Google Maps Overlay View with React
type PopupConfig = {
map: google.maps.Map;
content: React.Component;
position: google.maps.LatLng;
}
class Popup extends google.maps.OverlayView {
private readonly container: HTMLDivElement;
private content: ComponentChild;
private position: google.maps.LatLng;
@pjflanagan
pjflanagan / index.html
Last active January 19, 2023 17:48
HTML5 Canvas Tutorial
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML5 Canvas</title>
</head>
<body>
<canvas id="my-canvas"></canvas>
</body>
<script>
window.onload = function(){
@pjflanagan
pjflanagan / remove_events_from_ics.py
Created August 25, 2021 18:53
Python code to manually remove events from a calendar (best used for large birthday calendars)
CAL_START = """
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Birthdays
X-WR-TIMEZONE:America/New_York
X-WR-CALDESC:Imported from Facebook

Merge GoPro Nightlapse Photos To Timelapse Video

This command now has a wrapper Python project that takes out the tedious parts for you.

See: NigthPro for GoPro

ffmpeg Command

This command turns a series of images into a timelapse video.

import tweepy
import requests
execfile("../TWITTER_CREDENTIALS.py")
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.secure = True
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
var script = document.createElement('script'); script.src = "https://code.jquery.com/jquery-3.4.1.min.js"; document.getElementsByTagName('head')[0].appendChild(script);
// wait for script to load, then add and run the rest in console
function setWinnerAndMakeGame(gameElem) {
// get the teams
const teams = [];
$(gameElem).find('.DenseOutcome-content').each((_i, teamElem) => {
teams.push({
name: $(teamElem).find('.DenseOutcome-title').text(),
import os, time
from stat import *
from PIL import Image
img_ext = ["jpg","jpeg","png"]
vid_ext = ["mov","m4a","mp4","3gp"]
#IMG_19960811_0001.jpg
#VID_19960811_0001.m4a
const int in = 1,
out = 3;
boolean on = false,
switchable = true;
void setup() {
pinMode(in, INPUT);
pinMode(out,OUTPUT);
}
void loop(){
import time
bar = 50 #length of bar in characters
loading = '0%'.ljust(bar) + '100%'
print(loading)
print('[', end="")
i = 0
def load(percent):
#percent is decimal between 0 and 1 inclusive