start new:
tmux
start new with session name:
tmux new -s myname
| // --- Compiling --- | |
| $ wget http://download.redis.io/releases/redis-2.8.3.tar.gz | |
| $ tar xzvf redis-2.8.3.tar.gz | |
| $ cd redis-2.8.3 | |
| $ make | |
| $ make install | |
| // --- or using yum --- | |
| $ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm | |
| $ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm |
| 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() |
| 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) |
| Copyright the authors of Honcho and/or Ben Lopatin | |
| Licensed for reuse, modification, and distribution under the terms of the MIT license |
| from scrapy.spider import BaseSpider | |
| from twisted.internet import reactor, defer | |
| from scrapy.http import Request | |
| DELAY = 5 # seconds | |
| class MySpider(BaseSpider): | |
| name = 'wikipedia' |
| 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: |
| ### 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 |
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;" |