Skip to content

Instantly share code, notes, and snippets.

@photonxp
photonxp / Use .ssh config file to connect to github
Last active August 29, 2015 13:59
Instructions on how to connect to github by the settings of ssh config file
Use .ssh/config file to connect to github
Preparations:
You'd better have prepared following materials:
* A pair of public/private keys, say id_rsa_gitlover & id_rsa_gitlover.pub
If you don't have yet, here's the instruction you can refer to:
https://help.github.com/articles/generating-ssh-keys
* A github account, say [email protected]
@photonxp
photonxp / 0_reuse_code.js
Created April 18, 2014 03:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
pass arguments in django template
<form action="{% url 'polls:vote' question.id %}" method="post">
How does url receives arguments in the template?
https://docs.djangoproject.com/en/dev/intro/tutorial03/
polls/templates/polls/detail.html
<h1>{{ question.question_text }}</h1>
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
<form action="{% url 'polls:vote' question.id %}" method="post">
{% csrf_token %}
{% for choice in question.choice_set.all %}
<input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" />
@photonxp
photonxp / curl_ip.sh
Created April 21, 2014 13:19
curl to get external ip for local machine. Used to check if a proxy is working.
#!/bin/bash
curl ipecho.net/plain ; echo
openvpn configure notes:
Follow the process on debian wiki: https://wiki.debian.org/OpenVPN
The process is almost OK. Only a few adjustments is required as below:
checking:
$ which openvpn
The default directory after installation is: /etc/openvpn/
All relative path in .conf files points to this path.
anypackage/
__init__.py
xxx.py # class WWW is originally defined in this xxx file.
generally speaking, python can only import class from modules, which is usually a .py file.
import WWW from xxx
But, we can also import class from a package(folder) directly, rather than from the module. This is where an __init__.py file can step onto the stage.
get python dependency graph
install snake food
sudo apt-get install snakefood
http://furius.ca/snakefood/
install graphviz
@photonxp
photonxp / grep letters|whitespace|number
Created May 16, 2016 01:21
bash grep letters|whitespace|number
# grep letters|whitespace|number
# http://www.robelle.com/smugbook/regexpr.html
ps -elf | grep '[a-zA-Z]\{1,\}\s*2502'
@photonxp
photonxp / decodebase64.py
Last active December 31, 2016 08:07
simply decode base64 content from a string or a readable file
#!/usr/bin/python
# Demo code. Decode base64 content from a string or a readable file
# Works for Python 2.7.3, at least
# Usage
# decodebase64.py base64string
# decodebase64.py /absolute/path/to/base64/file
import sys