Skip to content

Instantly share code, notes, and snippets.

View keltanas's full-sized avatar
🇷🇺
justice will be served

Ke7Tana5 keltanas

🇷🇺
justice will be served
  • Saint Petersburg
View GitHub Profile
@keltanas
keltanas / RabbitSetupMQ.md
Created April 30, 2015 18:28
RabbitSetupMQ

Setup Rabbit MQ on Ubuntu

sudo nano /etc/apt/sources.list

add to end file

deb http://www.rabbitmq.com/debian/ testing main

add public key

@keltanas
keltanas / account2pdf.php
Created June 13, 2012 22:45
Example export account to pdf
<?php
set_include_path($_SERVER['DOCUMENT_ROOT']);
require_once 'engine.php';
// подключаем библиотеку
require_once('tcpdf/config/lang/rus.php');
require_once('tcpdf/tcpdf.php');
//require_once('../class/imo_account_pdf.php');
@keltanas
keltanas / example001.js
Created August 13, 2012 15:57
Пример смены контекста
for ( n=1; n<=3; n++ ){
$.get( url, $.proxy( function( n, data ){
console.log(arguments, n, data);
}, n));
}
@keltanas
keltanas / gravatar.php
Created September 9, 2012 23:46
Gravatar request example
<?php
/**
* Gravatar request example
* @author Nikolay Ermin <nikolay@ermin.ru>
* @link http://siteforever.ru
*/
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
<?php
//...
function settingCONF_BYCOUNTRY_BYZONE_FORM($module_id)
{
$curr_country = isset($_POST["shipping_module_bycountry_byzone_country"]) ? $_POST["shipping_module_bycountry_byzone_country"] : 0;
$curr_country = (int) $curr_country;
if(!$curr_country){
$curr_country = xGetData('SXshipping_module_bycountry_byzone_country'.$module_id);
@keltanas
keltanas / gist:4182125
Last active October 13, 2015 10:28
В чем разница?
<?php
// <= PHP 5.2
$cities = array_filter($cities,create_function('$v','return count($v);'));
// >= PHP 5.3
$cities = array_filter($cities,function($v){return count($v);});
// VS
@keltanas
keltanas / testClosure.php
Created December 13, 2012 17:36 — forked from anonymous/testClosure.php
Вернем анонимную функцию, которая берет $this от родительского метода и возвращает его. Работает в PHP 5.4+ Демонстрирует видимость переменной $this в замыкании (в PHP 5.3 замыкать объект приходится через техническую переменную)
<?php
class test
{
public function do_test()
{
return function() {
return $this;
};
}
}
/**
* Configured View for jQGrig
* @author: Nikolay Ermin <keltanas@gmail.com>
*/
define("Keltanas/GridView", [
"jquery",
"underscore",
"backbone",
"jqgrid/jquery.jqGrid"
], function ($, _, Backbone) {
#!/bin/sh
# /etc/init.d/teamcity - startup script for teamcity
export TEAMCITY_DATA_PATH="/home/keltanas/.BuildServer"
#sudo -u keltanas
case $1 in
start)
echo "Starting Team City"
start-stop-daemon --start -c keltanas --exec /opt/TeamCity/bin/runAll.sh start
@keltanas
keltanas / true_closure.py
Created December 24, 2012 18:20
Передаем ссылку на объект через лямда-функцию
__author__ = 'keltanas'
class closure:
def get_me(self):
return lambda : self
inst_test = closure()
me = inst_test.get_me()
del inst_test