This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
# get the camera | |
camera = cv2.VideoCapture(1) | |
# setup output window | |
cv2.namedWindow('output', cv2.WINDOW_AUTOSIZE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$app->get('/sample-page', function() use ($app) { | |
$cache = new Cache(Kv::getClient()); | |
if (($page = $cache->load('sample-page')) === false) { | |
$sql = "select * from pages where page_name = 'sample-page'"; | |
$page = Db::doQuery($sql); | |
$cache->save('sample-page', $page, '3600'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
set_include_path(dirname(dirname(__DIR__))); | |
require 'vendor/autoload.php'; | |
use Slim\Slim; | |
use SlimProject\Rain; | |
use SlimProject\Db; | |
// instantiate the app and view | |
$app = new Slim(array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$app->get('/fixreddit/:subreddit', function($subreddit) use ($app) { | |
$validSubreddits = [ 'php', 'python', 'programming' ]; | |
if (in_array($subreddit, $validSubreddits)) { | |
$cache = new Cache(Kv::getClient()); | |
$cacheId = 'fixreddit:' . $subreddit; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class FixReddit | |
{ | |
public static function getRSSForSubreddit($subreddit) | |
{ | |
$feed = new \Suin\RSSWriter\Feed(); | |
$channel = new \Suin\RSSWriter\Channel(); | |
$channel->title("r/$subreddit") | |
->url("http://reddit.com/r/$subreddit") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Cache | |
{ | |
const KEY_PREFIX = 'cache:'; | |
protected $_client; | |
public function __construct(\Predis\Client $client) | |
{ | |
$this->_client = $client; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Kv | |
{ | |
const KEY_PREFIX = 'aSampleApplicationKeyPrefix:'; | |
protected static $_config = null; | |
public static function getClient() | |
{ | |
if (!self::$_config) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" -- / == to left/right thru tabs | |
map -- gT | |
map == gt | |
" ww to save, qq to save + quit, QQ to quit w/o save, zz to toggle fold | |
map ww :w<CR> | |
map qq :wq<CR> | |
map QQ :q!<CR> | |
map zz za |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add some aliases in ~/.bash_aliases | |
cat > ~/.bash_aliases << DELIM | |
alias vim="vim -p" | |
alias lsg="ls | grep" | |
alias bin="cd ~/bin" | |
DELIM | |
# add PS1 config line to ~/.bashrc | |
echo "PS1=\"\n\u | \w \"" >> ~/.bashrc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# remap prefix to CTRL-a | |
set -g prefix C-a | |
unbind C-b | |
# unbind tab key to fix autocomplete | |
unbind-key Tab | |
# | key splits vertically, _ key splits horizontly | |
bind \ split-window -h | |
bind - split-window -v |