Skip to content

Instantly share code, notes, and snippets.

@gregorychalenko
gregorychalenko / example.com
Last active July 28, 2016 22:43
letsencrypt example:
server
{
listen 80;
listen 443 ssl;
server_name example.com www.example.com;
location ~ /.well-known {
allow all;
}
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
@gregorychalenko
gregorychalenko / crontab entry
Created July 9, 2016 17:52
backup multiple database
# backup tasks
# database backups
0 0 * * * /path/to/mysql.backup.sh -m dayly
0 1 * * 0 /path/to/mysql.backup.sh -m weekly
0 2 1 * * /path/to/mysql.backup.sh -m monthly
0 3 1 1 * /path/to/mysql.backup.sh -m yearly
@gregorychalenko
gregorychalenko / install-comodo-ssl-cert-for-nginx.rst
Created April 18, 2016 14:50 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

// tinyxhr by Shimon Doodkin - licanse: public doamin - https://gist.github.com/4706967
//
// tinyxhr("http://site.com/ajaxaction",function (err,data,xhr){ if (err) console.log("goterr ",err,'status='+xhr.status); console.log(data) });
// tinyxhr("http://site.com/ajaxaction",function (err,data,xhr){ if (err) console.log("goterr ",err,'status='+xhr.status); console.log(data) },'POST','value1=1&value2=2');
// tinyxhr("http://site.com/ajaxaction.json",function (err,data,xhr){ if (err) console.log("goterr ",err,'status='+xhr.status); console.log(data); console.log(JSON.parse(data)) },'POST',JSON.stringify({value:1}),'application/javascript');
// cb - a callback function like: function (err,data,XMLHttpRequestObject){ if (err) throw err; }
//
function tinyxhr(url,cb,method,post,contenttype)
{
<?php
// server
class MySoapServer
{
public function getMessage()
{
return 'Hello,World!';
}
/*
bootstrap multiple modal z-index fixer
*/
(function($){
// default zindex for modal
var zIndex=1070, zStep=10, recursion=0,
backgroundColor="black",
backdrop, nativeAppend = $.fn.appendTo;
$.fn.appendTo = function()
{

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@gregorychalenko
gregorychalenko / time_since
Last active August 29, 2015 13:56
time since. Pirms 5 stundam 20 minutem
<?php
function( $datestamp, $tail_length = 2 )
{
$interval = date_diff( date_create(), date_create( $datestamp ) );
$chunks = '%Y:%M:%d:%H:%i:%s';
$interval = array_filter(
array_combine( explode( ':', $chunks ), explode(":", $interval->format( $chunks ) ) ),
'intval'
);