Skip to content

Instantly share code, notes, and snippets.

@zackshen
zackshen / 0_reuse_code.js
Created February 14, 2016 13:30
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
.
├── actions
├── stores
├── views
│   ├── Anonymous
│   │   ├── __tests__
│   │   ├── views
│   │   │   ├── Home
│   │   │   │   ├── __tests__
│   │   │   │   └── Handler.js
@zackshen
zackshen / blog-webpack-2.md
Created January 28, 2016 14:03 — forked from xjamundx/blog-webpack-2.md
From Require.js to Webpack - Part 2 (the how)

This is the follow up to a post I wrote recently called From Require.js to Webpack - Party 1 (the why) which was published in my personal blog.

In that post I talked about 3 main reasons for moving from require.js to webpack:

  1. Common JS support
  2. NPM support
  3. a healthy loader/plugin ecosystem.

Here I'll instead talk about some of the technical challenges that we faced during the migration. Despite the clear benefits in developer experience (DX) the setup was fairly difficult and I'd like to cover some of the challanges we faced to make the transition a bit easier.

class dotdictify(dict):
def __init__(self, value=None):
if value is None:
pass
elif isinstance(value, dict):
for key in value:
self.__setitem__(key, value[key])
else:
raise TypeError, 'expected dict'
import os
import subprocess
with open(os.devnull, 'w') as null:
subprocess.call(['echo', 'foo'], stdout=null, stderr=subprocess.STDOUT)
import time
class Timer(object):
def __init__(self, verbose=False):
self.verbose = verbose
def __enter__(self):
self.start = time.time()
return self
import gc
def dump_garbage():
"""
show us what's the garbage about
"""
# force collection
print "\nGARBAGE:"
gc.collect()
ps aux | grep -ie amarok | awk '{print $2}' | xargs kill -9
import threading
import logging
logger = logging.getLogger('default')
class _TaskThread(threading.Thread):
def __init__(self, interval=1):
threading.Thread.__init__(self)
self._finished = threading.Event()
self._exited = threading.Event()
# Vim快速选中、删除、复制引号或括号中的内容
以下命令可以对标点内的内容进行操作。
ci'、ci"、ci(、ci[、ci{、ci< - 分别更改这些配对标点符号中的文本内容
di'、di"、di(或dib、di[、di{或diB、di< - 分别删除这些配对标点符号中的文本内容
yi'、yi"、yi(、yi[、yi{、yi< - 分别复制这些配对标点符号中的文本内容
vi'、vi"、vi(、vi[、vi{、vi< - 分别选中这些配对标点符号中的文本内容