Skip to content

Instantly share code, notes, and snippets.

View codeb2cc's full-sized avatar
🎯
Focusing

Codeb Fan codeb2cc

🎯
Focusing
  • Eastworld AI
  • Singapore
View GitHub Profile
@codeb2cc
codeb2cc / demo.py
Created March 7, 2012 13:23
Demonstration of MongDB FileField's Losing File Reference
# -*- coding:utf-8 -*-
import tempfile
import pymongo, gridfs, mongoengine
class TheDocument(mongoengine.Document):
the_file = mongoengine.FileField()
if __name__ == '__main__':
@codeb2cc
codeb2cc / gridfs_lock.py
Created March 5, 2012 20:24
A naive solution of GridFS's concurrency problem
# -*- coding:utf-8 -*-
# This demo demonstrates the concurrency problem of MongDB's GridFS interface.
import os, tempfile, multiprocessing, time
import pymongo, gridfs
import mongoengine
DB_HOST = '127.0.0.1'
DB_PORT = 27017
@codeb2cc
codeb2cc / gridfs_concurrency.py
Created March 5, 2012 20:00
Demonstration of MongDB GridFS's concurrency problem
# -*- coding:utf-8 -*-
# This demo demonstrates the concurrency problem of MongDB's GridFS interface.
import os, tempfile, multiprocessing, time
import pymongo, gridfs
import mongoengine
DB_HOST = '127.0.0.1'
DB_PORT = 27017
@codeb2cc
codeb2cc / benmark.py
Created March 5, 2012 17:51
MongoDB Insert VS Save
# -*- coding:utf-8 -*-
# MongoDB Benmarking with Mongoengine
import os, time, multiprocessing
import pymongo
import mongoengine
DB_HOST = '127.0.0.1'
DB_PORT = 27017
@codeb2cc
codeb2cc / zshrc
Created January 20, 2012 09:45
My zsh configuration
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=512
SAVEHIST=512
bindkey -v
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/codeb2cc/.zshrc'
autoload -Uz compinit
@codeb2cc
codeb2cc / .bashrc
Created December 27, 2011 14:06
Bash Prompt
# User specific aliases and functions
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias rm='rm -i'
alias mv='mv -i'
alias du='du -h --max-depth=1'
alias df='df -h'
alias grep='grep --color'
@codeb2cc
codeb2cc / emailValidator.js
Created December 22, 2011 12:04
Email Validator
function validEmail(email){
var emailReg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
return emailReg.test(email);
}