Skip to content

Instantly share code, notes, and snippets.

View mixu's full-sized avatar

Mikito Takada mixu

View GitHub Profile
(function() {
function range(start,stop) {
var result=[];
for (var idx=start.charCodeAt(0),end=stop.charCodeAt(0); idx <=end; ++idx){
result.push(String.fromCharCode(idx));
}
return result;
};
@mixu
mixu / readme.md
Last active April 25, 2017 02:04
Benchmark node-glob (minimatch) against the case in https://research.swtch.com/glob
lebab --replace lib --transform arrow --transform for-of --transform for-each --transform arg-rest --transform arg-spread --transform obj-method --transform multi-var --transform let --transform class --transform commonjs --transform template
prettier --single-quote --trailing-comma all --bracket-spacing --write "./{test,lib}/**/*.js"
@mixu
mixu / download.js
Last active March 31, 2018 00:09
Facebook album downloader
var images = [];
function getPhoto() {
var img = document.querySelector('.spotlight');
console.log(images.length, img.src);
var hasImage = images.indexOf(img.src) !== -1
if (!hasImage) {
images.push(img.src);
var currentSrc = img.src;
document.querySelector('.snowliftPager.next').click();
<html>
<script>
var m = require("minilog")("web");
require("minilog").enable();
m.error("some err");
</script>
</html>
@mixu
mixu / command
Created October 3, 2014 00:06
Alphabetize JSON input
find ./conf -type f -name "*.json" -print | xargs -L 1 node -e "var out = '', fs = require('fs'); var out = process.argv[process.argv.length - 1]; var j = JSON.parse(fs.readFileSync(out).toString()); fs.writeFileSync(out, JSON.stringify(traverse(j), null, 2)); function traverse(j) { if (Array.isArray(j)) { return j.map(traverse); } if (typeof j !== 'object' || j === null) { return j; } var r = {}; Object.keys(j).sort().forEach(function(k) { r[k] = traverse(j[k]); }); return r; }"
@mixu
mixu / find-old-files.sh
Created September 4, 2014 21:02
Find oldest files in a git repo
git ls-tree -r --name-only HEAD | while read filename; do
echo "$(git log -1 --format="%at | %h | %an | %ad |" -- $filename) $filename"
done
@mixu
mixu / restart-hadoop.sh
Created January 3, 2014 01:13
restart hadoop
for i in `service --status-all |& grep -Po "(zookeeper|hadoop).*"`; do sudo service $i restart; done
@mixu
mixu / such-expressive.js
Created December 28, 2013 21:52
evil global very helping such expressive wow
// evil global
// very helping
// such expressive
// wow
Number.prototype.days = function() {
var i = this;
return {
from_now: function() {
var d = new Date();
@mixu
mixu / gist:7086772
Created October 21, 2013 16:31
Set viedo playback speed
document.querySelectorAll('video')[0].playbackRate = 2