Skip to content

Instantly share code, notes, and snippets.

View st98's full-sized avatar

st98 st98

View GitHub Profile
@st98
st98 / a.py
Last active August 29, 2015 14:22
DOMContentLoaded
import time
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return '''
<!doctype html>
<body>
<head>
<title>DOMContentLoaded</title>
@st98
st98 / t.js
Created June 6, 2015 15:03
DOMCharacterDataModified
javascript:
var a = [
prompt('title'),
"document.getElementById('h').addEventListener('DOMCharacterDataModified', function (s) { document.title = s.newValue; })"
];
var t = 'data:text/html;charset=utf-8,<!doctype html><meta charset="utf-8"><title>$1</title><h1 id="h" contenteditable>$1</h1><script>$2</script>';
location.href = t.replace(/[$]\d+/g, function (s) { return a[parseInt(s.slice(1), 10) - 1]; });
@st98
st98 / l.js
Created June 2, 2015 07:11
ES CTF の Log でアレ。
Array.prototype.reduce.call(document.querySelectorAll('.narrow li code'), function (p, c) {
var s = c.childNodes[0].nodeValue;
if (!(s in p))
p[s] = 0;
p[s]++; return p;
}, {});
@st98
st98 / bit_length.py
Last active August 29, 2015 14:22
int.bit_length()
n = int(1e6)
def f(x):
l = 0
while x != 0:
l += 1
x >>= 1
return l
f(n) # 20
/*
> debug
< function debug(fn) { [Command Line API] }
*/
function f(x) {
return x * 2;
}
function g(x) {
return Math.pow(f(x), 2);
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>マンデルブロ集合。</title>
<style>
canvas {
display: block;
}
</style>
@st98
st98 / a.js
Created March 7, 2015 09:06
ニコニコ動画の ?ref=… を消すヤツ。
Array.prototype.forEach.call(document.querySelectorAll('a'), function (a) {
a.href = a.href.replace(/(sm\d+)\?.+/, '$1');
});
@st98
st98 / nicos.js
Last active August 29, 2015 14:16
ニコニコ動画のマイリストの合計再生時間を出力するヤツ。
(function () {
if (!(String.prototype.repeat)) {
String.prototype.repeat = function (n) {
if (n < 0) throw RangeError('Invalid repeat count');
return Array(n + 1).join(this);
};
}
function zfill(s, n) {
if (s.length >= n) return s;
return ('0'.repeat(n) + s).slice(-n);
b = /b/
#####
/a#{b.source}c/.source # => 'a#{b.source}c'
///a#{b.source}c///.source # => 'abc'
@st98
st98 / delete.js
Created February 18, 2015 10:13
delete。
function C() {}
C.prototype.m = function () { return 'm'; };
/////
var a = new C();
a.m(); // => 'm'
/////
delete a.m;
a.m(); // => 'm'
/////
delete C.prototype.m;