start new:
tmux
start new with session name:
tmux new -s myname
| /* | |
| Assuming you have an enum type like this. | |
| You want to rename 'pending' to 'lodged' | |
| */ | |
| CREATE TYPE dispute_status AS ENUM('pending', 'resolved', 'open', 'cancelled'); | |
| BEGIN; | |
| ALTER TYPE dispute_status ADD VALUE 'lodged'; | |
| UPDATE dispute SET status = 'lodged' WHERE status = 'pending'; |
| @media only screen and (min-width: 320px) { | |
| /* Small screen, non-retina */ | |
| } | |
| @media | |
| only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 320px), | |
| only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 320px), | |
| only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 320px), |
| <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
| class MY_Session extends CI_Session{ | |
| private $sess_use_redis = TRUE; | |
| private $redis = ''; | |
| public function __construct($params = array()) { | |
| //parent::__construct(); | |
| $this->CI =& get_instance(); |
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
| """ | |
| Two things are wrong with Django's default `SECRET_KEY` system: | |
| 1. It is not random but pseudo-random | |
| 2. It saves and displays the SECRET_KEY in `settings.py` | |
| This snippet | |
| 1. uses `SystemRandom()` instead to generate a random key | |
| 2. saves a local `secret.txt` |
| <?php | |
| /** | |
| * Create a web friendly URL slug from a string. | |
| * | |
| * Although supported, transliteration is discouraged because | |
| * 1) most web browsers support UTF-8 characters in URLs | |
| * 2) transliteration causes a loss of information | |
| * | |
| * @author Sean Murphy <[email protected]> | |
| * @copyright Copyright 2012 Sean Murphy. All rights reserved. |
| try: | |
| import simplejson as json | |
| except ImportError: | |
| try: | |
| import json | |
| except ImportError: | |
| raise ImportError | |
| import datetime | |
| from bson.objectid import ObjectId | |
| from werkzeug import Response |
| http { | |
| map $http_user_agent $limit_bots { | |
| default ''; | |
| ~*(google|bing|yandex|msnbot) $binary_remote_addr; | |
| } | |
| limit_req_zone $limit_bots zone=bots:10m rate=1r/m; | |
| server { |
| ffprobe -v quiet -print_format json -show_format -show_streams "lolwut.mp4" > "lolwut.mp4.json" |