Skip to content

Instantly share code, notes, and snippets.

{
"10": {
"answer": "JSON",
"opt": [
"BSON",
"JSON",
"SON",
"XML",
"YAML"
],
@georgefs
georgefs / gtk_sys_clipboard.vim
Created April 1, 2013 08:43
ubuntu 系統剪貼簿gtk
""ubuntu virtual mode ctrl+c 複製到系統剪貼簿 gtk only
python import gtk
python import vim
vmap <silent> <C-C> y:let @0=substitute(@0,"\\","\\\\\\","gi")<CR>:let @0=substitute(@0,"\'","\\\\'","gi")<CR>:python gtk.clipboard_get().set_text('''<C-R>0''')<CR>:python gtk.clipboard_get().store()<CR>
@georgefs
georgefs / setting.py
Created April 12, 2013 02:41
django mongoengine admin setting
#
#Django settings for main project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', '[email protected]'),
)
@georgefs
georgefs / init_template.sh
Last active December 16, 2015 09:19
simple init.d template
#!/bin/bash
###
# george.li 2013/1/9
#
# simple daemon template
#
# env var
# DAEMON: daemon program path
# NAME: suggest daemon name
# PID_FILE: daemon pid file path
@georgefs
georgefs / mongoengine_utils.py
Created April 19, 2013 23:25
cover mongoengine document to raw dict
from bson.objectid import ObjectId
from bson.dbref import DBRef
from mongoengine.document import Document
import collections
from datetime import datetime
from mongoengine.queryset import QuerySet
def raw_data(data):
if isinstance(data, unicode):
@georgefs
georgefs / utils.py
Created April 19, 2013 23:39
django view json decoder auto warp status & errormsg
def json_api(func):
def deco(*args, **kwargs):
result = {}
try:
result['status'] = 0
result['msg'] = "success"
result['data'] = func(*args, **kwargs)
except Exception,e:
result['status'] = e.errorno if hasattr(e, 'errorno') else 1
@georgefs
georgefs / window_fog.vim
Created May 9, 2013 14:29
除了主要編輯視窗都上迷霧0..0 額外付送十字游標喔 lol XD window 開太多 常會找不到現在的編輯區~攤手 找了一下.. vim原生不支援單一window 修改background color.. 只能用這種蠢方法XDDD ColorColumn 的highlight 來模擬了- -+ 雖然不完美但是夠用了~
"height ligth cusor
set t_Co=256
set cursorline
set cursorcolumn
highlight CursorColumn cterm=none ctermbg=236
highlight CursorLine cterm=none ctermbg=236
highlight ColorColumn ctermbg=none ctermbg=240
" Dim inactive windows using 'colorcolumn' setting
" This tends to slow down redrawing, but is very useful.
@georgefs
georgefs / advance_search_form_admin.py
Created May 11, 2013 20:54
django advance search form
class FormForAdvancedSearch(forms.Form):
#you can put any field here this is an example so only 1 simple CharField
form_field1 = forms.CharField()
class MyModelAdmin(admin.ModelAdmin):
# the auxiliary search form
advanced_search_form = FormForAdvancedSearch()
# a dictionary of key that will be removed from the GET QueryDict
# this is necessary otherwise ChangeList will complain for malformed
# query string
@georgefs
georgefs / bash_rc
Created May 14, 2013 01:05
som of my bash rc
pp='ps -aux|grep '
function pk(){
echo kill -9 `ps -aux|grep $1|awk '{print \$2}'`
}
@georgefs
georgefs / uwsgi.py
Last active December 19, 2015 17:48
管裡開啟uwsgi.ini 的/etc/init.d
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright © 2013 george
#
# Distributed under terms of the MIT license.
__all__=[]
import os
import sys
import re