Skip to content

Instantly share code, notes, and snippets.

View mixu's full-sized avatar

Mikito Takada mixu

View GitHub Profile
@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 / 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();
(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 / 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
@mixu
mixu / extract.js
Created October 11, 2013 21:47
extract URLs from a stream (newline-separated)
#!/usr/bin/env node
/*
Installation: npm install linewise
Usage:
cat urls.json | node extract.js > urls.txt
Assuming urls.json contains lines with zero or more urls per line, this will
extract all the urls and produce a file with one url per line.
@mixu
mixu / gist:6258404
Created August 17, 2013 19:36
Get a JSON structure with all your open tabs
// Needs to be run in the context of an extension with the "tabs" permission.
chrome.tabs.query({}, function(tabs) {
var byWindow = {};
tabs.forEach(function(t) {
if(!byWindow[t.windowId]) {
byWindow[t.windowId] = []
}
byWindow[t.windowId].push(t.url);
console.log(JSON.stringify(byWindow, null, 2));