Skip to content

Instantly share code, notes, and snippets.

Shusse Kaido shussekaido

Block or report user

Report or block shussekaido

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ffmpeg-throttle.txt
Reference:
https://lorenzo.mile.si/2016/07/limiting-cpu-usage-and-server-load-with-ffmpeg/
https://github.com/opsengine/cpulimit
brew install cpulimit
Run ffmpeg with:
nice -19 cpulimit -l 30 -- ffmpeg blah blah -threads 1 /tmp/yourvideo.mp4
Note that '-threads 1' needs to be the last option.
@shussekaido
shussekaido / polling.js
Created Jan 9, 2017
Use Promise to wait until polled condition is satisfied
View polling.js
function ensureFooIsSet() {
return new Promise(function (resolve, reject) {
(function waitForFoo(){
if (lib.foo) return resolve();
setTimeout(waitForFoo, 30);
})();
});
}
// http://stackoverflow.com/questions/30505960/use-promise-to-wait-until-polled-condition-is-satisfied
@shussekaido
shussekaido / koohiistroke.js
Created Nov 1, 2014
Adds kanji stroke order to the Study and Review sections of kanji.koohii.com. Works with Tampermonkey or Greasemonkey for Chrome or Firefox.
View koohiistroke.js
// ==UserScript==
// @name Kanji.koohii Stroke Order
// @namespace koohiistroke
// @description Adds kanji stroke order to the study and review sections on kanji.koohii.com
// @include http://kanji.koohii.com/study/kanji/*
// @include https://kanji.koohii.com/study/kanji/*
// @include http://kanji.koohii.com/review*
// @include https://kanji.koohii.com/review*
// @grant GM_xmlhttpRequest
// @version 1.1
@shussekaido
shussekaido / Koohii Review stroke order
Created Feb 23, 2014
Adds Kanji Stroke Order to the Review section of kanji.koohii.com. Tested in Chrome with Tampermonkey.
View Koohii Review stroke order
// ==UserScript==
// @name Kanji.koohii Stroke Order - Review section
// @namespace koohiireview
// @description Adds Kanjis Stroke Order to the Review section
// @include http://kanji.koohii.com/review*
// @include https://kanji.koohii.com/review*
// @version 1.0
// ==/UserScript==
@shussekaido
shussekaido / Remove timecodes from SRT
Created Sep 30, 2013
Creates plain text from SRT files by removing timecodes
View Remove timecodes from SRT
To simply remove timecodes (this is a long command that should be on one line):
cat episode01.srt
|cat "$@"|tr -d '\r'
|grep -v '^[0-9]*$'
|grep -v '^[0-9][0-9]:[0-9][0-9]:[0-9][0-9],[0-9][0-9][0-9] --> [0-9]'
> episode01.txt
To remove timecodes and linebreaks:
@shussekaido
shussekaido / gist:ddd94060539ef90f7eaf
Last active Jan 9, 2017
Confluence 5 on FreeBSD 9 with OpenJDK 7
View gist:ddd94060539ef90f7eaf
# 
#Prepare
# 
# On brand new FreeBSD do:
portsnap fetch extract
# Otherwise do:
portsnap fetch update
View our_setup_script.js
db = db.getSisterDB("config");
var mongosConn = db; // assume we connected to a mongos to get going
var res = null;
function check() {
printjson(res);
if( !res || !res.ok ) {
throw "check(): not ok, stopping";
View m101_hw_2.2.js
// Assign your query to a variable. To quote the assignment: "select homework documents, sort by student and then by score"
var students = db.grades./* YOUR CODE */
// Create a variable to track student_id so we can detect when it changes
var id = "";
// Loop through our query results. Each document in the query is passed into a function as 'student'
students.forEach(function (student) {
if (id !== student.student_id) { // Check if the student_id is new
db.grades./* YOUR CODE */ // If your 'students' query is correct the document with the lowest homework score is here. Remove it.
You can’t perform that action at this time.