Skip to content

Instantly share code, notes, and snippets.

matches_set = CommonSet.new(@mysql, @mongo, job)
method = (eval "#{job.args['method']}Method").new(@mysql, @mongo, user, matches_set)
@coodix
coodix / gist:3379015
Created August 17, 2012 14:16
Slow log parser
cat /var/log/php-fpm/php-slow.log | \
grep -v "/lib/vendor\|/lib/.*Filter\|cache/frontend\|+++ dump failed\|pool www\|script_filename" | \
cut -c 22- | grep "^$" -A 1 | grep "/" | \
grep `ls /srv/www/prod/releases/ | tac | head -1` | \
sort | uniq -c | sort -n | less
@coodix
coodix / gist:4147231
Created November 26, 2012 08:39
DO things happen
Было:
'<?xml version="1.0" encoding="UTF-8"?>
<response>
<status>0</status>
<iframeUrl>https://www.onlinedengi.ru/pay/bank_cards.php</iframeUrl>
<paymentId>117341518</paymentId>
<amountOriginal>553</amountOriginal>
<currency>RUB</currency>
<lang>rus</lang>
Array.prototype.getUnique = function(){
var u = {}, a = [];
for(var i = 0, l = this.length; i < l; ++i){
if(u.hasOwnProperty(this[i])) {
continue;
}
a.push(this[i]);
u[this[i]] = 1;
}
return a;
@coodix
coodix / CIAN.RU Add photos at List page
Last active December 16, 2015 07:59
Add flat photos thumbnails with zoom by mouseover at search result page at cian.ru Run this js code in browser console at cian.ru search result page
$.getScript('http://cdn.jsdelivr.net/jquery.lazyload/1.8.4/jquery.lazyload.js', function() {
var $popup = $('<div></div>').css({
position: 'fixed'
});
$('body').append($popup);
$('a[href*="/rent/flat/"]').lazyload({
threshold : 200,
appear: function(elements_left, settings) {
var $container = $(this).closest('div');
$.get($(this).attr('href'), function (data) {
@coodix
coodix / gist:5876005
Created June 27, 2013 12:21
CentOs 6 Install Repositories
cd /tmp
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm --import https://fedoraproject.org/static/0608B895.txt
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
@coodix
coodix / git-aliasses
Last active December 21, 2015 16:19 — forked from thenoseman/git-aliasses
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.st status
git config --global alias.br branch
@coodix
coodix / gist:6449660
Created September 5, 2013 12:48
Remove background and add shadow by ImageMagick
$ convert f4cf6efd198523859819d78c333b63d7.jpg -bordercolor white -border 1x1 -alpha set -channel RGBA -fuzz 1% -fill none -floodfill +0+0 white -shave 1x1 coin.png
$ convert coin.png \( +clone -background black -shadow 80x3+5+5 \) +swap -background none -layers merge +repage coin.png
@coodix
coodix / use-style
Last active December 22, 2015 21:59
Example of usinf use statement with PHP namespaces
<?php
// class User.php
namespace Billing;
class User {
...
}
@coodix
coodix / check_php_syntax
Created May 23, 2014 06:26
Check syntax in all php files
find ./ -name "*.php" -exec php -l {} \; | grep -v "No syntax"