Skip to content

Instantly share code, notes, and snippets.

View a-square's full-sized avatar

Aleksei Averchenko a-square

View GitHub Profile
@a-square
a-square / .zshrc
Created March 5, 2012 15:41
.zshrc with themes fixed to change background color instead of foreground color
# Set up the prompt
autoload -Uz promptinit
promptinit
prompt adam1
color_fix_precmd() {
PS1="`echo "$PS1" | tr Kk Ff`"
PS2="`echo "$PS2" | tr Kk Ff`"
PS3="`echo "$PS3" | tr Kk Ff`"
PS4="`echo "$PS4" | tr Kk Ff`"
@a-square
a-square / .vimrc
Created March 14, 2012 06:15
My .vimrc
set hidden
set background=dark
let mapleader=","
set incsearch
set shortmess=atI
set t_Co=256 " set to force 256 colors on uncool terminals
" Allow cyrillic letters in commands
set langmap=ёйцукенгшщзхъфывапролджэячсмитьбюЁЙЦУКЕHГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ;`qwertyuiop[]asdfghjkl\\;'zxcvbnm\\,.~QWERTYUIOP{}ASDFGHJKL:\\"ZXCVBNM<>
@a-square
a-square / wombat256.vim
Created March 14, 2012 08:42
A variation of the wombat vim color scheme with the added support of 256 color terminals and much less italics. Generated with the help of vimfix.
" Maintainer: Lars H. Nielsen (dengmao@gmail.com)
" Last Change: January 22 2007
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
@a-square
a-square / vimfix.rb
Created March 14, 2012 08:48
Vimfix is a ruby script made to help port vim color schemes to xterm-256color terminals
#!/usr/bin/ruby
class Array
# classic implementation using the left fold
# from StackOverflow
def min_index
champ = self.each_with_index.inject([1000, 0]) do |c, (v, i)|
cv = c[0]; ci = c[1];
if v <= cv
[v, i]
@a-square
a-square / run.c
Created April 5, 2012 08:15
A program that allows you to run gui apps from the console without getting all of its output. E.g.: cd ~/work/a/b/c/; run ./gui-app param
#include <unistd.h>
#include <sys/types.h>
#include <sys/ioctl.h>
int main (int argc, char **argv)
{
pid_t pid;
int fd;
/*
@a-square
a-square / get-blip.pl
Created May 5, 2012 07:49
A blip.tv downloader
#!/usr/bin/perl
##########################################################################
# example: perl get-blip.pl http://spoonyexperiment.com/.../
#
# if it doesn't work, make sure you copied the url from the addres bar,
# not a link to avoid getting a redirection page
##########################################################################
use strict;
# myproject/config/initializers/handlebars_assets.rb
HandlebarsAssets::Config.path_prefix = 'backbone/templates'
@a-square
a-square / cs-scope.coffee
Last active December 12, 2015 07:19
Why explicit shadowing is important. Many people wrongfully claim that the same problem arises with defines in Scheme. It doesn't.
$('.test').each (i, e) ->
e = $(e)
content = e.find('.content') # Gee, I hope it's not global!
e.find('.refresh').on 'click', (e) ->
$.ajax {
method: 'GET',
url: 'http://example.com',
type: 'text'
success: (res) -> content.html(res)
@a-square
a-square / UIImageView-Cache-Then-Network.m
Last active August 29, 2015 14:05
More responsive UIImageView+AFNetworking using NSURLCache
// It's debatable if it's actually a good idea, because most of the time the image will be
// loaded from the cache without revalidation anyway, but it still has some utility in cases
// when max-age is short, or the image is big
//
// Also, it is more useful if we assume that max-age is smaller than the average user session,
// and that the iOS device never has to evict the images in the UIImageView+AFNetworking cache,
// because then *every* request for the image that actually goes through the NSURLCache will
// trigger the double request codepath. That being said, it's still probably excessive, because
// the amortised delay before the image is shown is still not affected much
- (void)setImageWithURLRequest:(NSURLRequest *)originalURLRequest
@a-square
a-square / run-oclint.sh
Created January 21, 2015 10:48
A modern CocoaPods-aware OCLint target script for Xcode
#
# parameters (including heuristic defaults)
#
if [ -z ${MY_SCHEME+x} ]
then
export MY_SCHEME=${PROJECT_NAME}
fi
if [ -z ${MY_WORKSPACE+x} ]