Skip to content

Instantly share code, notes, and snippets.

View cocoabox's full-sized avatar

cocoabox cocoabox

View GitHub Profile
@cocoabox
cocoabox / to-mp4-baseline.sh
Created November 29, 2019 09:25
to-mp4-baseline.sh
# .bashrc
# =======
to-mp4-baseline ()
{
if [ -z "$2" ]; then
OUT="$1.mp4";
else
OUT="$2";
fi;
if [ -f "$OUT" ]; then
@cocoabox
cocoabox / twitter-block-current-user.js
Last active November 25, 2019 06:46
twitter-block-current-user.js
/**
* ユーザープロフィールが開いた状態で実行すると
* そのユーザーをブロックする
* @param {DOMElement} document
* @return {Promise<>}
* 成功した場合Resolve(引数なし)する
*/
function block_user(document=window.document) {
function wait_for_element(query, timeout_ms=1100) {
return new Promise((resolve, reject) => {
@cocoabox
cocoabox / bash-progress-bar.sh
Last active October 25, 2019 01:24
bash progress bar
#!/bin/bash
# demo : https://twitter.com/cocoamatic/status/1187539670214688768
BAR_LENGTH=50 # progress bar width
make_progress_bar() {
# $1 : progress
# $2 : total
# example : BAR=$(make_progress_bar 66 200)
PERCENT=$(awk -vn=$1 'BEGIN{printf("%.2f%%", 100*n/'$2')}')
#ifndef ESP_IDF_TEMPLATE_MQTT_APP_HPP
#define ESP_IDF_TEMPLATE_MQTT_APP_HPP
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "defines.h"
#define CONFIG_LOG_DEFAULT_LEVEL ESP_LOG_DEBUG
#!/usr/bin/env node
/* prints out :
........
..@@@@..
.@....@.
.@....@.
.@....@.
.@....@.
.@....@.
.@....@.
@cocoabox
cocoabox / mercari-fetch.sh
Created August 11, 2019 04:15
mercari fetch
curl 'https://www.mercari.com/jp/search/?keyword=%E4%BF%A1%E5%8F%B7%E6%A9%9F+LED' -H 'accept-encoding: gzip, deflate, br' \
| gunzip -c \
| hxnormalize -x \
| hxselect -s "\n\n\n" 'section.items-box'
@cocoabox
cocoabox / change-ime.sh
Created June 26, 2019 04:19
mac OS change active keyboard layout with shell script
#!/bin/bash
HIRAGANA="ひらがな (Google)"
US="U.S."
change_ime() {
read -r -d '' SCRIPT <<End
tell application "System Events" to tell process "SystemUIServer"
tell (1st menu bar item of menu bar 1 whose value of attribute "AXDescription" is "text input")
return {its value, click, click menu 1's menu item "$1"}
end tell
@cocoabox
cocoabox / tailf-aws-cloudwatch-log.sh
Created June 13, 2019 10:21
tail follow aws cloudwatch log
#!/bin/bash
set -e
LOG_GROUP_NAME="$1"
LOG_STREAM_NAME="$2"
if [ -z "$LOG_GROUP_NAME" -o -z "$LOG_STREAM_NAME" ]; then
echo "usage : $0 [LOG_GROUP_NAME] [LOG_STREAM_NAME]">&2
exit 1
fi
@cocoabox
cocoabox / python-multiprocess-example.py
Created June 12, 2019 15:23
python multi-process pool example
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# computes CRC of each file in current working directory (including subdirectories)
# usage: python3 python-multiprocess-example.py
#
import sys
import os
import glob
import zlib
@cocoabox
cocoabox / circlet-princess.js
Created May 5, 2019 10:18
サークレットプリンセスのデータが欲しいので(ry
// サークレットプリンセスのデータが欲しいので(ry
//
// 使い方
//
// 0. ゲームを立ち上げる : http://pc-play.games.dmm.com/play/circlet_princess/
// 1. ゲーム起動中に XHR Breakpoint (Pause on any URL) を付ける
// 2. なにかする(e.g. ガチャ画面に移動)と、Debuggerが立ち上がる
// 3. JS コンソールに以下を入力する
//
// let w = window.open(); w.FS = FS; w.that = this;