Skip to content

Instantly share code, notes, and snippets.

View Koc's full-sized avatar
🇺🇦
Donate to United24 or Come Back Alive

Konstantin Myakshin Koc

🇺🇦
Donate to United24 or Come Back Alive
  • METRO Markets GmbH
  • Ukraine, Kyiv
  • X @myakshin
View GitHub Profile
@Koc
Koc / ips.txt
Last active August 29, 2015 14:26
metalloprokat@metalloprokat1:/data/www/metalloprokat.ru$ sudo cat /var/log/apache2/metalloprokat.ru-access.log | cut -d " " -f 1 | sort | uniq -c | sort -g -r | head -50
[sudo] password for metalloprokat:
5583374 10.1.142.101 10.1.142.101
58697 130.193.48.24 spider-130-193-48-24.yandex.com
58246 37.140.141.49 spider-37-140-141-49.yandex.com
57944 5.255.253.105 spider-5-255-253-105.yandex.com
57170 5.255.253.191 spider-5-255-253-191.yandex.com
55781 95.108.158.184 spider-95-108-158-184.yandex.com
51520 5.255.253.153 spider-5-255-253-153.yandex.com
@Koc
Koc / user.js
Created June 1, 2015 11:32
Google Open Search Result In Nes Tab
// ==UserScript==
// @name Google Open Search Result In Nes Tab
// @version 0.1
// @author Konstantin Myakshin
// @grant none
//
// @include *://www.google.*/*q=*
// @include *://www.google.*/*tbs=*
// @include *://www.google.*/search?*
// @include *://www.google.*/webhp?*
@Koc
Koc / typeahead.js
Created September 11, 2014 15:42
Typeahead prefetch filtering example
$el.typeahead({
minLength: 2,
autoselect: true,
hint: false,
highlight: true
}, {
source: function(query, cb) {
suggestSource.ttAdapter()(query, function(items) {
var filteredItems = [];
angular.forEach(items, function(item) {
// An example controller binded to the form
function FormCntl($scope, $compile) {
// Consider using FosJsRouting bundle, if you want to use a Symfony2 route
$scope.formUrl = "http://url-to-fetch-my-form";
// Data from the form will be binded here
$scope.data = {};
// Method called when submitting the form
$scope.submit = function() {
@Koc
Koc / gist:5812828
Last active December 18, 2015 16:39 — forked from anonymous/gist:5803875
/usr/local/bin/fake-sendmail
#!/usr/bin/php
<?php
$processUser = posix_getpwuid(posix_geteuid());
$name = $processUser['dir'].'/mail/'.date('Y-m-d H:i:s').'-'.microtime(true).'.eml';
if (!is_dir($dir = dirname($name))) {
mkdir($dir, 0777, true);
}
$fh = fopen($name, "w");
if (!$fh) {
die(1);
@Koc
Koc / css.css
Last active December 17, 2015 19:39
markup examples
/* <div class="main-header">...</div> - плохо */
.main-header:after,
.main-header .top-panel-inner:after,
.main-menu-list:after,
.wrapper:after,
.main-footer .footer-inner:after,
.category-title:after,
.products-list:after,
.checkout-form:after,
.product-title:after,
@Koc
Koc / 1-schema.sql
Last active December 14, 2015 09:19
DROP TABLE IF EXISTS company;
CREATE TABLE company (
id INT(11) NOT NULL AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
rating INT(11) NOT NULL,
is_paid TINYINT(1) NOT NULL,
PRIMARY KEY (id)
)
ENGINE = INNODB;
@Koc
Koc / 1. infrastructure.php
Created November 6, 2012 22:25
Doctrine2 bulk inserts
<?php
use Doctrine\ORM\Persisters;
class DoctrineHelper
{
protected $entityManagers = array();
public function bulkCommit(EntityManager $em, array $entities)
{
@Koc
Koc / gist:3016704
Created June 29, 2012 08:42
Doctrine2 DISTANCE function
<?php
namespace Myako\Geographical\Functions;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
/**
* "DISTANCE" "(" LatitudeFrom, LongitudetFrom, LatitudeTo, LongitudeTo ")"
*
@Koc
Koc / bijective.php
Created March 26, 2012 12:56 — forked from xeoncross/bijective.php
URL shortener
<?php
class Bijective
{
public $dictionary = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
public function __construct()
{
$this->dictionary = str_split($this->dictionary);
}