Skip to content

Instantly share code, notes, and snippets.

import argparse
import json
import subprocess
from collections import namedtuple
def execute(arg, cwd):
proc = subprocess.Popen(
arg,
shell=True,
{
"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"}],
@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:
redis-server --port 6381 --cluster-enabled yes --cluster-config-file ~/rediscluster/nodes1.conf
redis-server --port 6382 --cluster-enabled yes --cluster-config-file ~/rediscluster/nodes2.conf
redis-server --port 6383 --cluster-enabled yes --cluster-config-file ~/rediscluster/nodes3.conf
import subprocess
import sys
import time
p = subprocess.Popen(
('redis-server', '--port', '6379', '--bind', '127.0.0.1'),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
WAIT = 0.001
from benchmarker import Benchmarker
import json
import ujson
imp_obj = {
'rectangle': {'tagid': '12345', 'banner': {'w': 300, 'h': 250}},
'big_banner': {'tagid': '22222', 'banner': {'w': 728, 'h': 90}},
'rectangle_with_inventory': {'tagid': '10000', 'banner': {'w': 300, 'h': 250}},
'banned': {'tagid': '54321', 'banner': {'w': 300, 'h': 250}},
}
from benchmarker import Benchmarker
from itertools import ifilter
f = lambda x: x % 2
with Benchmarker(width=40, loop=1000) as bm:
for _ in bm('filter'):
list(filter(f, xrange(10000)))
for _ in bm('ifilter'):
list(ifilter(f, xrange(10000)))
@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"
# -*- coding: utf-8 -*-
import argparse
import re
import sys
from collections import namedtuple
import git
match_serial = re.compile(r'^\+\s+(\d{10})\s*; serial$').match