Skip to content

Instantly share code, notes, and snippets.

View 1999's full-sized avatar

Dmitrii Sorin 1999

View GitHub Profile
@1999
1999 / gist:2602021
Created May 5, 2012 12:31
AWS SES php example
<?php
date_default_timezone_set( 'Europe/Moscow' );
ini_set( 'memory_limit', '1024M' );
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, 'https://email.us-east-1.amazonaws.com' );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_HEADER, true );
@1999
1999 / grayscale.js
Created March 6, 2012 07:44
HTML5 grayscale images
function grayscale(src) {
var canvas = document.createElement("canvas"),
ctx = canvas.getContext("2d"),
imgPixels, x, y, i, avg;
var imgObj = new Image();
imgObj.src = src;
canvas.width = imgObj.width;
canvas.height = imgObj.height;
@1999
1999 / gist:1835570
Created February 15, 2012 13:04
Proxy API implementation example
/**
* Proxy API implementation example
* @link https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Proxy
*/
let proxyHandlerMaker = function(obj) {
return {
// Fundamental traps
getOwnPropertyDescriptor: function(name) {
var desc = Object.getOwnPropertyDescriptor(obj, name);
// a trapping proxy's properties must always be configurable
@1999
1999 / gist:1442317
Created December 7, 2011 10:30
Javascript geohash implementation
Array.prototype.average = function() {
var i, len, sum = 0;
for (i=0, len=this.length; i<len; i++) {
sum += this[i];
}
return sum / this.length;
};
@1999
1999 / md5.js
Created August 3, 2011 10:31
MD5 method for String object
String.prototype.md5 = function() {
var safe_add = function(x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
var rol = function(num, cnt) {
return (num << cnt) | (num >>> (32 - cnt));
@1999
1999 / gist:1042431
Created June 23, 2011 12:10
map-reduce на выборку последних веток комментов
{
map: function(doc) {
if (doc.subtype === 'pm') {
return;
}
if (typeof doc.private !== 'undefined' && doc.private === 1) {
return;
}
@1999
1999 / gist:738943
Created December 13, 2010 12:26
php-fpm
./configure \
--prefix=/opt/php \
--sysconfdir=/etc/opt/php \
--enable-fpm \
--disable-cgi \
--with-config-file-path=/etc/opt/php \
--with-config-file-scan-dir=/etc/opt/php/conf.d/ \
--enable-zip \
--with-gettext \
--disable-ftp \
<?php
$cnn = new AMQPConnect();
# подсоединяемся
$exch = new AMQPExchange( $cnn );
$exch->declare( 'testing', 'direct', AMQP_DURABLE );
if ( true === isset( $_GET['publish'] ) ) {
for ( $i=1; $i<=5; $i++ ) {
We couldn’t find that file to show.
./configure \
--prefix=/opt/local \
--conf-path=/etc/opt/nginx/nginx.conf \
--pid-path=/opt/local/var/run/nginx.pid \
--error-log-path=/opt/local/var/log/nginx/error.log \
--http-log-path=/opt/local/var/log/nginx/access.log \
--user=ubuntu \
--group=ubuntu
# libssl-dev - библиотека для md5 функций OpenSSL