Skip to content

Instantly share code, notes, and snippets.

# $ jupyter notebook
# Right top, click New
# https://www.dataquest.io/blog/jupyter-notebook-tutorial/
# https://www.kaggle.com/janiobachmann/lending-club-risk-analysis-and-metrics
@ferryzhou
ferryzhou / show_youtube_dl.sh
Last active July 5, 2018 17:21
youtube download
# Download youtube to mp3
youtube-dl -f bestaudio -x --audio-format mp3 -o '%(playlist)s/%(playlist_index)s – %(title)s.%(ext)s' https://www.youtube.com/playlist?list=PLByf7LdMdgugN_3Jms9fjJpNV6rS_eB2N
# Download playlist
youtube-dl -o '%(playlist)s/%(playlist_index)s – %(title)s.%(ext)s' https://www.youtube.com/playlist?list=PLByf7LdMdgugN_3Jms9fjJpNV6rS_eB2N
# Cut videos
ffmpeg -i movie.mp4 -ss 00:00:03 -t 00:00:08 -async 1 cut.mp4
# Download from ustream to mp4 so even partially downloaded data can be used
import numpy as np
# logistic regression.
# yi = sigmoid(dot(a * xi))
def sigmoid(x):
return 1 / (1 + np.exp(-x))
N = 1000
M = 2
import numpy as np
# A linear function.
# Ax = y
# Given A and y, solve x.
# Standard L2 loss function with l2 regularization.
N = 1000
M = 2
A = np.random.random((N, M))
@ferryzhou
ferryzhou / README.md
Last active July 11, 2022 15:23
Use riot and ajax to show data from a restful api using postgrest. also use bootswatch for theme.
  1. start restful api server

postgrest "host=localhost dbname=tnews" -a $(whoami) --schema public

  1. serve the html

python -m SimpleHTTPServer 8080

@ferryzhou
ferryzhou / show_mbot_bluetooth.js
Created May 15, 2016 17:05
connect to mbot through bluetooth from nodejs
// Based on tutorial here:
// https://itp.nyu.edu/physcomp/labs/labs-serial-communication/lab-serial-communication-with-node-js/
// Examples:
// node test.js /dev/tty.Makeblock-ELETSPP
var serialport = require('serialport');
var SerialPort = serialport.SerialPort;
var portName = process.argv[2];
// turn led green
@ferryzhou
ferryzhou / google_api_go_client.go
Created November 30, 2015 04:15
google api go client initialize
// https://github.com/google/google-api-go-client
import (
"golang.org/x/net/context"
"golang.org/x/oauth2/google"
"google.golang.org/api/compute/v1"
)
func main() {
// Use oauth2.NoContext if there isn't a good context to pass in.
@ferryzhou
ferryzhou / 0_reuse_code.js
Created November 28, 2015 16:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ferryzhou
ferryzhou / go.vimrc
Created November 8, 2015 15:56
vimrc for go
execute pathogen#infect()
syntax on
filetype plugin indent on
set number
set backspace=2
set t_Co=256
set background=dark
colorscheme PaperColor
@ferryzhou
ferryzhou / create_mappings.sh
Last active August 29, 2015 14:08
get github watch events in a month
curl -XPUT 'http://localhost:9200/_template/github-watch' -d @github-watch-mappings.json