This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Retrying logic for https://egghead.io/lessons/xstate-use-xstate-null-events-and-transient-transitions-to-immediately-transition-states | |
*/ | |
const fetchMachine = Machine({ | |
id: 'fetch', | |
initial: 'idle', | |
context: { | |
tries: 0 | |
}, | |
states: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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== | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
#Prepare | |
# | |
# On brand new FreeBSD do: | |
portsnap fetch extract | |
# Otherwise do: | |
portsnap fetch update |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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. |