Skip to content

Instantly share code, notes, and snippets.

View radex's full-sized avatar
🚀
Full reusability

Radek Pietruszewski radex

🚀
Full reusability
View GitHub Profile
@radex
radex / gist:4537623
Last active December 11, 2015 03:28
CSS-like hex notation colors in Objective C
// header
#ifdef TARGET_OS_IPHONE
#define NativeColor UIColor
#else
#define NativeColor NSColor
#endif
NativeColor* hexColor(int hex);
NativeColor* hexaColor(int hex, float a);
@radex
radex / MASShortcut.podspec
Last active December 11, 2015 21:58
Podfile for (up-to-date) MASShortcut library
Pod::Spec.new do |s|
s.name = "MASShortcut"
s.version = "1.1.1"
s.summary = "Modern framework for managing global keyboard shortcuts compatible with Mac App Store."
s.description = <<-DESC
Some time ago Cocoa developers used a brilliant framework ShortcutRecorder for managing keyboard shortcuts in application preferences. However, it became incompatible with a new plugin architecture of Xcode 4.
The project MASShortcut introduces modern API and user interface for recording, storing and using global keyboard shortcuts. All code is compatible with Xcode 4.3, Mac OS X 10.7 and the sandboxed environment.
DESC
s.homepage = "http://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-in-cocoa.html"
@radex
radex / gist:4955049
Created February 14, 2013 18:30
Add that to a class that you want to use as a singleton object across multiple XIB files. If you have an init method, you might want to make sure you don't re-initialize the object that's already been initialized. Warning: feels like magic
+ (id) allocWithZone:(NSZone *)zone
{
static id globalInstance;
if(!globalInstance)
{
globalInstance = [super allocWithZone:zone];
}
return globalInstance;
Pod::Spec.new do |s|
s.name = "MASPreferences"
s.version = "1.0.1"
s.summary = "Custom implementation of Preferences window in Cocoa applications for Mac OS X."
s.homepage = "https://github.com/shpakovski/MASPreferences"
s.license = "BSD"
s.author = "Vadim Shpakovski"
s.source = { :git => "https://github.com/shpakovski/MASPreferences.git", :commit => 'efeaf31ffb917240b1de0a38ed8c3e110a66866e' }
s.platform = :osx
RACSequence *normalizedLongWords = [[words.rac_sequence
filter:^ BOOL (NSString *word) {
return [word length] >= 10;
}]
map:^(NSString *word) {
return [word lowercaseString];
}];
normalized = words.select { |w| w.length >= 10 }.map { |w| w.downcase }
@radex
radex / comprehensions.coffee
Created March 23, 2013 08:34
Playing around with CoffeeScript's comprehensions. Not practical to nest them like that, but definitely fun that it's even possible!
text = """Messiah (HWV 56) is an English-language oratorio composed in 1741 by George Frideric Handel, with a scriptural text compiled by Charles Jennens from the King James Bible and the Book of Common Prayer. Messiah was first performed in Dublin in 1742, and received its London premiere the following year. After an initially modest public reception, the oratorio gained in popularity, becoming one of the most frequently performed choral works in Western music. Although its structure resembles that of opera, it is not in dramatic form, but a reflection on Jesus Christ as Messiah. Handel begins Part I with prophecies by Isaiah and others, and moves to the annunciation to the shepherds, the only "scene" taken from the Gospels. In Part II he concentrates on the Passion and ends with the Hallelujah Chorus. In Part III he covers the resurrection of the dead and Christ's glorification in heaven. Handel wrote Messiah for modest vocal and instrumental forces; after his death, the work was adapted for performance wit
@radex
radex / comprehensions2.coffee
Created March 23, 2013 09:53
Playing around with CoffeeScript's comprehensions and inline conditions some more… Again, it's not the most readable and practical way to implement it, but it's fun to test the edges of what the language can do
text = """Messiah (HWV 56) is an English-language oratorio composed in 1741 by George Frideric Handel, with a scriptural text compiled by Charles Jennens from the King James Bible and the Book of Common Prayer. Messiah was first performed in Dublin in 1742, and received its London premiere the following year. After an initially modest public reception, the oratorio gained in popularity, becoming one of the most frequently performed choral works in Western music. Although its structure resembles that of opera, it is not in dramatic form, but a reflection on Jesus Christ as Messiah. Handel begins Part I with prophecies by Isaiah and others, and moves to the annunciation to the shepherds, the only "scene" taken from the Gospels. In Part II he concentrates on the Passion and ends with the Hallelujah Chorus. In Part III he covers the resurrection of the dead and Christ's glorification in heaven. Handel wrote Messiah for modest vocal and instrumental forces; after his death, the work was adapted for performance wit
@radex
radex / compile_xcode.sh
Created March 28, 2013 20:38
Coding some part of an Xcode project in TextMate? Tired of constantly switching between TM and Xcode to compile it? Create this command in your TextMate bundle:
#!/bin/zsh
osascript <<SCRIPT
tell application "Xcode"
activate
end tell
tell application "System Events"
tell application process "Xcode"
click menu item "Stop" of menu 1 of menu bar item "Product" of menu bar 1
Pod::Spec.new do |s|
s.name = 'CocoaLumberjack'
s.version = '1.6.1'
s.license = 'BSD'
s.summary = 'A fast & simple, yet powerful & flexible logging framework for Mac and iOS.'
s.homepage = 'https://github.com/robbiehanson/CocoaLumberjack'
s.author = { 'Robbie Hanson' => 'robbiehanson@deusty.com' }
s.source = { :git => 'https://github.com/robbiehanson/CocoaLumberjack.git',
:commit => 'b5fbf2da1fa35f208683f9afa441b071cc621cd0' }