Skip to content

Instantly share code, notes, and snippets.

View loretoparisi's full-sized avatar
🐍
NightShift

Loreto Parisi loretoparisi

🐍
NightShift
View GitHub Profile
@loretoparisi
loretoparisi / emoticons.json
Created April 17, 2019 18:14
A JSON trivial list of Emoticons
{
"100": "💯",
"1234": "🔢",
"grinning": "😀",
"smiley": "😃",
"smile": "😄",
"grin": "😁",
"laughing": "😆",
"satisfied": "😆",
"sweat_smile": "😅",
@loretoparisi
loretoparisi / randomHSVPalette.js
Created April 10, 2019 16:21
Generate a random HSV palette of non overlapping colors
function randomHSVPalette(options) {
function random(min, max) {
return min + Math.random() * (max - min);
}
function HSVtoXYZ(hsv) {
var h = hsv[0];
var s = hsv[1];
var v = hsv[2];
@loretoparisi
loretoparisi / python_randomness.py
Created April 8, 2019 22:36
Python Randomness - Reproducibility isn't a requirement, it's a necessity!
# Set the seed for hash based operations in python
os.environ['PYTHONHASHSEED'] = '0'
seed=1234
# set the seed for random number generator
rn.seed(seed)
# Set the numpy seed
np.random.seed(seed)
@loretoparisi
loretoparisi / git_init_remote_origin.sh
Created April 5, 2019 19:20
Git Init from Remote Origin Master
git remote add origin https://github.com/loretoparisi/phoenix-elixir-boilerplate.git
git add *
git commit -m "Initial Import"
git push --set-upstream origin master
git push origin master
@loretoparisi
loretoparisi / phoenix_elixir_boilerplate.sh
Last active April 5, 2019 18:57
Phoenix Elixir Boilerplate: up and running in 3 minutes!
brew update
brew install elixir
mix local.hex
mix archive.install hex phx_new 1.4.3
mix phx.new hello --no-ecto
cd hello
mix phx.server
@loretoparisi
loretoparisi / set_json_encoder.py
Last active April 3, 2019 14:05
Simple JSON Set Encoder in Python
import json
class SetEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, set):
return list(obj)
return json.JSONEncoder.default(self, obj)
@loretoparisi
loretoparisi / tf_install_python36.sh
Last active March 20, 2019 11:06
Tensorflow 1.120, Python3.6, CUDA9 starting from tensorflow:tensorflow-latest-gpu (TF 1.13.0, CUDA 10, March 2019)
add-apt-repository ppa:jonathonf/python-3.6
apt-get update & apt-get install -y python3.6
curl https://bootstrap.pypa.io/get-pip.py > get-pip.py
python3.6 get-pip.py
pip3 uninstall tensorflow-gpu
pip3.6 install tensorflow-gpu==1.12.0
python3.6 -c "import tensorflow as tf; print(tf.__version__);"
@loretoparisi
loretoparisi / gist:48c4eb79be1098bc803b31a23cf8826d
Created March 16, 2019 20:32
Docker Insufficient permissions to set thread priority
Containers: 3
Running: 1
Paused: 0
Stopped: 2
Images: 93
Server Version: 18.09.2
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
@loretoparisi
loretoparisi / download_audio_file.py
Last active April 11, 2022 13:23
Download large Binary file in Python3
url="https://audio-ssl.itunes.apple.com/apple-assets-us-std-000001/AudioPreview114/v4/3a/19/2e/3a192eb6-9643-19ca-2411-78cf3f7d8434/mzaf_6193260726294400087.plus.aac.p.m4a"
CHUNK = 2 * 1024 # change buffer size depending on file size, etc.
FOUT = 'test.m4a'
response = urlopen(url) # this will get the binary file contents
with open(FOUT, 'wb') as f:
while True:
chunk = response.read(CHUNK)
if not chunk:
break
f.write(chunk)
@loretoparisi
loretoparisi / apple_music_playlists_pop.js
Last active March 9, 2019 13:31
Apple Music All Playlists
const URL = https://itunes.apple.com/us/curator/976439548#see-all/playlists
const NAME = "YOUR_NAME"
var playlist_names=$('.we-lockup__title')
var playlist_links = $('.targeted-link');
var apple_music_playlists=[];
playlist_names.each((index,elem) => {
var link = playlist_links[index];
var playlist = {};
playlist.url= $(link).attr('href')