Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I wrote like 10 lines of code a week then I sleep.

laixintao

💭
I wrote like 10 lines of code a week then I sleep.
View GitHub Profile
@lgyanf
lgyanf / add_query_parameters.py
Created June 14, 2016 10:49
A python decorator that adds query parameters to django-rest-framework swagger docstring.
View add_query_parameters.py
# -*- coding: utf-8 -*-
import collections
import yaml
from rest_framework import fields
"""
Convert rest_framework.fields classes to Swagger data types according to http://swagger.io/specification/
Return 'string' by default.
@bmhatfield
bmhatfield / .profile
Last active March 5, 2023 12:17
Automatic Git commit signing with GPG on OSX
View .profile
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
@Jiezhi
Jiezhi / tmux.conf.bak
Last active April 11, 2022 02:07
tmux configure file from 《tmux:Productive Mouse-Free Development》
View tmux.conf.bak
# Setting the prefix from C-b to C-a
set -g prefix C-a
# Free the original Ctrl-b prefix keybinding
unbind C-b
#setting the delay between prefix and command
set -sg escape-time 1
# Ensure that we can send Ctrl-A to other apps
@ryerh
ryerh / tmux-cheatsheet.markdown
Last active March 26, 2023 16:50 — forked from MohamedAlaa/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表 & 简明教程
View tmux-cheatsheet.markdown

注意:本文内容适用于 Tmux 2.3 及以上的版本,但是绝大部分的特性低版本也都适用,鼠标支持、VI 模式、插件管理在低版本可能会与本文不兼容。

Tmux 快捷键 & 速查表 & 简明教程

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

@mayank-io
mayank-io / pg_truncate_tables.sql
Created January 9, 2016 07:59
Postgres: Truncate all tables in PUBLIC schema for a given USER
View pg_truncate_tables.sql
-- Running this snippet creates a function. This function can then be executed
-- in this manner:
-- SELECT truncate_tables('postgres');
CREATE OR REPLACE FUNCTION truncate_tables(_username text)
RETURNS void AS
$func$
BEGIN
RAISE NOTICE '%',
-- EXECUTE -- dangerous, test before you execute!
@ficapy
ficapy / img_upload.py
Last active April 9, 2018 13:08
当做图床使用,读取粘贴板的图像保存上传,完成后将url地址写入到剪贴板
View img_upload.py
#!/usr/local/bin/python2
# -*- coding: utf-8 -*-
# Author: Ficapy
# Create: '16/1/1'
import datetime
import os
import sys
import atexit
import requests
View zsh-color-names.zsh
#!/bin/zsh -f
autoload -U colors
colors
print "
ZSH Color definitions:
\e[1mprompt simple\e[0m [\e[1m<\e[0mcolor1\e[1m>\e[0m[\e[1m<\e[0mcolor2\e[1m>\e[0m[\e[1m<\e[0mcolor3\e[1m>\e[0m[\e[1m<\e[0mstring1\e[1m>\e[0m[\e[1m<\e[0mstring2\e[1m>\e[0m[\e[1m<\e[0mstring3\e[1m>\e[0m]]]]]]
Supply up to three \e[1mcolors\e[0m and then up to three alternate static \e[1mprompt strings \e[0m.
\e[1mcolor1\e[0m is the local prompt color: \e[1mzsh-% \e[0m color1=default
\e[1mcolor2\e[0m is the remote prompt color: \e[31m$HOST:r:r-%\e[0m color2=red
\e[1mcolor3\e[0m is the screensession prompt color: \e[1mScreen-% \e[0m color3=default
@toast38coza
toast38coza / commands
Last active March 3, 2022 11:30
Simple systemd unit for running a django app
View commands
# start / stop / restart / status
systemctl start test
systemctl stop test
systemctl restart test
systemctl status test
# logs use journalctl:
# tail the logs for unit `django`
journalctl -f -u django
@mrluanma
mrluanma / README.md
Last active August 1, 2017 01:22
使用 requests + concurrent.futures 并发的访问 HTTP 服务示例
View README.md
$ python t.py
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): example.net
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (2): example.net
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (3): example.net
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (4): example.net
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (5): example.net
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (6): example.net
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (7): example.net
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (8): example.net
@un1t
un1t / django-script.py
Created February 21, 2015 21:48
How to run scripts outside django
View django-script.py
# coding: utf-8
import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
django.setup()
# write your code here