Skip to content

Instantly share code, notes, and snippets.

View oleganza's full-sized avatar

Oleg Andreev oleganza

View GitHub Profile
// Oleg Andreev <oleganza@gmail.com>
#import <Foundation/Foundation.h>
@interface NSData (BTC)
// Init with securely random byte string from /dev/random
- (id) initRandomWithLength:(NSUInteger)length;
// Init with zero-terminated string in UTF-8 encoding.
Apr. 25 2013 15:30 CEST UPDATE
Dear all, we'd like to give everyone an update as to what exactly is happening, has happened, and will happen in relation to the recent events at Bitcoin-Central.net.
Here are a few questions that require an immediate answer.
Have funds been lost?
A few hundred Bitcoins have been stolen from our hot wallet.
@oleganza
oleganza / gist:3404669
Created August 20, 2012 14:18
Modern Objective-C
// 2011:
[container setObject:value forKey:[NSString stringWithFormat:@"%d", number]];
// 2012:
container[@(number).stringValue] = value;
@oleganza
oleganza / rss-to-opml.rb
Created July 31, 2012 08:30
Mountain Lion RSS -> OPML
#!/usr/bin/env ruby
#
# Script outputs OPML ready to be uploaded to Google Reader or a RSS app.
# Run in Terminal: $ ruby rss-to-opml.rb > myfeeds.opml
# In Google Reader, go to Settings ("gear button") -> Import/Export -> Upload OPML.
# Enjoy.
#
# Oleg Andreev, July 31, 2012.
require 'CGI'
@oleganza
oleganza / NSObject+OASelectorNotifications.h
Created August 25, 2011 11:43
NSObject+OASelectorNotifications.h
/*
Oleg Andreev <oleganza@gmail.com>
January 25, 2011
With NSNotificationCenter you post notifications with a name like MyNotification.
Observer subscribes to this name with some selector like myNotification:
To make things easier and less verbose, we won't declare notification names, but only the selectors.
NSEvent* pingEvent = [NSEvent otherEventWithType:NSApplicationDefined
location:NSMakePoint(0, 0)
modifierFlags:0
timestamp:0
windowNumber:0
context:nil
subtype:0
data1:0
data2:0];
// Returns a new block which calls first and second blocks
void(^OABlockConcat(void(^block1)(), void(^block2)()))()
{
block1 = [[block1 copy] autorelease];
block2 = [[block2 copy] autorelease];
if (!block1) return block2;
if (!block2) return block1;
void(^block3)() = ^{
@interface GBStageShortcutHintDetector : NSObject
+ (GBStageShortcutHintDetector*) detectorWithView:(NSView*)aView;
// A view which should be hidden by default and shown with a tip
@property(nonatomic, retain) NSView* view;
// A callback from the similar delegate
Piotr Petrus
And by God, I’ve been waiting for an app like this for ages.
@FrogBawt
Gitbox — Git version control on the Mac - Now this is just sexy, why must Mac users mock me like this?
@brennannovak:
GitBox finally a glorious Gui Mac app for managing git repositories http://gitboxapp.com thank the lord!
http://news.ycombinator.com/user?id=makeramen:
@oleganza
oleganza / break_in_block.rb
Created January 18, 2011 08:43
This sample shows strange Ruby 1.8.7 behaviour when "break" happens inside a block
def a
begin
yield
rescue Exception => e
puts "a: rescue => #{e}"
else
puts "a: no exception"
ensure
puts "a: ensure"