Skip to content

Instantly share code, notes, and snippets.

View vgrichina's full-sized avatar

Vladimir Grichina vgrichina

View GitHub Profile
@vgrichina
vgrichina / CellBackgroundView.h
Created November 12, 2012 21:39
Customizable background view for UITableViewCell in grouped table view
//
// CellBackgroundView.h
//
//
#import <UIKit/UIKit.h>
typedef enum {
CellPositionTop,
CellPositionMiddle,
@vgrichina
vgrichina / gist:3968594
Created October 28, 2012 13:27
iPad mini simulation hack
- (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 August 21, 2012 14:51
Deploy webapp to Tomcat on remote Windows machine
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 July 10, 2012 09:17
ZSH Mercurial prompt
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%} '
[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
@vgrichina
vgrichina / pidof
Created January 30, 2012 16:45
pidof for OS X
#!/bin/sh
if [ $# -ne 1 ] ; then
echo "Usage: $0 <processname>"
exit
fi
ps axc|awk "{if (\$5==\"$1\") print \$1}"|tr '\n' ' '
echo
@vgrichina
vgrichina / NetworkPhotoDataSource.h
Created January 30, 2012 11:13
Reusable data source for NIPhotoAlbumScrollView and NIPhotoScrubberView
//
// Copyright 2011 Jeff Verkoeyen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@vgrichina
vgrichina / PlistUtility.groovy
Created January 13, 2012 03:46
Simple OS X XML property list parser
import org.codehaus.groovy.grails.plugins.codecs.Base64Codec
class PlistUtility {
static parseXmlPlistText(String text) {
def xml = new XmlParser().parseText(text)
assert xml.name() == "plist"
def parseNode
parseNode = { node ->
@vgrichina
vgrichina / RunPlatformUnitTests.patch
Created November 15, 2011 00:27
Patch for RunPlatformUnitTests to allow running iOS application tests in Simulator using xcodebuild
*** /Developer/Platforms/iPhoneSimulator.platform/Developer/Tools/RunPlatformUnitTests 2011-08-30 06:49:13.000000000 +0300
--- /Developer/Platforms/iPhoneSimulator.platform/Developer/Tools/RunPlatformUnitTests.new 2011-11-15 02:21:59.000000000 +0200
***************
*** 90,101 ****
Configure_TEST_ARCHS
if [ "${TEST_HOST}" != "" ]; then
! Warning ${LINENO} "Skipping tests; the iPhoneSimulator platform does not currently support application-hosted tests (TEST_HOST set)."
--langdef=objc
--langmap=objc:.m
--regex-objc=/^[\t ]*(\-|\+)[\t ]*\([_a-zA-Z0-9][_a-zA-Z0-9]*\)([_a-zA-Z0-9][_a-zA-Z0-9]*)/\2/f/