Skip to content

Instantly share code, notes, and snippets.

View n0ts's full-sized avatar
🏠
Working from home

Naoya Nakazawa n0ts

🏠
Working from home
  • Freelancer
  • Tokyo, Japan
  • X @n0ts
View GitHub Profile
@n0ts
n0ts / test-dd-threadstats.py
Created September 13, 2016 03:19
Datadog Agent ThreadStats sample code
# test for Threadstat - a tool for collecting metrics in high performance applications
# http://datadogpy.readthedocs.io/en/latest/#datadog-threadstats-module
import random, time, os, yaml
# Configure the module according to your needs
from datadog import initialize
from datadog.util.config import get_config
# initialize(api_key=None, app_key=None, host_name=None, api_host=None, statsd_host=None, statsd_port=None, statsd_use_default_route=False, **kwargs)
config = get_config()
@n0ts
n0ts / my-net-tcp-timewait.patch
Last active October 19, 2016 06:33
TCP_TIMEWAIT_LEN patch
--- ./include/net/tcp.h-org 2016-10-18 18:14:54.051023657 +0900
+++ ./include/net/tcp.h 2016-10-19 13:51:41.959816976 +0900
@@ -111,8 +111,8 @@
* initial RTO.
*/
-#define TCP_TIMEWAIT_LEN (60*HZ) /* how long to wait to destroy TIME-WAIT
- * state, about 60 seconds */
+#define TCP_TIMEWAIT_LEN (1*HZ) /* how long to wait to destroy TIME-WAIT
+ * state, about 1 second */
@n0ts
n0ts / set-aws-ec2-id-use-longer.sh
Last active December 6, 2016 06:17
Set AWS EC2 ID longer for all region
for r in $(aws ec2 --region us-east-1 describe-regions | jq -r ".Regions[] | .RegionName"); do for i in "instance" "reservation" "volume" "snapshot"; do aws --debug --region $r ec2 modify-id-format --resource $i --use-long-ids; done; done
@n0ts
n0ts / get-aws-ec2-id-use-longer.sh
Created December 6, 2016 06:18
Get AWS EC2 ID longer for all region
for r in $(aws --region us-east-1 ec2 describe-regions | jq -r ".Regions[] | .RegionName"); do aws --region $r ec2 describe-id-format; done
@n0ts
n0ts / brew-cask-upgrade.sh
Last active April 15, 2020 15:30
brew cask upgrade
#!/bin/bash
for c in $(brew cask list); do
info=$(brew cask info $c)
installed_ver=$(echo "$info" | cut -d$'\n' -f1 | tr -d ' ' | cut -d':' -f 2)
current_ver=$(echo "$info" | cut -d$'\n' -f3 | cut -d' ' -f 1 | rev | cut -d'/' -f 1 | rev)
if [ "$installed_ver" != "$current_ver" ]; then
echo "$c is installed '$installed_ver', current is '$current_ver'"
brew cask reinstall $c
fi
IFS=$'\n'
for i in $(find . -type f -name '*.png'); do
dir=$(dirname "$i")
file=$(basename "$i" .png)
sips -s format jpeg $i --out "$dir/$file.jpg"
done
@n0ts
n0ts / gist:c847f3d13142ab092043400a92e3df50
Created June 19, 2017 14:04
kumogata-tempate exanple
#
# iam-and-s3
#
require 'aws-sdk'
$: << File.dirname(__FILE__)
### common local library
require 'meta'
require 'aws'
https://www.dropbox.com/s/er3bofqrgnl6wue/Emacs-24.3.app.zip?dl=0
@n0ts
n0ts / .gitconfig
Last active August 2, 2022 07:25
Git config alias
[alias]
rc = rebase --continue
ft = fetch
ftp = fetch --tags --prune
pr = pull --rebase
co = checkout
wd = diff --word-diff
br = branch
so = remote show origin
kc = commit
@n0ts
n0ts / install.out
Last active October 17, 2017 23:09
nginx-full with mruby-module
$ brew install nginx-full --with-mruby-module --no-sandbox
==> Installing nginx-full from homebrew/nginx
==> Downloading https://nginx.org/download/nginx-1.12.1.tar.gz
######################################################################## 100.0%
==> git init
==> git submodule init
==> git submodule update
==> git add build_config.rb
==> git commit -m 'build_config.rb'
Last 15 lines from ~/Library/Logs/Homebrew/nginx-full/05.git: