This file contains 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
// This shows an example of how to generate a SSH RSA Private/Public key pair and save it locally | |
package main | |
import ( | |
"crypto/rand" | |
"crypto/rsa" | |
"crypto/x509" | |
"encoding/pem" | |
"golang.org/x/crypto/ssh" |
This file contains 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 these to speed up OpenCart | |
ALTER TABLE `oc_product` ADD INDEX(`date_available`, `status`); | |
ALTER TABLE `oc_product` ADD INDEX(`status`); | |
ALTER TABLE `oc_url_alias` ADD UNIQUE(`query`); | |
ALTER TABLE `oc_product_to_store` ADD INDEX(`store_id`); | |
ALTER TABLE `oc_category_path` ADD INDEX(`path_id`, `category_id`); | |
ALTER TABLE `oc_category_path` ADD INDEX(`category_id`, `path_id`); | |
ALTER TABLE `oc_product_description` ADD INDEX(`language_id`); | |
ALTER TABLE `oc_category` ADD INDEX (`parent_id`, `status`, `sort_order`); | |
ALTER TABLE `oc_category` ADD INDEX(`sort_order`); |
This file contains 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
""" | |
Graceful Stopper | |
=================== | |
Tool to stop a TCPServer (or HTTPServer) in a graceful manner (when the all | |
currently running work is done). This script works either for forked servers or | |
single-process servers. | |
The graceful-stop process can be triggered by sending `SIGHUP` to server (in a | |
forked environment, sending SIGHUP to master server, propagates to all | |
children). Server immediately releases the listening socket (so another server |
This file contains 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 tornado.web | |
class NoCacheStaticFileHandler(tornado.web.StaticFileHandler): | |
def set_extra_headers(self, path): | |
self.set_header("Cache-control", "no-cache") | |
class Application(tornado.web.Application): | |
def __init__(self): | |
handlers = [ | |
# ... |
This file contains 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 | |
/** | |
* Scan the api path, recursively including all PHP files | |
* | |
* @param string $dir | |
* @param int $depth (optional) | |
*/ | |
protected function _require_all($dir, $depth=0) { | |
if ($depth > $this->max_scan_depth) { |
This file contains 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
#Please tell me there is a better way to do this | |
#(And by 'a better way', I don't mean incorporating the cut within the awk script) | |
npm ls | grep -E "^(├|└)─" | cut -d" " -f2 | awk '{FS = "@"; print "\""$1"\"", ":", "\""$2"\""}' |
This file contains 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
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
This file contains 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
[unix_http_server] | |
file=/tmp/supervisor.sock ; path to your socket file | |
[supervisord] | |
logfile=/var/log/supervisord/supervisord.log ; supervisord log file | |
logfile_maxbytes=50MB ; maximum size of logfile before rotation | |
logfile_backups=10 ; number of backed up logfiles | |
loglevel=error ; info, debug, warn, trace | |
pidfile=/var/run/supervisord.pid ; pidfile location | |
nodaemon=false ; run supervisord as a daemon |