As configured in my dotfiles.
start new:
tmux
start new with session name:
#!/bin/bash | |
mysql -e "CREATE DATABASE \`$1\` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;" | |
mysql -e "GRANT ALL PRIVILEGES ON \`$1\`.* TO '$2'@'localhost' IDENTIFIED BY '$3' WITH GRANT OPTION;" |
As configured in my dotfiles.
start new:
tmux
start new with session name:
### INSTALLATION NOTES ### | |
# 1. Install Homebrew (https://github.com/mxcl/homebrew) | |
# 2. brew install zsh | |
# 3. Install OhMyZsh (https://github.com/robbyrussell/oh-my-zsh) | |
# 4. brew install reattach-to-user-namespace --wrap-pbcopy-pbpaste && brew link reattach-to-user-namespace | |
# 5. Install iTerm2 | |
# 6. In iTerm2 preferences for your profile set: | |
# Character Encoding: Unicode (UTF-8) | |
# Report Terminal Type: xterm-256color | |
# 7. Put itunesartist and itunestrack into PATH |
class LoggingMixin(object): | |
def dispatch(self, request_type, request, **kwargs): | |
logger.debug( | |
'%s %s %s' % | |
(request.method, request.get_full_path(), request.raw_post_data)) | |
try: | |
response = super(LoggingMixin, self).dispatch( | |
request_type, request, **kwargs) | |
except (BadRequest, fields.ApiFieldError), e: |
from scrapy.spider import BaseSpider | |
from twisted.internet import reactor, defer | |
from scrapy.http import Request | |
DELAY = 5 # seconds | |
class MySpider(BaseSpider): | |
name = 'wikipedia' |
Copyright the authors of Honcho and/or Ben Lopatin | |
Licensed for reuse, modification, and distribution under the terms of the MIT license |
##git mergetool
In the middle file (future merged file), you can navigate between conflicts with ]c
and [c
.
Choose which version you want to keep with :diffget //2
or :diffget //3
(the //2
and //3
are unique identifiers for the target/master copy and the merge/branch copy file names).
:diffupdate (to remove leftover spacing issues)
:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)
import pickle | |
# Session key | |
key = 'my_qs' | |
# Pizza => model example | |
qs = Pizza.objects.filter(ingredient='tomato') | |
# Dumping data | |
request.session[key] = pickle.dumps(qs.query) |
import cv2.cv as cv | |
import tesseract | |
gray = cv.LoadImage('captcha.jpeg', cv.CV_LOAD_IMAGE_GRAYSCALE) | |
cv.Threshold(gray, gray, 231, 255, cv.CV_THRESH_BINARY) | |
api = tesseract.TessBaseAPI() | |
api.Init(".","eng",tesseract.OEM_DEFAULT) | |
api.SetVariable("tessedit_char_whitelist", "0123456789abcdefghijklmnopqrstuvwxyz") | |
api.SetPageSegMode(tesseract.PSM_SINGLE_WORD) | |
tesseract.SetCvImage(gray,api) | |
print api.GetUTF8Text() |