Skip to content

Instantly share code, notes, and snippets.

View apwan's full-sized avatar

Yijie apwan

  • The University of Hong Kong
View GitHub Profile
@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
@stevenkaspar
stevenkaspar / flow.js
Last active June 2, 2019 03:07
VexFlow SVG Javascript Animation
var Note = function(options){
console.log(window);
this.StaveNote = new Vex.Flow.StaveNote(options);
this.removed = false;
/**
* moves the note right from its ORIGINAL position by x pixels
* (sets the trasform: translate(x) value to x)
*/
this.setOffsetX = (x) => {
if(this.removed){
@htp
htp / curl-websocket.sh
Last active May 14, 2024 21:24
Test a WebSocket using curl.
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@alptugan
alptugan / CONDTIONALS
Last active June 4, 2023 12:21
Sonic Pi Cheat Sheet
So, let’s flip a coin: if it’s heads, play a drum, if it’s tails, play a cymbal. Easy. We can emulate a coin flip with our one_in function (introduced in the section on randomness) specifying a probability of 1 in 2: one_in(2). We can then use the result of this to decide between two pieces of code, the code to play the drum and the code to play the cymbal:
loop do
if one_in(2)
sample :drum_heavy_kick
else
sample :drum_cymbal_closed
end
@Spencer-Easton
Spencer-Easton / exportSpreadsheet.gs
Last active March 21, 2024 00:43
Example on how to export a Google sheet to various formats, includes most PDF options
function exportSpreadsheet() {
//All requests must include id in the path and a format parameter
//https://docs.google.com/spreadsheets/d/{SpreadsheetId}/export
//FORMATS WITH NO ADDITIONAL OPTIONS
//format=xlsx //excel
//format=ods //Open Document Spreadsheet
//format=zip //html zipped
@yourtion
yourtion / BaiduBcdReader.java
Last active June 28, 2019 09:30
词库文件导出 (搜狗拼音输入法SCEL词库文件解析 、QQ拼音qpyd词库文件解析 、百度拼音输入法BCD词库文件解析 、Lingoes灵格斯电子词典LD2(LDF)文件解析)
/* 百度拼音输入法BCD词库文件解析
* Copyright (c) 2010 Xiaoyun Zhu
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@terrywbrady
terrywbrady / GoogleSpreadsheet.html
Last active May 17, 2024 07:17
Sample HTML/JS to parse a Google Spreadsheet
<!doctype html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
var spData = null;
function doData(json) {
spData = json.feed.entry;
}
@LastDragon-ru
LastDragon-ru / README.md
Created January 12, 2014 15:11
git-http-backend + nginx (RHEL/Centos)

Requirements:

  • fcgiwrap
  • spawn-fcgi
  • nginx
  • git

Repository setup (without anonymous access):

@yetithefoot
yetithefoot / stuns
Last active April 2, 2024 10:49 — forked from zziuni/stuns
STUN+TURN servers list
{url:'stun:stun01.sipphone.com'},
{url:'stun:stun.ekiga.net'},
{url:'stun:stun.fwdnet.net'},
{url:'stun:stun.ideasip.com'},
{url:'stun:stun.iptel.org'},
{url:'stun:stun.rixtelecom.se'},
{url:'stun:stun.schlund.de'},
{url:'stun:stun.l.google.com:19302'},
{url:'stun:stun1.l.google.com:19302'},
{url:'stun:stun2.l.google.com:19302'},
@eirikb
eirikb / imgur-oauth-test.html
Last active March 6, 2024 14:21
Post to imgur using oauth (api v3) on a static (no server) site
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>imgur oauth</title>
<script src="http://code.jquery.com/jquery.min.js"></script>
<script>
$(function () {
var extractToken = function(hash) {