Skip to content

Instantly share code, notes, and snippets.

View st98's full-sized avatar

st98 st98

View GitHub Profile
@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');
});
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>マンデルブロ集合。</title>
<style>
canvas {
display: block;
}
</style>
/*
> debug
< function debug(fn) { [Command Line API] }
*/
function f(x) {
return x * 2;
}
function g(x) {
return Math.pow(f(x), 2);
}
@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
@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 / 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 / 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>
class Complex
constructor: (re=0, im=0) ->
if not(this instanceof Complex)
return new Complex re, im
this.re = re
this.im = im
conjugate: (other) ->
new Complex @re, -@im
add: (other) ->
[re, im] = [@re + other.re, @im + other.im]
@st98
st98 / rep_stosd.c
Last active August 29, 2015 14:22
rep stosd
// gcc -masm=intel rep_stosd.c -o a
#include <stdio.h>
char s[16] = "Hello, world!";
int main(void) {
printf("[+] %s\n", s);
asm volatile(
"mov eax, 0x44434241;"
"mov ecx, 0x2;"
"lea edi, [s];"
"rep stosd"
@st98
st98 / wakaba.js
Last active August 29, 2015 14:25
/わかば*ガール/.test('わかばばばばガール')