Skip to content

Instantly share code, notes, and snippets.

@hiwonjoon
hiwonjoon / python-ffmpeg.py
Last active November 26, 2023 16:11
ffmpeg and ffprobe subprocess call in python; extract specific frame at some timepoint, extract duration of a video
import subprocess
import datetime
import numpy as np
THREAD_NUM=4
def get_video_info(fileloc) :
command = ['ffprobe',
'-v', 'fatal',
'-show_entries', 'stream=width,height,r_frame_rate,duration',
@markormesher
markormesher / doubling-algorithm.md
Last active November 5, 2023 15:06
The Doubling Algorithm for Suffix Array Construction

The Doubling Algorithm for Suffix Array Construction

I'll use x = "banana", m = 6 as an example. The suffixes are:

0:  banana
1:  anana
2:  nana
etc.

First, we'll work out R1, which is the rank of each suffix according to it's first letter only. Because we're just comparing single letters, we can do it in Theta(m) with a bucket sort. There will be some duplicates, and that's fine. We only have three different letters, so we give all of the A's a rank of 0, all of the B's a rank of 1, and all of the N's a rank of 2. We end up with this:

@MicroHank
MicroHank / event
Last active July 10, 2020 08:51
事件捕捉 (event capturing) 與事件氣泡 (event bubbling)
關於事件捕捉(下沉階段)及事件氣泡(上浮階段),終於寫出簡單的程式碼來理解這個章節的意思。
元素做事件綁定,事件捕捉是由根節點(document)往下搜尋至該元素節點內容,再由該節點內容上浮至根節點。
在 Javascript Code 裡,使用 addEventListener(eventType, handler(function), boolean) 在元素上註冊事件,
第三個參數決定事件的觸發是在捕捉階段還是氣泡階段。
以下是簡單的程式範例:
---------------------[HTML]---------------------
<html>
<head>
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@austinmarton
austinmarton / sendRawEth.c
Created February 27, 2012 08:40
Send a raw Ethernet frame in Linux
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>