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 / gennerate_passwd.py
Created February 7, 2014 07:22
Generate password
from crypt import crypt
from random import choice
import string
import sys
salt_pop = string.letters + string.digits + '.' + '/'
salt = ''
for i in range(8):
salt = salt + choice(salt_pop)
@n0ts
n0ts / get_chef_packages.rb
Created February 10, 2014 12:39
Get Chef Packages
#
# get_packages.rb <el5|el6|deb>
#
require 'net/http'
require 'rexml/document'
case ARGV[0]
when 'el5', 'el6', 'deb'
package = ARGV[0]
else
num calls time self name
-----------------------------------------------------------------------------------
1) 1 205.59 205.59 71.91% 205.59 205.59 71.91% rbenv
2) 4 40.86 10.21 14.29% 40.86 10.21 14.29% compaudit
3) 2 79.44 39.72 27.79% 38.58 19.29 13.50% compinit
4) 1 0.29 0.29 0.10% 0.29 0.29 0.10% bashcompinit
5) 2 0.22 0.11 0.08% 0.22 0.11 0.08% compdef
6) 1 0.21 0.21 0.07% 0.21 0.21 0.07% is-at-least
7) 1 0.16 0.16 0.05% 0.07 0.07 0.03% complete
8) 1 0.05 0.05 0.02% 0.05 0.05 0.02% exists
@n0ts
n0ts / gist:10645605
Created April 14, 2014 12:59
tomahawk on CentOS 5
$ tomahawk -h h1 uptime
Traceback (most recent call last):
File "/usr/bin/tomahawk", line 4, in ?
from pkg_resources import require; require('tomahawk==0.7.0')
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2479, in ?
working_set.require(__requires__)
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 585, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 483, in resolve
@n0ts
n0ts / gist:10712912
Created April 15, 2014 08:13
256_colors.sh
# show 256 terminal colors
for i in {0..255} ; do
printf "\x1b[38;5;${i}mcolour${i}\n"
done
@n0ts
n0ts / gist:11359549
Created April 28, 2014 01:17
usbhid.sh
#!bin/sh
echo -n "5-1:1.0" > /sys/bus/usb/drivers/usbhid/unbind
echo -n "5-1:1.0" > /sys/bus/usb/drivers/usbrh/bind
echo -n "5-2:1.0" > /sys/bus/usb/drivers/usbhid/unbind
echo -n "5-2:1.0" > /sys/bus/usb/drivers/usbrh/bind
ls /proc/usbrh
@n0ts
n0ts / user_agent.yml
Last active August 29, 2015 14:00
User Agent
iPhone 5s:
carrier: SoftBank
ua: Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53
width: 640
height: 1136
Nexus 5:
carrier: Others
ua: Mozilla/5.0 (Linux; Android 4.4.2; Nexus 5 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.105 Mobile Safari/537.36
width: 1080
height: 1920
@n0ts
n0ts / remove-old-kernel.sh
Created May 7, 2014 09:51
Remove old kernel
sudo apt-get remove --purge $(dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')
@n0ts
n0ts / gist:55c8650985cb519355c2
Last active August 29, 2015 14:02
brew install --powerline --vim-powerline ricty
...
==> fontforge -lang=py -script /private/tmp/ricty-JOuT/Ricty-3.2.3/scripts/powerline-fontpatcher [] Ricty-Bold.tt
Executable based on sources from 14:57 GMT 31-Jul-2012-D.
Library based on sources from 14:57 GMT 31-Jul-2012.
usage: powerline-fontpatcher [-h] [--no-rename] [--source-font font]
font [font ...]
powerline-fontpatcher: error: argument font: can't open '[]': [Errno 2] No such file or directory: '[]'
READ THIS: https://github.com/Homebrew/homebrew/wiki/troubleshooting
If reporting this issue please do so at (not Homebrew/homebrew):
@n0ts
n0ts / gist:3f6b95dec568c9674163
Created September 17, 2014 07:30
AWS EC2 create-tags
for i in `aws ec2 describe-security-groups | jq -r '@csv "\(.SecurityGroups[] | [.GroupId, .GroupName])"'`; do aws ec2 create-tags --resources `echo $i | cut -d ',' -f 1 | tr -d '"'` --tags Key=Name,Value=`echo $i | cut -d ',' -f 2 | tr -d '"'` ; done