Skip to content

Instantly share code, notes, and snippets.

$ # 任意の <PREFIX> から始まるブランチを一括削除する
$ git branch | grep -E 'PREFIX.' | xargs -I % git branch -d %
@doxas
doxas / dbm.sh
Last active March 10, 2021 02:26
delete branch --marged
$ # master と develop を除く merge 済みのブランチを一括削除する
$ git branch --merged master | grep -vE '^\*|master$|develop$' | xargs -I % git branch -d %
precision mediump float;
uniform sampler2D textureUnit;
uniform vec2 invResolution; // 1.0 / resolution
const float REDUCE_MIN = 1.0 / 128.0;
const float REDUCE_MUL = 1.0 / 8.0;
const float SPAN_MAX = 8.0;
const vec3 LUMA = vec3(0.299, 0.587, 0.114);
/**
* @param {vec2} coord - base texture coord
* @param {vec2} view - resolution of viewport
* @param {vec2} resource - resolution of resource
* @return {vec2} like a `background-size: cover` on css
*/
vec2 cover(vec2 coord, vec2 view, vec2 resource){
vec2 ratio = vec2(
min((view.x / view.y) / (resource.x / resource.y), 1.0),
min((view.y / view.x) / (resource.y / resource.x), 1.0)
function uuid(){
// https://github.com/GoogleChrome/chrome-platform-analytics/blob/master/src/internal/identifier.js
const chars = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.split('');
for(let i = 0, j = chars.length; i < j; i++){
switch(chars[i]){
case 'x':
chars[i] = Math.floor(Math.random() * 16).toString(16);
break;
case 'y':
chars[i] = (Math.floor(Math.random() * 4) + 8).toString(16);
copyToClipboard(str){
const t = document.createElement('textarea');
t.value = str;
document.body.appendChild(t);
t.select();
document.execCommand('copy');
document.body.removeChild(t);
}
let isMobileDevice = (
ua.indexOf('android') > -1 ||
ua.indexOf('iphone') > -1 ||
ua.indexOf('ipod') > -1 ||
ua.indexOf('ipad') > -1 ||
(ua.indexOf('macintosh') > -1 && 'ontouchend' in document)
);
function powerOfTwo(v){
return (v & (v - 1)) === 0;
}
function nearPowerOfTwo(v){
if(v <= 0){return 0;}
let w = v;
w = w | (w >> 1);
w = w | (w >> 2);
w = w | (w >> 4);
w = w | (w >> 8);
function copyToClipboard(stringData){
let t = document.createElement('textarea');
t.value = stringData;
document.body.appendChild(t);
t.select();
document.execCommand('copy');
document.body.removeChild(t);
}
@doxas
doxas / clipboard.js
Created July 16, 2019 10:20
copy to clipboard
let t = document.createElement('textarea');
t.value = 'hogepiyo';
document.body.appendChild(t);
t.select();
document.execCommand('copy');
document.body.removeChild(t);