Skip to content

Instantly share code, notes, and snippets.

View laixintao's full-sized avatar
📟
I live in the terminal.

laixintao

📟
I live in the terminal.
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.
# -*- 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 May 6, 2024 22:27
Automatic Git commit signing with GPG on OSX
# 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》
# 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 April 18, 2024 18:06 — forked from MohamedAlaa/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表 & 简明教程

注意:本文内容适用于 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
-- 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地址写入到剪贴板
#!/usr/local/bin/python2
# -*- coding: utf-8 -*-
# Author: Ficapy
# Create: '16/1/1'
import datetime
import os
import sys
import atexit
import requests
@toast38coza
toast38coza / commands
Last active March 3, 2022 11:30
Simple systemd unit for running a django app
# 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 服务示例
$ 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
# coding: utf-8
import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
django.setup()
# write your code here
@anvaka
anvaka / top-github.md
Last active February 3, 2021 19:58
Top GitHub users by total number of stars

I was playing with GitHub Archive recently. Out of curiosity I ran this query:

SELECT COUNT(repository_owner) as totalStars, repository_owner
FROM [githubarchive:github.timeline] 
WHERE type = 'WatchEvent'
GROUP BY repository_owner
ORDER BY totalStars DESC
LIMIT 1000