Skip to content

Instantly share code, notes, and snippets.

View loisaidasam's full-sized avatar
🙌
🙌

Loisaida Sam loisaidasam

🙌
🙌
View GitHub Profile
@loisaidasam
loisaidasam / git-find-large-files
Created March 15, 2019 20:10
Shows you the largest objects in your repo's pack file.
#!/bin/bash
# git-find-large-files
# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see https://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
# @see https://stackoverflow.com/questions/10622179/how-to-find-identify-large-commits-in-git-history/10622293#10622293
# @author Antony Stubbs
@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 / 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
@loisaidasam
loisaidasam / histogram.py
Last active February 5, 2019 18:58
Extensible script for generating a histogram using `matplotlib`
import argparse
import cPickle
import json
import math
import os.path
import matplotlib.pyplot as plt
@loisaidasam
loisaidasam / threading_test.py
Last active January 25, 2019 20:49
Examining shared mutable objects in threading
import random
import threading
import time
class MyObject(object):
thread_id = None
@loisaidasam
loisaidasam / pipy-check
Last active January 23, 2019 16:18
Check the current version of a lib on pypi
#!/bin/bash
###
# Check the current version of a lib on pypi
#
# https://gist.github.com/loisaidasam/2cb9bcc32312ca673c933ef07cdc706f
#
# Requires `curl` and [pup](https://github.com/ericchiang/pup)
###
@loisaidasam
loisaidasam / 1_problem.py
Last active October 5, 2018 18:10
Python help! How to make a static, yet dynamic, property in a base class?
SERVICE_ID_TACO_BELL = 1
SERVICE_ID_T_MOBILE = 2
SERVICE_NAMES = {
SERVICE_ID_TACO_BELL: "Taco Bell",
SERVICE_ID_T_MOBILE: "T-Mobile",
}
class BaseService(object):
@loisaidasam
loisaidasam / required_subclass_property.py
Created October 1, 2018 16:58
Requiring a Python class property to be explicitly set in its subclasses
# Base class
In [1]: class Foo(object):
...: @property
...: def bar(self):
...: raise NotImplementedError
...:
# Subclass 1, with property explicitly set
In [2]: class Foof(Foo):
...: bar = "taco"
@loisaidasam
loisaidasam / boolean_ordering.txt
Last active September 24, 2018 21:02
The truth about boolean ordering in Postgres
master=> SELECT * FROM (VALUES (1, true), (2, false), (3, null)) AS t (id,value);
id | value
----+-------
1 | t
2 | f
3 |
(3 rows)
master=> SELECT * FROM (VALUES (1, true), (2, false), (3, null)) AS t (id,value) order by value;
id | value
@loisaidasam
loisaidasam / get-all-the-emojis.sh
Created August 13, 2018 18:16
Get a list of ALL THE EMOJIS!
#!/bin/bash
# Via https://github.com/iamcal/emoji-data
# Requires jq
# https://stedolan.github.io/jq/
curl -Ss "https://raw.githubusercontent.com/iamcal/emoji-data/master/emoji.json" | jq '[.[] | .short_name]'