Skip to content

Instantly share code, notes, and snippets.

extension Int {
func bottlesOfBeer() {
let bottles = "\(self) bottle" + (self == 1 ? "" : "s")
let what = " of beer on the wall"
println("\(bottles + what), \(bottles) of beer.")
print("Take one down, pass it around, ")
if self == 1 {
println("no more bottles\(what).")
@intari
intari / rescuetime_hg_commit_hook
Created May 25, 2015 05:06
Commit hook to log commit messages as highlights to RescueTime
#!/bin/sh
#
# Log commit messages as a 'highlight' in RescueTime Premium for Mercurial
#
# To enable this hook:
#
# 1. Get your API key from https://www.rescuetime.com/integrations/git
# 2. Place this file somewhere
# 3. Make sure it has executable permissions (chmod +x post-commit)
# 4. add line commit=path/to/this to [hooks] session of your .hgrc
@intari
intari / DrawerItemWithBadgeInCircle.java
Created June 11, 2015 06:16
Make it possible to use custom centered background resource in MaterialDrawer library
package com.viorsan.gists.example1
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
//
// TBKeychainCounter.h
//
// Created by Tal Bereznitskey on 5/11/13.
// Copyright (c) 2013 Tal Bereznitskey. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface TBKeychainCounter : NSObject
@interface UIWindow (resize)
-(void)_adjustSizeClassesAndResizeWindowToFrame:(CGRect)frame;
@end
typedef enum _UICustomRes
{
UICustomResiPadTwoThirds,
UICustomResiPadHalf,
UICustomResiPadOneThird,
UICustomResiPhone47,
@cpeppas
cpeppas / gist:b5ffe6bd29b67d96416a
Last active September 1, 2017 17:13
Espresso CustomMatcher to help test things like Actionbar title
import android.view.View;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import static org.hamcrest.Matchers.is;
public class CustomMatchers {
public static Matcher<View> withResourceName(String resourceName) {
@avbk
avbk / robo.md
Last active October 14, 2017 00:16
Testing with Robolectric within Android Studio

Testing with Robolectric within Android Studio

Prerequisites

0. Setup a project

Setup a new Android project with Android Studio. If you already have done this you can skip this step.

@kalloc
kalloc / patriot.sh
Last active December 5, 2017 21:36
#!/bin/bash
wget -q -O /tmp/ips http://reestr.rublacklist.net/api/ips || exit 404
HASH=$(md5sum /tmp/ips | awk '{print $1}')
HASH_LAST=$(cat /tmp/ips.hash)
if [[ $HASH == $HASH_LAST ]] && [[ $(ip ro list dev tun2) != "" ]];then
exit 304
fi
IPS=$(cat /tmp/ips | sed 's|;|\n|g' | /bin/grep -E ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$; cat /root/addition_ips)
for rule in $(ip ro list dev tun2 | awk '{print $1}');do

Computer science theory

  1. Что такое инвариант цикла?

  2. Что такое сложность алгоритма? O(n) нотация. O(???) для операций с NSArray, NSDictionary, запрос в БД (индексированный VS. неиндексированный)

  3. CS data structures (linked list, binary tree, array)

  4. Различия аутентификации, авторизации

@hpique
hpique / iOS7-notifications.h
Last active January 29, 2018 14:19
List of all public notifications available in iOS 7.0 (or at least those whose constants are properly named).
// Developer/Library/Frameworks/SenTestingKit.framework/Headers/SenTestCaseRun.h
SENTEST_EXPORT NSString * const SenTestCaseDidStartNotification;
SENTEST_EXPORT NSString * const SenTestCaseDidStopNotification;
SENTEST_EXPORT NSString * const SenTestCaseDidFailNotification;
// Developer/Library/Frameworks/SenTestingKit.framework/Headers/SenTestDistributedNotifier.h
SENTEST_EXPORT NSString * const SenTestNotificationIdentifierKey;
// Developer/Library/Frameworks/SenTestingKit.framework/Headers/SenTestSuiteRun.h
SENTEST_EXPORT NSString * const SenTestSuiteDidStartNotification;