Skip to content

Instantly share code, notes, and snippets.

Avatar

Vladimir Grichina vgrichina

View GitHub Profile
View word_ladder.py
import string
class Solution:
# @param start, a string
# @param end, a string
# @param dict, a set of string
# @return an integer
def ladderLength(self, start, end, dict):
dict += [end]
View quicksort.swift
// Playground - noun: a place where people can play
import UIKit
let b = [1, 2, 3][1..2].filter { $0 < 3 }
let c = b + [5, 6]
func quicksort<T : Comparable>(arr : Array<T>) -> Array<T> {
if arr.count <= 1 {
return arr
View Dijkstra 5 lines
class Edge
attr_accessor :src, :dest, :length
def initialize(src, dest, length = 1)
@src = src
@dest = dest
@length = length
end
end
View CXBinder.h
//
// CXBinder.h
// TheList
//
// Created by Vladimir Grichina on 28.01.13.
// Copyright (c) 2013 TheList, LLC. All rights reserved.
//
#import <THObserversAndBinders/THBinder.h>
@vgrichina
vgrichina / NSObject+KVOWeakPropertyDebug.h
Created Jan 12, 2013
NSObject category that logs calls to addObserver for weak properties (as they aren't fully KVO-compliant)
View NSObject+KVOWeakPropertyDebug.h
//
// NSObject+KVOWeakPropertyDebug.h
// KVOWeakPropertyDebug
//
// Created by Vladimir Grichina on 12.01.13.
// Copyright (c) 2013 Vladimir Grichina. All rights reserved.
//
#import <Foundation/Foundation.h>
@vgrichina
vgrichina / CellBackgroundView.h
Created Nov 12, 2012
Customizable background view for UITableViewCell in grouped table view
View CellBackgroundView.h
//
// CellBackgroundView.h
//
//
#import <UIKit/UIKit.h>
typedef enum {
CellPositionTop,
CellPositionMiddle,
@vgrichina
vgrichina / gist:3968594
Created Oct 28, 2012
iPad mini simulation hack
View gist:3968594
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Some other stuff here ...
CGFloat scale = 4.71f/5.82f;
CGAffineTransform scaleTransform = CGAffineTransformMakeScale(scale, scale);
self.window.transform = CGAffineTransformConcat(scaleTransform, self.window.transform);
self.window.clipsToBounds = YES;
[self statusBarChanged:nil];
@vgrichina
vgrichina / gist:3416221
Created Aug 21, 2012
Deploy webapp to Tomcat on remote Windows machine
View gist:3416221
echo on
sc \\%SERVER_NAME% stop Tomcat7
rmdir /q /s %WEBAPPS_DIR%\%TARGET_PATH%
copy %WAR_FILE% %WEBAPPS_DIR%\%TARGET_PATH%.war
if errorlevel 1 goto Error
sc \\%SERVER_NAME% start Tomcat7
if errorlevel 1 goto Error
@vgrichina
vgrichina / .zshrc
Created Jul 10, 2012
ZSH Mercurial prompt
View .zshrc
function hg_prompt_info {
hg prompt --angle-brackets "\
<on %{$fg[magenta]%}<branch>%{$reset_color%}>\
< at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
%{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}<
patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
}
PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(hg_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%} '
View .gitconfig
[alias]
stage = !sh -c '[[ -z "$@" ]] && git add -u || git add "$@" && git add -u "$@" ' -
unstage = reset HEAD --
rewind = ![[ -z "$@" ]] && git reset --hard HEAD || git checkout HEAD