Skip to content

Instantly share code, notes, and snippets.

@nekoya
nekoya / network_nic_r8168.md
Created September 24, 2012 10:03
RealTekのNICドライバ問題(r8169→r8168への切り替え)
@nekoya
nekoya / examples.py
Last active December 14, 2021 09:13
PyGithub cheat sheet
from github import Github
GITHUB_TOKEN = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
g = Github(GITHUB_TOKEN)
def get_user():
"""
Returns:
{
"title": "nekoya",
"rules": [
{
"description": "backslash",
"manipulators": [
{
"conditions": [{"input_sources": [{"language": "en"}], "type": "input_source_if"}],
"from": {"key_code": "international3"},
"to": [{"key_code": "international3", "modifiers": "option"}],
import argparse
import json
import subprocess
from collections import namedtuple
def execute(arg, cwd):
proc = subprocess.Popen(
arg,
shell=True,
@nekoya
nekoya / install_jenkins.sh
Created January 27, 2015 11:40
Install Jenkins
if [ ! -f /etc/init.d/jenkins ];then
curl -L http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
echo "deb http://pkg.jenkins-ci.org/debian binary/" > /etc/apt/sources.list.d/jenkins.list
apt-get -y update
apt-get install -y jenkins
# wait jenkins http port
echo "wait Jenkins service "
while [ "`netstat -tunl|grep 8080`" = "" ];do echo -n "."; sleep 1; done
echo " ok"
@nekoya
nekoya / decrypt.py
Created March 5, 2013 07:20
Perl Crypy::CBC (Blowfish) -> Python Crypto
import base64
from Crypto.Cipher import Blowfish
from binascii import unhexlify
from struct import pack
key = unhexlify('144a6b229633360207ff9c79016fc49426f1814727b663bc39df05df9a1892073e2812df9492c1e952aac68d1ddfefba635d3a33aba21535') # "thisiskey"
iv = '123abc45'
def enc(str):
@nekoya
nekoya / private.xml
Created November 29, 2013 10:43
KeyRemap4MacBook custom XML
<?xml version="1.0"?>
<root>
<list>
<item>
<name>nekoya</name>
<list>
<item>
<name>ASCII Bracket mode</name>
<identifier>remap.nekoya_ascii_bracket_mode</identifier>
from datetime import datetime
import pytz
def dump(dt):
print '1. strftime : %s' % dt.strftime('%Y-%m-%d %H:%M')
print '2. str : %s' % dt
print '3. as utc : %s' % dt.astimezone(pytz.utc)
print '4. 3 as local : %s' % dt.astimezone(pytz.utc).astimezone(ny)
print ''
import calendar, pytz, time
from datetime import datetime
from benchmarker import Benchmarker
jst = pytz.timezone('Asia/Tokyo')
now_utc = datetime.now(pytz.utc)
now_jst = datetime.now(jst)
with Benchmarker(width=20, loop=10000) as bm:
for _ in bm('utc2utc'):