Skip to content

Instantly share code, notes, and snippets.

View loretoparisi's full-sized avatar
🐍
NightShift

Loreto Parisi loretoparisi

🐍
NightShift
View GitHub Profile
script = document.createElement('script');script.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js";document.getElementsByTagName('head')[0].appendChild(script);
function download(name,jsonObject) {
var fileContents = JSON.stringify(jsonObject, null, 2);
var pp = document.createElement('a');
pp.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(fileContents));
pp.setAttribute('download', name+'.json');
pp.click();
}
df=[]
$('.m-mtk-track').each((index,item) => {
@loretoparisi
loretoparisi / english_contractions_dataset.json
Last active June 17, 2023 01:49
List of English contractions from Wikipedia
{
"ain't": "am not / is not / are not / has not / have not / did not",
"amn't": "am not",
"aren't": "are not",
"can't": "cannot",
"'cause": "because",
"could've": "could have",
"couldn't": "could not",
"couldn't've": "could not have",
"daren't": "dare not / dared not",
@loretoparisi
loretoparisi / english_contractions_dataset.js
Last active June 13, 2022 12:20
List of English contractions from Wikipedia
script = document.createElement('script');script.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js";document.getElementsByTagName('head')[0].appendChild(script);
function download(name,jsonObject) {
var fileContents = JSON.stringify(jsonObject, null, 2);
var pp = document.createElement('a');
pp.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(fileContents));
pp.setAttribute('download', name+'.json');
pp.click();
}
df={}
$( $('.wikitable')[0] ).find('tr').each((index,item) => {
@dvf
dvf / change-codec.md
Last active May 9, 2025 12:52
Enable High Quality mode on your headphones (Updated for macOS Catalina)

If you're using a high-end bluetooth headset on your Macbook Pro it's likely your mac is using an audio codec which favors battery efficiency over high quality. This results in a drastic degradation of sound, the SBC codec is the likely culprit, read more about it here.

Find out what codec you're using

  1. Play a song on your headphones
  2. Option (⌥) click the Bluetooth button at the top of your screen Inspect the Bluetooth Coded
  3. If you're using AAC or aptX, you can stop here—those are the highest quality codecs.

Change your codec to AAC or aptX

@stephenroller
stephenroller / mixout.py
Last active February 10, 2023 23:49
Example of mixout on generic modules.
#!/usr/bin/env python3
"""
Example of a generic Mixout implementation. (Lee et al., 2019).
https://arxiv.org/abs/1909.11299
Implementation by Stephen Roller (https://stephenroller.com).
Updated 2020-02-10 to include 1/(1 - p) correction term. Thanks to
Cheolhyoung Lee for making this correction.
import logging
import tracemalloc
from tornado.web import RequestHandler, HTTPError
class MemTraceHandler(RequestHandler):
def post(self) -> None:
action = self.get_argument('action')
nframe = self.get_argument('nframe', "6")
@loretoparisi
loretoparisi / longest_subsequence.py
Last active May 30, 2019 12:25
Longest Increasing Subsequence with Linear and Bisect (Binary) Search - http://research.variancia.com/unl-aligner/
def longest_subsequence_bisect(seq, mode='strictly', order='increasing',
key=None, index=False):
"""
>>> longest_subsequence_bisect([1,2,3,4,5,6,7,2,2,2,2,2,5,1,7,8])
Return the longest increasing subsequence of `seq`.
Parameters
----------
@yochze
yochze / Dockerfile
Last active January 31, 2021 16:41
How to compile TensorFlow 1.12 on Ubuntu 16.04 using Docker
FROM nvidia/cuda:9.0-base-ubuntu16.04
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cuda-command-line-tools-9-0 \
cuda-cublas-dev-9-0 \
cuda-cudart-dev-9-0 \
cuda-cufft-dev-9-0 \
cuda-curand-dev-9-0 \
cuda-cusolver-dev-9-0 \
@loretoparisi
loretoparisi / doc2tokens.js
Created March 8, 2019 17:57
JavaScript - calculate Start and End of a Word in a Sentence of a Document
var text = "Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit,\nsed do eiusmod tempor incididunt ut labore et dolore magna aliqua"
sentences = text.split(/\n/);
var doc = {};
doc.sentences = [];
for (var i = 0; i < sentences.length; i++) {
var sentence = sentences[i];
var words = sentence.split(/\s+/)
var sent = {}
sent.tokens = [];
@apal21
apal21 / S3 getObject async-await.js
Last active March 20, 2024 19:47
AWS S3 getObject using async/await
const s3 = new AWS.S3(accessparams);
(async () => {
try {
const file = await s3
.getObject({ Bucket: 'BUCKET-NAME', Key: 'path/to/your/file' })
.promise();
console.log(file.Body);
} catch (err) {
console.log(err);