Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
On vacation

Kawa Kokosawa kawa-kokosowa

🌴
On vacation
View GitHub Profile
@kawa-kokosowa
kawa-kokosowa / loopback.sh
Created Jun 24, 2018
Allows you to output sound based on the line-in
View loopback.sh
#!/bin/sh
pactl load-module module-loopback latency_msec=1
@kawa-kokosowa
kawa-kokosowa / python-style-nuance.md
Last active Dec 20, 2017
Lily's Python Style: The particularities I've learned over the years
View python-style-nuance.md

Lily's Nuanced Python Style

This style guide elaborates on pycode-style.

Syntax

When to use quotes...

  • ''' is for string values.
  • """ is for docstrings.
@kawa-kokosowa
kawa-kokosowa / jaccard_similarity_bags.py
Created Nov 23, 2017
Jaccard Similarity of Bags (python3; builtin only)
View jaccard_similarity_bags.py
"""Jaccard Similarity of Bags
Using artificial restriciton of using only builtin Python 3 only.
"""
import doctest
def multiset_intersection_cardinality(x: list, y: list) -> int:
@kawa-kokosowa
kawa-kokosowa / jaccard_similarity.py
Last active Nov 25, 2017
Jaccard Similarity Function in Python 3 (builtins only)
View jaccard_similarity.py
"""Jaccard similarity of two sets using builtin Python 3 only."""
import doctest
def jaccard_similarity(x: set, y: set) -> float:
"""Get the Jaccard similarity of two sets.
Example:
>>> jaccard_similarity({1,2,3,4}, {2,3,5,7})
@kawa-kokosowa
kawa-kokosowa / card_combos.py
Last active Nov 24, 2017
find combinations of two playing cards when summed equal that value
View card_combos.py
"""Find all the combinations of two cards being added
to equal a range of values 2-26, because 2 is the lowest
value that has a combination, and 26 is the highest value
which has a combination.
King 13
Queen 12
Jack 11
Ace 1
@kawa-kokosowa
kawa-kokosowa / sync-youtube.sh
Last active Mar 3, 2016
Sync music on YouTube to Local Drive with youtube-dl
View sync-youtube.sh
#!/bin/zsh
# Sync a youtube playlist as mp3
#
# Requires youtube-dl: brew install youtube-dl
#
# Max quality.
youtube-dl -o "/Users/lillianlemmer/Music/Youtube/%(title)s.%(ext)s" \
--extract-audio --audio-format mp3 --audio-quality 0 \
--download-archive ~/.cache/youtube-dl/archive -q \
@kawa-kokosowa
kawa-kokosowa / model.html
Last active Dec 4, 2015
Hackday Challenge
View model.html
<html>
<head>
<style>
.wowimsocool {
display: block;
width: 632px;
height: 836px;
background: #000;
background-image: linear-gradient(to right, rgba(255, 0, 0, 255), rgba(255, 0, 0, 255)),
linear-gradient(to right, rgba(0, 255, 0, 255), rgba(0, 255, 0, 255)),
@kawa-kokosowa
kawa-kokosowa / astversion.py
Last active Nov 16, 2015
Retreive __version__ from a package's __init__.py, without executing or using regular expressions.
View astversion.py
"""Demo the ability to use Abstract Syntax Trees to
retrieve the value of __version__ from a package's
__init__.py, without executing __init__.py or using
regular expressions.
Works in Python 2 and Python 3.
See Also:
* https://greentreesnakes.readthedocs.org/en/latest/tofrom.html
* http://eli.thegreenplace.net/2009/11/28/python-internals-working-with-python-asts/