Skip to content

Instantly share code, notes, and snippets.

View oleganza's full-sized avatar

Oleg Andreev oleganza

View GitHub Profile
@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 <[email protected]>
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.
@oleganza
oleganza / NSData+OADataHelpers.m
Last active December 9, 2022 03:50
Creating NSString from NSData by fixing invalid UTF8 characters
// Author: Oleg Andreev <[email protected]>
// May 28, 2011
// Do What The Fuck You Want Public License <http://www.wtfpl.net>
#import "NSData+OADataHelpers.h"
#if !__has_feature(objc_arc)
#error ARC must be enabled!
#endif
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"
#import "NSData+OADataHelpers.h"
@implementation NSData (OADataHelpers)
- (NSString*) UTF8String
{
return [[[NSString alloc] initWithData:[self dataByHealingUTF8Stream] encoding:NSUTF8StringEncoding] autorelease];
}
// Replaces all broken sequences by � character and returns NSData with valid UTF-8 bytes.
def go_shopping
buy_gloves do
buy_shoes do
buy_coat do
yield
end
end
eat_sandwitch do # in parallel to buying shoes
drink_coke do
yield