Skip to content

Instantly share code, notes, and snippets.

View dchentech's full-sized avatar
🎯
Focusing

David Chen dchentech

🎯
Focusing
View GitHub Profile
@dchentech
dchentech / Discussion
Last active June 5, 2018 18:50
The Google Trends of 4 Web Frameworks Between 2005-2018:\nRuby on Rails, NodeJS, Python Flask, Java Spring.
Web development technologies change quickly in the recent decade. This visualisation displays the popularity change of 4 web frameworks. I scraped the data from Google Trends website. And here I choose the original colour of each web framework logo as the colours of time series.
When we look at this chart, we would easily find all web frameworks are becoming more popular than the past, except Ruby on Rails. Before 2005, Java was the mainstream way to build websites. When Web 2.0 SNS time came, people demanded an easy full-stack way to build the websites quickly. Ruby on Rails became popular due to its Convention over Configuration principle and the dynamic of Ruby programming language. Between 2007 and 2010, people find the shortcoming of Ruby on Rails is hard to maintain when the business and websites grow, and also the poor performance. After 2011, the market demanded more complicated frontend technology to provide more complex user experience, NodeJS came to solve this problem, and NodeJS also improved
@dchentech
dchentech / local_benchmark.py
Created May 13, 2015 05:24
JSON VS eval performance benchmark, see requirement at https://github.com/spotify/luigi/pull/939
# -*-coding:utf-8-*-
from etl_utils import process_notifier
from collections import Counter, defaultdict
import ujson
null = None
def char_count(func):
result = defaultdict(int)
@dchentech
dchentech / enc_dec_test.py
Last active August 29, 2015 14:20 — forked from justinfx/enc_dec_test.py
Speed test of common serializers on python 2.7.9 (pickle, cPickle, ujson, cjson, simplejson, json, yajl, msgpack, Python builtin)
"""
Dependencies:
pip install tabulate simplejson python-cjson ujson yajl msgpack-python
"""
from timeit import timeit
from tabulate import tabulate
# -*-coding:utf-8-*-
'''cjson, jsonlib, simplejson, and yajl also use C code
demjson did not use C code, but was too painfully slow to benchmark
(took about 20 seconds for these tests)
'''
import json
import sys
import time
@dchentech
dchentech / overwrite_base.py
Created January 6, 2015 08:16
Overwrite base class's methods.
# -*- coding: utf-8 -*-
"""
Overwrite base class's methods.
"""
import unittest
class Base(object):
@dchentech
dchentech / analysis_hg_day_commit_count.rb
Created December 19, 2014 06:50
用 Ruby 简单 统计 hg 每日 commit 量。
`hg log --template 'date: {date|isodate}\n' | grep 'date: '`.split("\n").map {|i1| i1[6..15] }.inject({}) {|d1, i1| d1[i1] ||= 0; d1[i1] += 1; d1 }.sort {|a, b| a[0] <=> b[0] }.each {|i| puts i.inspect };0
__END__
["2014-09-24", 4]
["2014-09-25", 8]
["2014-09-26", 6]
["2014-09-28", 10]
["2014-09-29", 14]
["2014-09-30", 3]
["2014-10-08", 14]
@dchentech
dchentech / lazy_load_reference.py
Created December 5, 2014 02:47
Lazy reference between tasks, include recursive references.
# Lazy reference between tasks, include recursive references.
# 1. `eval` version
def ref_tasks(*tasks):
def wrap(task1):
def _ref_task(self):
return eval(task1)
return _ref_task
@dchentech
dchentech / slow.coffee
Last active August 29, 2015 14:08
Simulate slow cpu computing
_.each(Array(10), -> Array(Math.pow(10, 8)).join("=").length)
@dchentech
dchentech / python_singleton.py
Created July 23, 2014 10:57
从Singleton实现看Python里的__new__和__init__区别。
from singleton import singleton
@singleton(True)
class hh(object):
cc = 0
def __init__(self):
hh.cc += 1
self.count = hh.cc
@dchentech
dchentech / .gitignore
Last active January 24, 2018 12:22 — forked from miku/.gitignore
*gz
*.txt