Skip to content

Instantly share code, notes, and snippets.

Avatar

Volodymyr Zhukov pironim

  • Epam
  • Kyiv, Ukraine
View GitHub Profile
@pironim
pironim / variance.md
Created Jul 7, 2016 — forked from maiermic/variance.md
Description of the four kinds of variance: covariance, contravariance, invariance and bivariance.
View variance.md

Variance

The term variance describes how subtyping between higher kinded types is related to subtyping relations of their type arguments.

Higher Kinded Types

A higher kinded type composes type arguments to a new type. I use square bracket notation to define a higher kinded type:

C[T] // The higher kinded type `C` composes type argument `T` to a new type `C[T]`.

The same works with multiple type arguments:

@pironim
pironim / UnlimitedJCEPolicyJDK8.sh
Last active Sep 27, 2017
apply UnlimitedJCEPolicyJDK8
View UnlimitedJCEPolicyJDK8.sh
JCE_DIR="$(dirname $(dirname $(readlink -f $(which javac))))/jre/lib/security"
echo JCE_DIR
# http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
# http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
# Dowload and unpack UnlimitedJCE policy files
View Vagrantfile
# Usage: IE={box} vagrant up
#
# Eg. IE=XPIE6 vagrant up
boxes = {
"XPIE6" => "http://aka.ms/vagrant-xp-ie6",
"XPIE8" => "http://aka.ms/vagrant-xp-ie8",
"VistaIE7" => "http://aka.ms/vagrant-vista-ie7",
"Win7IE8" => "http://aka.ms/vagrant-win7-ie8",
"Win7IE9" => "http://aka.ms/vagrant-win7-ie9",
View example.rb
require 'oauth_util.rb'
require 'net/http'
o = OauthUtil.new
o.consumer_key = 'examplek9SGJUTUpocjZ5QjBJmQ9WVdrOVVFNHdSR2x1TkhFbWNHbzlNQS0tJnM9Y29uc3VtkZXJzZWNyZXQmeD0yYg--';
o.consumer_secret = 'exampled88d4109c63e778dsadcdd5c1875814977';
url = 'http://query.yahooapis.com/v1/yql?q=select%20*%20from%20social.updates.search%20where%20query%3D%22search%20terms%22&diagnostics=true';
@pironim
pironim / gist:a4d43e0aba7a780dd02b
Created Oct 1, 2014
git pre-commit hook with debugger
View gist:a4d43e0aba7a780dd02b
# details here http://blog.kaygee79.com/git-pre-commit-hook-to-find-common-debug-functions-such-as-console-log-var_dump-and-print_r/
TEXT_DEFAULT="\\033[0;39m"
TEXT_INFO="\\033[1;32m"
TEXT_ERROR="\\033[1;31m"
TEXT_YELLOW="\\033[1;33m"
echo -e "$TEXT_YELLOW""[ >>> PRE-COMMIT START ]""$TEXT_DEFAULT"
FILES_PATTERN='(\..+)?$'
View vim-version-apt-get-vim-gtk
$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 4 2012 04:10:13)
Included patches: 1-429
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by buildd@
Huge version with GTK2 GUI. Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff
+digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi
@pironim
pironim / gist:2f578c60afb67f156136
Created Sep 16, 2014
git pre-commit hook to check branch name
View gist:2f578c60afb67f156136
#!/bin/bash
#
# Pre-commit hooks
# Check branch name
BRANCH_NAME_LENGTH=`git rev-parse --abbrev-ref HEAD | grep -E '^t[0-9]{2,16}\_.*_[A-Za-z]{2,2}$' | wc -c`
if [ ${BRANCH_NAME_LENGTH} -eq 0 ] ; then
echo -e '\E[37;44m'"\033[1mERROR\033[0m in pre-commit hook: vim /export/web/.git/hooks/pre-commit"
echo "Branch name should be like t00000_blah_blah_CA - brand is two letters"
View rails_load_path_tips.md

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

@pironim
pironim / gist:6239572
Last active Dec 21, 2015
git aliases
View gist:6239572
git config --global alias.br branch
git config --global alias.cp cherry-pick
git config --global alias.cm commit
git config --global alias.co checkout
git config --global alias.s status
@pironim
pironim / page for id
Created Jul 11, 2013
Kaminary find page for id
View page for id
# You should sort by uniq column to make your results predictable
def pagination_base
current_company.projects.order('name ASC, id ASC')
end
def page_for(id)
ids = pagination_base.pluck(:id)
position = ids.index(id.to_i)