Skip to content

Instantly share code, notes, and snippets.

ruby -run -e httpd . -p 8000
$ ps auxf
javascript:$("img.avatar").attr("src", "https://pbs.twimg.com/profile_images/903950953459490816/1_wK5kUp_400x400.jpg")
@ahy4
ahy4 / vscode.json
Last active November 8, 2017 15:45
{
"editor.fontFamily": "'CamingoCode', 'Ricty Diminished'",
"editor.fontSize": 14,
"editor.tabSize": 2,
"editor.formatOnType": true,
"editor.cursorBlinking": "smooth",
"editor.renderWhitespace": "boundary",
"editor.renderControlCharacters": true,
"editor.renderIndentGuides": true,
"editor.renderLineHighlight": "all",
help
prefix+?
起動
% tmux
or
% tmux new-session
セッションの確認
% tmux ls
echo 192.168.3.{1..254} | xargs -P256 -n1 ping -s1 -c1 -W1 | grep ttl
@ahy4
ahy4 / dl.sh
Last active February 7, 2018 13:42
#!/bin/bash
ffmpeg -i "$1" -c copy "openrec-`date "+%Y-%m%d-%H%M%S"`.ts"
# ./dl.sh http://url.to/m3u8
# https://gist.github.com/rokugasenpai/cdaff5eac2e88e6b9efe412982e7ae31
// 5勝でOKラインになり8敗で割れる ⇒ 5勝7敗までセーフ
// であるから、求める確率は
// 4勝n敗してから5勝目をおさめる確率 (n = 0, 1, ..., 7)
// = (4勝0敗の確率 + 4勝1敗の確率 + 4勝2敗の確率 + ... + 4勝7敗の確率) × 5勝目をする確率
// $= (_4C_0p^4 + _5C_1p^4(1-p)+ _6C_2p^4(1-p)^2 + \cdots + _{11}C_7p^4(1-p)^7)\cdot p$
// ただし p は勝率とする
// nPk
const permutation = (n, k) => Array.from({length: k}, (_, i) => n - i).reduce((a, b) => a * b, 1);
window.$ = (function () {
if (Math.random() < 0.95) return $; // 影響範囲をへらしてリスク減らす
var getCallStack = function () {
try {
throw new Error("DUMMY");
} catch(e) {
return e.stack
.split(/[\r\n]+/)
.filter(function (s){
// ns.targetFnを上書きしたい
var ns = {
prop: 10
};
ns.__proto__.targetFn = function targetFn(v1, v2) {
return this.prop + v1 + v2
};
console.log(ns.targetFn(5, 3)); // => 18
var tmp1 = ns.targetFn;