Skip to content

Instantly share code, notes, and snippets.

@Yaiba
Yaiba / keybase.md
Created January 18, 2021 04:49
proof for yaiba@github

Keybase proof

I hereby claim:

  • I am yaiba on github.
  • I am yaiba (https://keybase.io/yaiba) on keybase.
  • I have a public key ASAmh2lUuB1WMsrj4pWXp8bEP2Z2QzXkDhZ7zsSMaaSoTQo

To claim this, I am signing this object:

git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@Yaiba
Yaiba / ubuntu_ssh_login_slack_notify.sh
Last active March 30, 2022 23:31
get slack notify when login to ubuntu server
#/bin/sh
# #######################################
# pam REF: https://askubuntu.com/a/448602 https://blog.stalkr.net/2010/11/login-notifications-pamexec-scripting.html
# copy to /usr/local/bin, then +x
# add "session optional pam_exec.so type=open_session seteuid log=/tmp/pam.log /usr/local/bin/login_slack_notify.sh" to /etc/pam.d/sshd
# work on Ubuntu 14.04.5 / Centos 7.9
# selinux refer https://unix.stackexchange.com/a/474063 https://bugzilla.redhat.com/show_bug.cgi?id=737906#c1
#echo "User: $PAM_USER" >> /tmp/a.txt
#echo "Ruser: $PAM_RUSER" >> /tmp/a.txt
@Yaiba
Yaiba / ns-cheatsheet.clj
Created March 13, 2017 02:36 — forked from ghoseb/ns-cheatsheet.clj
Clojure ns syntax cheat-sheet
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix
;; and optionally can refer functions to the current ns.
;;
;; * :import refers Java classes to the current namespace.
;;
;; * :refer-clojure affects availability of built-in (clojure.core)
;; functions.
@Yaiba
Yaiba / wsgi.py
Last active December 22, 2016 08:36
profile on every django request by decorate wsgihandler
import os
import functools
import time
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demo.settings")
#import cProfile
#def profiled(func):
@Yaiba
Yaiba / redis_queue.py
Created March 10, 2016 06:44
a simple redis queue
class RQueue(object):
""" redis queue wrap """
KEY = "redis"
def __init__(self, redis_conn):
"""
:host: redis host
:port: redis port
:redis_conn: redis connection
"""
self.redis = redis_conn
@Yaiba
Yaiba / using-python27-on-centos6
Last active January 5, 2016 02:27
using python27 on centos 6.x
#!/bin/bash
# fix yum
sed -i 's/\/usr\/bin\/python/\/usr\/bin\/python2.6/g' /usr/bin/yum
# requirement
yum -y update
yum groupinstall -y 'development tools'
yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget
@Yaiba
Yaiba / alpine-python-runtime-dockerfile
Created November 4, 2015 01:39
python2.7 runtime using alpine
# DOCKER_VERSION 1.8.3
# DESCRIPTION: alpine python runtime
FROM gliderlabs/alpine:3.2
MAINTAINER Yaiba
RUN apk-install --update \
python \
python-dev \
py-pip \

##tornado-debug 原理

使用方法: $ tor-deb python -m wcms_front.server

原理流程:

  1. 把/usr/lib/python2.7/site-packages/tornado_debug/bootstrap添加到环境变量PYTHONPATH

  2. 使用os.execl开启子进程,运行python程序

@Yaiba
Yaiba / pelican-dockerfile
Created June 9, 2015 10:09
simple dockerfile for pelican
# DOCKER_VERSION 1.6.2
# DESCTIPRION: dockerfile for build pelican
FROM ubuntu:14.04
MAINTAINER Gavin Fan gavintofan@gmail.com
RUN apt-get update -y
RUN apt-get install -y make python-setuptools
RUN easy_install pip
RUN pip install pelican Markdown typogrify