Skip to content

Instantly share code, notes, and snippets.

View loisaidasam's full-sized avatar
🙌
🙌

Loisaida Sam loisaidasam

🙌
🙌
View GitHub Profile
@loisaidasam
loisaidasam / README.md
Created January 31, 2020 20:45
How often can we celebrate someone's birthday in the office?

Given a certain amount of employees in an office, how many weeks of the year should it be reasonable to celebrate birthdays?

Assumptions:

  • there are ~200 employees in this office
  • there are 52 weeks in the year
  • there is an equal probability of each employee being born on any of the 52 weeks

Here are 20 trials:

@loisaidasam
loisaidasam / README.md
Last active December 2, 2019 19:07
Bookmarklet: Strava - Open Group Activities

Bookmarklet: Strava - Open Group Activities

In Strava, when you go on a bike ride with other folks, it groups your activities together.

Use this bookmarklet to open up the activities of all of the other people you rode bikes with in separate tabs.

To create the bookmarklet

  • Create a new browser bookmark
  • For location, paste in the contents of bookmarklet.js
@loisaidasam
loisaidasam / dcoms.csv
Last active November 18, 2019 15:48
The 103 DCOMs now available on Disney+, scraped from https://www.buzzfeed.com/laurengarafano/disney-plus-dcoms using `pup`
title year
Adventures in Babysitting 2016
Alley Cats Strike 2000
Avalon High 2010
Bad Hair Day 2015
Brink! 1998
Buffalo Dreams 2005
Cadet Kelly 2002
Camp Rock 2008
Camp Rock 2: The Final Jam 2010
@loisaidasam
loisaidasam / nytimes-xword-scrape.py
Created October 20, 2019 19:44
Grab the latest NY Times Crossword puzzle
#!/usr/bin/env python
"""Grab the latest NY Times Crossword puzzle
TODO: Figure out how to get today's puzzle - for some reason this grabs yesterday's
"""
import os
import re
import time
#!/bin/bash
# Solver for https://permanent-redirect.xyz
# Saves HTML pages to `pages/` dir
page="$1";
if [ -z "$page" ]
then
echo "Pass a starting page!";
exit 1;
@loisaidasam
loisaidasam / picblast.sh
Last active August 2, 2019 15:07 — forked from bwhitman/picblast.sh
Make an audio collage out of your live photos
#!/bin/bash
mkdir /tmp/picblast
cd ~/Pictures/Photos\ Library.photoslibrary
for i in $(find . | grep jpegvideocompl)
do
ffmpeg -i $i /tmp/picblast/${i:(-8)}.wav
done
@loisaidasam
loisaidasam / wilson.py
Last active July 23, 2019 19:18
Python implementation - Lower bound of Wilson score confidence interval for a Bernoulli parameter
"""
Python implementation - Lower bound of Wilson score confidence interval for a Bernoulli parameter
- http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
- https://news.ycombinator.com/item?id=15131611
- https://stackoverflow.com/questions/10029588/python-implementation-of-the-wilson-score-interval/45965534
- https://stackoverflow.com/questions/10029588/python-implementation-of-the-wilson-score-interval/45965534#45965534
"""
import math
@loisaidasam
loisaidasam / would-you-rather
Last active March 5, 2019 15:53
Would You Rather (via rrrather.com API, using curl/jq)
#!/bin/bash
jq_str='(.title + ": " + .choicea + " OR " + .choiceb + " - " + .link + " (" + (.votes|tostring) + " votes)")'
curl -Ss "https://www.rrrather.com/botapi" | jq -r "$jq_str"
@loisaidasam
loisaidasam / postgres_queries_and_commands.sql
Last active February 15, 2019 22:19 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (9.2+)
SELECT pid, age(clock_timestamp(), query_start), usename, state, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start asc;
-- or if your query is very long/verbose
SELECT pid, age(clock_timestamp(), query_start), usename, state, substring(query, 1, 100)
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@loisaidasam
loisaidasam / currently_playing.txt
Created February 6, 2019 16:26
OSX/Applescript - get artist / title of the current track playing on Spotify
$ osascript -e "if application \"Spotify\" is running then tell application \"Spotify\" to get artist of current track & \" - \" & name of current track"
Tirzah - Fine Again