Skip to content

Instantly share code, notes, and snippets.

View cocoabox's full-sized avatar

cocoabox cocoabox

View GitHub Profile
@cocoabox
cocoabox / cputop5.sh
Created August 30, 2014 13:37
CPU Top5
ps aux | tail -n+2 | sort -rk 3,4 | awk 'NR <= 5 { cpu=$3; pid=$2; $1=$2=$3=$4=$5=$6=$7=$8=$9=$10=""; printf("CPU:%-.1f \tPID:%5d : %s\n", cpu, pid, $0); }'
@cocoabox
cocoabox / twitter_emoji.html
Created August 31, 2014 15:40
ツイッター絵文字一覧 html
<!DOCTYPE HTML>
<html>
<head>
<title>hello</title>
<style>
span.hex {
display: none;
}
span.char {
display: block;
@cocoabox
cocoabox / remuxx.sh
Created December 29, 2014 11:03
remux .mkv into .mp4 (transcode audio to AAC) using ffmpeg, with progress indicator and time remaining
#!/bin/bash
PURPLE=$(tput setaf 13)
RED=$(tput setaf 1)
CYAN=$(tput setaf 14)
YELLOW=$(tput setaf 11)
GREEN=$(tput setaf 2)
NONE=$(tput sgr0)
ERASE="`tput cuu1``tput el`"
if [ -z "$1" ]; then
echo "Usage: $(basename $0) [source movie file]"
@cocoabox
cocoabox / fragment_decode.js
Last active August 29, 2015 14:12
converts fragment #aa=bb&cc=dd+ee into dictionary {"aa":"bb", "cc" : "dd ee"}
/**
* input: #hogehogehogehoge output: "hogehogehogehoge"
* input: #one/two/three output: "one/two/three"
* input: #a=1&b=2&c=hello+me output: {a:1, b:2, c:"hello me"}
* input: #a&b=2&c=hello?+me output: {a:true, b:2, c:"hello? me"}
* input: #a&b=2=3=4=5 output: {a:true, b:[2,3,4,5]}
*
* @return {string|object}
*/
function fragment_decode() {
@cocoabox
cocoabox / g_plus_pics.js
Created January 10, 2015 10:58
bookmarklet to download g+ pics in original resolution
javascript:var last_url='';var l = document.getElementsByTagName('div');var cnt = 0;for (var i = 0; i < l.length; ++i) { var s = l[i].getAttribute('style');if ('string'!== typeof s || !s) {continue;}s = s.replace(/\s+/g, '').toLowerCase(); if ((-1<s.indexOf('opacity:1;') ||-1<s.indexOf('z-index:0;'))&&s.match(/height:[0-9]+/g)&&s.match(/width:[0-9]+/g)) { var im = l[i].getElementsByTagName('img'); if (im && im.length) { for (var j = 0; j < im.length; ++j) {var u='https:' + im[j].getAttribute('src');if(u && 'string'===typeof u && u.indexOf('gstatic.com')==-1 && (u.indexOf('.jpg')>-1 || u.indexOf('.png'>-1))){u = u.replace(/w[0-9]+\-h[0-9]+/g,'w9999-h9999');if(u!=last_url){window.open(u,'img_window');last_url = u;++cnt;}} } } }}if(!cnt) {alert('SORRY');}
@cocoabox
cocoabox / js_funny_args.js
Last active August 29, 2015 14:23
python positional named arguments emulation using javascript
"use strict";
function get_args(arguments_) {
/* http://stackoverflow.com/questions/1007981/how-to-get-function-parameter-names-values-dynamically-from-javascript */
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
var ARGUMENT_NAMES = /([^\s,]+)/g;
var src = arguments_.callee.toString().replace(STRIP_COMMENTS, '');
var pars = src.slice(src.indexOf('(')+1, src.indexOf(')')).match(ARGUMENT_NAMES);
if (! pars) { pars = []; }
var i, j;
javascript:var s = document.getElementsByClassName("media-image")[0].src, v = function (p) { window.open(p.replace(/(:large$)/, ":orig")) };if (s) { v(s) } else { s =document.getElementsByClassName("media-img")[0].src; if (s) { v(s) } else { alert( "no image") }}
@cocoabox
cocoabox / twitter_img.txt
Created December 7, 2015 09:26
twitter_img.txt
javascript:var s = document.getElementsByClassName("media-image")[0].src, v = function (p) { window.open(p.replace(/(:large$)/, ":orig")) };if (s) { v(s) } else { s =document.getElementsByClassName("media-img")[0].src; if (s) { v(s) } else { alert( "no image") }}
@cocoabox
cocoabox / vaadin_sass_compiler_pom.xml
Last active December 9, 2015 06:09
vaadin sass compiler を単体で動かせる為の Maven プロジェクトファイルです to create a Vaadin Sass Compiler JAR without any dependencies (;・∀・)
<!--
HOW TO USE:
0. https://github.com/vaadin/sass-compiler からソースを取得する
get vaadin sass compiler from above
 1. このファイルで pom.xml を上書きする
  overwrite pom.xml with this file
 2. ビルドする $ mvn package
  build
 3. 出来上がり $ java -jar target/vaadin-sass-compiler-1.0.0-SNAPSHOT-jar-with-dependencies.jar
  done!
@cocoabox
cocoabox / twitter_images.bookmarklet.js
Last active August 4, 2016 13:44
ツイッターの画像を原寸大に表示する(使い方:以下のテキストをコピーして、ブラウザのツールバーに「新しいページ」→アドレス欄に貼り付ける)
javascript: var re = /^(.*?)(:[a-z]+)?$/;
[].forEach.call(document.getElementsByClassName("media-img"), function(e) {
var orig = (e.src ? e.src : "").replace(re, "$1:orig");
window.open(orig);
});
var dlg = document.getElementsByClassName("permalink-container");
if (dlg.length) {
[].forEach.call(dlg[0].getElementsByClassName("AdaptiveMedia-photoContainer"), function(div) {
[].forEach.call(div.getElementsByTagName("img"), function(img) {
var orig = (img.src ? img.src : "").replace(re, "$1:orig");