Skip to content

Instantly share code, notes, and snippets.

View javascripter's full-sized avatar

javascripter

View GitHub Profile
@javascripter
javascripter / gist:d376c9a4f22a947c5ff8
Created May 16, 2014 12:45
a step by step execution with generators
function* gcd(a, b) {
[a, b]
if (a < b) {
var t = a;
a = b;
b = t;
}
do {
r = a % b;
#include <stdio.h>
#include <string.h>
int main(void) {
int n;
int employees[4000] = {0};
while (1) {
scanf("%d", &n);
if (!n) break;
// ==UserScript==
// @name GMEasyInstall
// @namespace http://d.hatena.ne.jp/javascripter/
// @include http*
// ==/UserScript==
function fixLink(doc) {
$$('a[href$=".user.js"]', doc)
.forEach(function(a) {
a.href += "#";
});
// ==UserScript==
// @name MDCJa2En
// @namespace http://d.hatena.ne.jp/javascripter/
// @include http://developer.mozilla.org/ja/*
// ==/UserScript==
function ja2en(doc) {
Array.forEach(doc.getElementsByClassName('new'),
function(a) {
a.href = a.href.replace("ja","en");
});
// ==UserScript==
// @name SmartLDR
// @namespace http://d.hatena.ne.jp/javascripter/
// @include http://reader.livedoor.com/reader/
// ==/UserScript==
function evalInPage(fun) {
location.href = "javascript:void (" + fun + ")()";
}
function $N(name, a)
[[i == "className" ? "class": i, a[i]]
for (i in a) if (a.hasOwnProperty(i))]
.reduce((function(elem, [attr, value])
(elem.setAttribute(attr, value), elem)),
document.createElement(name));
$N("div", {className: "foo", id: "bar"}); // <div id="bar" class="foo">
Function.prototype.bind = function bind() {
var args = Array.slice(arguments),
thisObj = args.shift(),
self = this;
return function ()
self.apply(thisObj, args.concat(Array.slice(arguments)));
};
// ==UserScript==
// @name NicoVideoAutoPlay
// @namespace http://d.hatena.ne.jp/javascripter/
// @include http://www.nicovideo.jp/watch/*
// ==/UserScript==
location.href = "javascript:" + function () {
var flvplayer = document.getElementById("flvplayer");
(function play() {
try {
(function () {
var last = null;
(function request() {
with (new XMLHttpRequest()) {
open('get', location.href, true);
send(null);
onload = function () {
if (!last || last == this.responseText) {
last = this.responseText;
setTimeout(request, 100);
// ==UserScript==
// @name All bbeta
// @namespace http://d.hatena.ne.jp/javascripter/
// @include http*
// ==/UserScript==
function replace(parent) {
Array.forEach(
parent.querySelectorAll('a[href^="http://b.hatena.ne.jp/"]'),
function (elem) {