- Create
UNLOGGED
table. This reduces the amount of data written to persistent storage by up to 2x. - Set
WITH (autovacuum_enabled=false)
on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we neverDELETE
orUPDATE
the table). - Insert rows with
COPY FROM STDIN
. This is the fastest possible approach to insert rows into table. - Minimize the number of indexes in the table, since they slow down inserts. Usually an index
on
time timestamp with time zone
is enough. - Add
synchronous_commit = off
topostgresql.conf
. - Use table inheritance for fast removal of old data:
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
function getData() { | |
var deferred = $.Deferred(); | |
$.ajax({ | |
'url': 'http://google.com', | |
'success': function(data) { | |
deferred.resolve('yay'); | |
}, | |
'error': function(error) { | |
deferred.reject('boo'); |
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
function compose(...fnArgs) { | |
const [first, ...funcs] = fnArgs.reverse(); | |
return function(...args) { | |
return funcs.reduce((res, fn) => fn(res), first(...args)); | |
}; | |
} |
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 | |
// PHP Simple Proxy | |
// Responds to GET or POST | |
//I would use session or other checks to prevent abuse. | |
//do not put it in the wild without limiting usage to a domain, list of urls etc | |
$url = ($_POST['url']) ? $_POST['url'] : $_GET['url']; | |
$url = urldecode($url); | |
if(empty($url)){ |
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 | |
/** Encryption setup CODE **/ | |
$key = openssl_pkey_new(array('private_key_bits' => 2048)); | |
$private_key = openssl_pkey_get_details($key); | |
$public_key = $private_key['key']; | |
echo "<pre>"; | |
print_r($private_key); | |
echo "</pre>"; |
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
function myfunc(){ | |
var data = { | |
name:'', | |
age:0, | |
roles:[], | |
prefs:{ | |
timezone:1, | |
theme:'light', | |
lng:'en' | |
} |
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
(function(x, f=()=>x){ | |
var x; | |
var y=x; | |
x=2; | |
return [x,y,f()]; | |
})(1) | |
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
301 moved permanently (redirect): | |
<?php | |
header('HTTP/1.1 301 Moved Permanently'); | |
header('Location: http://www.example.com'); | |
die(); | |
?> | |
302 moved temporarily(redirect): | |
<?php | |
header('Location: http://www.example.com'); |
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 | |
$opt = array( | |
"--zoom"=>'1', | |
"--disable-smart-shrinking"=>'', | |
"--page-size"=>'A4', | |
"--orientation"=>'Landscape', | |
"--margin-bottom"=>'0', | |
"--margin-top"=>'0', | |
"--margin-left"=>'0', | |
"--margin-right"=>'0' |
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
start .\chrome.exe --disable-web-security --ignore-certificate-errors --user-data-dir="D:/Chrome" | |
exit |