Skip to content

Instantly share code, notes, and snippets.

@tracek
tracek / librosa_parallel.py
Created February 19, 2019 06:24
Running librosa parallel for loops with multiprocessing and joblib
# The script illustartes stunning difference on my machine with processing of signal with multiprocessing and joblib.
# The slowness of multiprocessing is likely caused by oversubscription
import time
import numpy as np
import librosa
from joblib import Parallel, delayed
from functools import partial
from multiprocessing import Pool
@erogol
erogol / tts_example.ipynb
Last active July 19, 2025 20:07
TTS_example.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@guangningyu
guangningyu / random_forest.py
Created July 14, 2017 09:45
Reference: [How to Implement Random Forest From Scratch in Python](http://machinelearningmastery.com/implement-random-forest-scratch-python/)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import copy
from random import seed
from random import randrange
from math import sqrt
'''
@syedrakib
syedrakib / RSA_example.py
Last active June 21, 2024 19:48
An example of asymmetric encryption in python using a public/private keypair - utilizes RSA from PyCrypto library
# Inspired from http://coding4streetcred.com/blog/post/Asymmetric-Encryption-Revisited-(in-PyCrypto)
# PyCrypto docs available at https://www.dlitz.net/software/pycrypto/api/2.6/
from Crypto import Random
from Crypto.PublicKey import RSA
import base64
def generate_keys():
# RSA modulus length must be a multiple of 256 and >= 1024
modulus_length = 256*4 # use larger value in production
@tasdikrahman
tasdikrahman / python_tests_dir_structure.md
Last active February 10, 2025 22:15
Typical Directory structure for python tests

A Typical directory structure for running tests using unittest

Ref : stackoverflow

The best solution in my opinion is to use the unittest [command line interface][1] which will add the directory to the sys.path so you don't have to (done in the TestLoader class).

For example for a directory structure like this:

new_project

├── antigravity.py

@fuyufjh
fuyufjh / cheatsheet.py
Last active November 14, 2024 03:43
My Python Cheatsheet
Python Cheatsheet
=================
################################ Input & Output ###############################
name = input('please enter your name: ')
print('hello,', name)
ageStr = input('please enter your age: ')
age = int(ageStr)
@franzwong
franzwong / python_cheatsheet.md
Last active August 19, 2021 10:31
Python cheatsheet

Python cheatsheet

  • for loop
for i in xrange(10):
  print i
@mizuy
mizuy / python_tips.rst
Created May 8, 2011 17:53
Python Programming Tips