Skip to content

Instantly share code, notes, and snippets.

View lihan's full-sized avatar

lihan lihan

View GitHub Profile
@lihan
lihan / psql-srv.py
Created February 22, 2022 10:57 — forked from setop/psql-srv.py
postgres "server" wire protocol example (ported python3)
# th30z@u1310:[Desktop]$ psql -h localhost -p 55432
# Password:
# psql (9.1.10, server 0.0.0)
# WARNING: psql version 9.1, server version 0.0.
# Some psql features might not work.
# Type "help" for help.
#
# th30z=> select foo;
# a | b
# ---+---
@lihan
lihan / gist:c0d7eeef9a0b375a8f1dd6365f45cb20
Last active July 13, 2021 13:53
Postman Pre-request script to add signatures to work with django-rest-framework-httpsignature
/**
* How to use
*
* 1. Place below script in "Pre-request Script" tab in Postman, change "apiKey" and "apiSecret" variable.
* 2. In the "Headers" tab, reference the value as "{{authorisation}}" as per your predefined header name,
* typically "authorization"
* 3. Depending on your server side setup, add header "x-api-key" to your KEY.
*
* Tested with Postman Version 6.0.9
*

Keybase proof

I hereby claim:

  • I am lihan on github.
  • I am lihan (https://keybase.io/lihan) on keybase.
  • I have a public key whose fingerprint is 34DC D710 2875 2E2B 9461 0D11 6538 D09A D34A F82C

To claim this, I am signing this object:

@lihan
lihan / project-html-template
Created June 8, 2013 15:48
My html template for django project
{% extends 'html5.html' %}
{% block title %}{% endblock title %}
{% block description %}{% endblock %}
{% block head_css %}{% endblock %}
{% block body_contents %}
{% endblock %}
@lihan
lihan / html5.html
Created June 8, 2013 15:44
My root template for django project.
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>{% block title %}{% endblock title %}</title>
<meta name="description" content="{% block description %}{% endblock %}">
@lihan
lihan / gist:5220679
Created March 22, 2013 11:44
Django requirements.txt
django
django-secure
django-model-utils
psycopg2
django-debug-toolbar
South
django-redis-cache
django-waffle
requests
@lihan
lihan / gist:3817396
Created October 2, 2012 08:39
Ubuntu VPN Script for OpenVZ/Xen/KVM"
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH
clear
CUR_DIR=$(pwd)
if [ $(id -u) != "0" ]; then
printf "Error: You must be root to run this script!"
exit 1