Skip to content

Instantly share code, notes, and snippets.

View parkan's full-sized avatar

Arkadiy Kukarkin parkan

View GitHub Profile
@parkan
parkan / pre-commit
Created November 11, 2010 20:10 — forked from sztanpet/pre-commit
php pre-commit lint that doesn't break on deleted files
#!php
<?php
$files = array();
exec('git diff-index --cached --diff-filter=ACMRTUXB --name-only HEAD', $files );
$exitcode = 0;
// dont redirect stderr to stdin, we will get the errors twice, redirect it to dev/null
if ( PHP_OS == 'WINNT' )
$redirect = ' 2> NUL';
else
#!/opt/perlbrew/perls/current/bin/perl
use utf8;
use strict;
use warnings;
use v5.16;
use Algorithm::Permute;
use Data::Validate::IP;
@parkan
parkan / gist:8410301
Last active January 3, 2016 04:39
PHP's sequential/associative array behavior appears to depend on whether the array has a continuous, monotonically increasing sequence of indices starting at 0. Unsetting an index in the middle of the sequence will make the array behave associatively. Unsetting out of order indices such that order is restored (e.g. [0,2,1] to [0,1]) will restore…
php > $foo = [];
php > $foo[0] = 'zero';
php > $foo[1] = 'first';
php > $foo[0] = 'second';
php > var_dump($foo);
array(2) {
[0] =>
string(6) "second"
[1] =>
string(5) "first"
@parkan
parkan / faceboxgenders.txt
Last active August 29, 2015 13:57
facebox gender breakdown
male
----
model-002.jpg model-012.jpg model-023.jpg model-033.jpg model-045.jpg
model-003.jpg model-014.jpg model-025.jpg model-035.jpg model-047.jpg
model-004.jpg model-016.jpg model-026.jpg model-036.jpg model-049.jpg
model-006.jpg model-017.jpg model-027.jpg model-041.jpg model-050.jpg
model-007.jpg model-019.jpg model-031.jpg model-043.jpg
model-010.jpg model-021.jpg model-032.jpg model-044.jpg
female
@parkan
parkan / git-grep-blame.rb
Created August 14, 2014 21:33
Blame the output of a git-grep. Edited to work under ruby 2.1.X
#!/usr/local/bin/ruby
grep = `git grep -n #{ARGV[0]} #{ARGV[1]}`
interrupt = false
grep.split("\n").each do |file_with_line|
exit if interrupt
file, line_number, line = file_with_line.split(':', 3)
@parkan
parkan / gist:46e9057b49c4c835a148
Created October 6, 2014 17:30
twisted install failure (scrapy prereq)
[~]% pip install twisted (arkadiy@sodium:~)
Downloading/unpacking twisted
Downloading Twisted-14.0.2.tar.bz2 (4.3MB): 4.3MB downloaded
Running setup.py (path:/private/var/folders/sm/38kkrt9n5z5524hmxqn3h8yh0000gq/T/pip_build_arkadiy/twisted/setup.py) egg_info for package twisted
Downloading/unpacking zope.interface>=3.6.0 (from twisted)
Downloading zope.interface-4.1.1.tar.gz (864kB): 864kB downloaded
Running setup.py (path:/private/var/folders/sm/38kkrt9n5z5524hmxqn3h8yh0000gq/T/pip_build_arkadiy/zope.interface/setup.py) egg_info for package zope.interface
warning: no previously-included files matching '*.dll' found anywhere in distribution
@parkan
parkan / gist:e89f9d54533326ff94bd
Created December 5, 2014 17:57
Chromium contributor count
[0ff3a49...//src]% git remote -v (arkadiy@sodium:~/src/)
origin https://chromium.googlesource.com/chromium/src.git (fetch)
origin https://chromium.googlesource.com/chromium/src.git (push)
[0ff3a49...//src]% git shortlog -sn | wc -l (arkadiy@sodium:~/src/)
3385
@parkan
parkan / force.csv
Last active August 29, 2015 14:18 — forked from d3noob/.block
source target value
Harry Sally 100
Harry Sally 100
Harry Sally 100
Harry Mario 1.3
Sarah Alice 0.2
Eveie Alice 0.5
Peter Alice 1.6
Mario Alice 0.4
James Alice 0.6
@parkan
parkan / gist:0d75c363034db1ade31b
Last active August 29, 2015 14:24
Run a docker rails console container with heroku variables injected into ENV
# this replaces https://github.com/tpope/heroku-surrogate for docker containers (sort of)
docker-compose run `heroku config -a $APPNAME | tail +2 | tr -s " " | sed -E "s/^([^ ]+): (.+)/-e \1=\2/" | tr "\\n" " "` api rails c
@parkan
parkan / gist:6a4e74684feb828dddd6
Created July 13, 2015 16:53
onename verification
Verifying I am +arkadiy on my passcard. https://onename.com/arkadiy