Skip to content

Instantly share code, notes, and snippets.

View laozhu's full-sized avatar
👨‍💻
Coding ideas

Ritchie Zhu laozhu

👨‍💻
Coding ideas
View GitHub Profile
@laozhu
laozhu / suppport-odbc.sh
Created October 29, 2013 02:02
让Django连接上MS SQL Server
sudo apt-get install unixodbc-dev
pip install pyodbc
pip install django-pyodbc
@laozhu
laozhu / fix.sql
Created October 25, 2013 03:57
解决postgresql下的主键冲突问题
SELECT setval('tablename_id_seq', (SELECT MAX(id) FROM tablename)+1)
@laozhu
laozhu / git-tips.sh
Last active August 23, 2017 11:32
Git如何回滚本地和远程的代码库
git log
git reset --hard <commit-id>
git push <remote-repo> HEAD --force
@laozhu
laozhu / loginview.py
Created October 23, 2013 02:22
无法获取REQUEST中REDIRECT_FIELD_NAME对应的值。
from django.conf import settings
from django.contrib.auth import login, REDIRECT_FIELD_NAME
from .forms import LoginForm, ResetPasswordForm
from django.utils.decorators import method_decorator
from django.views.generic import FormView
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_protect
class LoginView(FormView):
@laozhu
laozhu / sublime-plugin-list.md
Last active December 17, 2015 10:39
my sublime plugin list

General

Alignment - 强大的对齐插件

HTML

emmet - 快速构建html基本结构

CSS

@laozhu
laozhu / gist:5589172
Created May 16, 2013 03:27
gentoo server make.conf
CFLAGS="-march=corei7 -O2 -pipe"
CXXFLAGS="${CFLAGS}"
CHOST="x86_64-pc-linux-gnu"
LINGUAS="en"
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
PORTAGE_NICENESS="15"
USE_PYTHON="2.5 2.6 2.7 3.1 3.2"
PYTHON_TARGETS="python2_5 python2_6 python2_7 python3_1 python3_2"
PYTHON_SINGLE_TARGET="python3_2"
from django import http
from django.utils.http import urlquote
from django.core import urlresolvers
class AppendOrRemoveSlashMiddleware(object):
"""
Like django's built in APPEND_SLASH functionality, but also works in reverse. Eg
will remove the slash if a slash-appended url won't resolve, but its non-slashed
counterpart will.
@laozhu
laozhu / install-funtoo.md
Last active December 15, 2015 04:59
Install Funtoo Desktop on Dell Inspiron 7520 SE
# emerge --sync
# emerge -av wqy-microhei 

GPT/GUID partition table

gdisk /dev/sda

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          411647   200.0 MiB   8300  Linux filesystem

2 411648 923647 250.0 MiB EF00 EFI System

@laozhu
laozhu / make.conf
Created March 20, 2013 13:33
/etc/make.conf for funtoo desktop
CFLAGS="-march=corei7 -O2 -pipe"
CXXFLAGS="${CFLAGS}"
CHOST="x86_64-pc-linux-gnu"
LINGUAS="en"
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
PORTAGE_NICENESS="15"
MAKEOPTS="-j5"
INPUT_DEVICES="evdev keyboard mouse synaptics"
VIDEO_CARDS="radeon intel"
@laozhu
laozhu / kernel-configure.md
Last active October 31, 2019 13:14
Linux 内核编译指南

编译原则

  1. 确定 的功能一定编译进内核
  2. 可能 的功能编译为模块
  3. 不确定 的功能保留默认值,或编译为模组
  4. 选择 双号 版本内核,忽略 单号 内核

准备工作