Skip to content

Instantly share code, notes, and snippets.

View carlcarl's full-sized avatar

Carl Huang carlcarl

View GitHub Profile
"""
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:
<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>
@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;
# 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)]
// ==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'; // 台北
@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.
@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 / media_queries.css
Created December 23, 2013 10:57
css media queries
/* http://stackoverflow.com/questions/18424798 */
@media(max-width:767px){}
@media(min-width:768px){}
@media(min-width:992px){}
@media(min-width:1200px){}
@carlcarl
carlcarl / meta_tags.html
Last active January 1, 2016 04:29
html meta tags
<!--http://stackoverflow.com/questions/11616697-->
<!-- for Google -->
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="" />
<meta name="copyright" content="" />
<meta name="application-name" content="" />
@carlcarl
carlcarl / random.c
Created September 25, 2013 15:15
random with /dev/urandom
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
int main (int argc, char *argv[])
{
FILE *urandom;
unsigned int seed;