Skip to content

Instantly share code, notes, and snippets.

View carlcarl's full-sized avatar

Carl Huang carlcarl

View GitHub Profile
@carlcarl
carlcarl / django_crud.py
Last active January 1, 2016 20:59
Django CRUD snippet
# From https://djangosnippets.org/snippets/2309/#!
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.core.urlresolvers import reverse
class AutomagicModel(models.Model):
class Meta:
abstract=True
def get_absolute_url(self):
@carlcarl
carlcarl / post-update.sh
Last active January 2, 2016 05:09
github post-update
#!/bin/sh
#
# This hook does two things:
#
# 1. update the "info" files that allow the list of references to be
# queries over dumb transports such as http
#
# 2. if this repository looks like it is a non-bare repository, and
# the checked-out branch is pushed to, then update the working copy.
# This makes "push" function somewhat similarly to darcs and bzr.
// ==UserScript==
// @name railwayTicketFormAutoField
// @namespace http://railway.hinet.net/ctno1.htm
// @description Change some element on login page
// @include http://*railway.hinet.net/ctno1.htm
// ==/UserScript==
var personalId = 'A123456789'; // 身份正字號
var fromStation = '100'; // 台北
# requires python 3.2.3 or higher
import concurrent.futures
def f(x):
print ("working on task: %s" %{x})
if x-1 > 0 :
return x-1 # I want this task back in the queue.
def main():
Queue = [x for x in range(4)]
@carlcarl
carlcarl / is_BST.c
Created June 25, 2014 03:34
Check is binary search tree
// http://www.geeksforgeeks.org/a-program-to-check-if-a-binary-tree-is-bst-or-not/
bool isBST(struct node* root)
{
static struct node *prev = NULL;
// traverse the tree in inorder fashion and keep track of prev node
if (root)
{
if (!isBST(root->left))
return false;
<div class="container">
<div class="row">
<div class="col-sm-6 col-md-4 col-md-offset-4">
<h1 class="text-center login-title">Sign in to continue to Bootsnipp</h1>
<div class="account-wall">
<img class="profile-img" src="https://lh5.googleusercontent.com/-b0-k99FZlyE/AAAAAAAAAAI/AAAAAAAAAAA/eu7opA4byxI/photo.jpg?sz=120"
alt="">
<form class="form-signin">
<input type="text" class="form-control" placeholder="Email" required autofocus>
<input type="password" class="form-control" placeholder="Password" required>
"""
module mydjangolib.bigint_patch
A fix for the rather well-known ticket #399 in the django project.
Create and link to auto-incrementing primary keys of type bigint without
having to reload the model instance after saving it to get the ID set in
the instance.
Logs:
@carlcarl
carlcarl / heart.css
Last active August 29, 2015 14:15
Heart css
.heart{
position: relative;
width: 200px;
height: 200px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
background-color: #FF7E7E;
# http://www.coder4.com/archives/1589
scheduler = sched.scheduler(time.time, time.sleep)
def event(action_time):
print 'action_time:%s' % (action_time)
scheduler.enterabs(action_time + 5, 1, event, (action_time + 5,))
inittime = time.time()
# 日本語用
$ sudo apt-get install libncursesw5-dev
# ソースコード取得
$ git clone https://github.com/jonas/tig.git
$ cd tig
$ git checkout -b my-build-2.0.1 tig-2.0.1
# ビルド, インストール
$ LDLIBS=-lncursesw CFLAGS=-I/usr/include/ncursesw make install prefix=$HOME/local