Skip to content

Instantly share code, notes, and snippets.

def incrementcount(word):
if wordcounts.get(word):
wordcounts[word] += 1
else:
wordcounts[word] = 1
# Can be replaced with:
wordcounts[word] = wordcounts.get(word, 0) + 1

Keybase proof

I hereby claim:

  • I am aitskovi on github.
  • I am aitskovi (https://keybase.io/aitskovi) on keybase.
  • I have a public key whose fingerprint is 4BC7 67CB 05F5 99CF BD49 1CF9 2E4A 4C85 7E97 EC9B

To claim this, I am signing this object:

@aitskovi
aitskovi / 0_reuse_code.js
Created January 29, 2014 19:52
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@aitskovi
aitskovi / varscope.js
Last active December 10, 2015 19:59
varscope
function invalid(a) {
var inner = function() {
console.log(a);
var a = '2';
console.log(a);
}
inner();
@aitskovi
aitskovi / NSObject_KVCExtensions.h
Created August 25, 2011 18:44
Key Value Coding - canSetValueForKey/KeyPath
#import <Foundation/Foundation.h>
@interface NSObject (NSObject_KVCExtensions)
- (BOOL)canSetValueForKey:(NSString *)key;
- (BOOL)canSetValueForKeyPath:(NSString *)keyPath;
@end
@aitskovi
aitskovi / NSObject_KVCExtensions.h
Created August 25, 2011 18:43
Key Value Coding - canSetValueForKey/KeyPath
#import <Foundation/Foundation.h>
@interface NSObject (NSObject_KVCExtensions)
- (BOOL)canSetValueForKey:(NSString *)key;
- (BOOL)canSetValueForKeyPath:(NSString *)keyPath;
@end
@aitskovi
aitskovi / NSObject_KVCExtensions.h
Created April 28, 2011 06:24
Key Value Coding - canSetValueForKey/KeyPath
#import <Foundation/Foundation.h>
@interface NSObject (NSObject_KVCExtensions)
- (BOOL)canSetValueForKey:(NSString *)key;
- (BOOL)canSetValueForKeyPath:(NSString *)keyPath;
@end
@aitskovi
aitskovi / GestureImage.m
Created March 4, 2011 05:03
A pannable, rotatable and zoomable image with gesture recognizers.
- (id)initWithImage:(UIImage *)image {
if ((self = [super initWithImage:image])) {
self.userInteractionEnabled = YES;
self.multipleTouchEnabled = YES;
_pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchRecognized:)];
[self addGestureRecognizer:_pinchGestureRecognizer];
_pinchGestureRecognizer.delegate = self;
_panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panRecognized:)];
[self addGestureRecognizer:_panRecognizer];
_panRecognizer.delegate = self;