Skip to content

Instantly share code, notes, and snippets.

Avatar

Eloy Durán alloy

View GitHub Profile
View sort_imports
#!/usr/bin/env ruby
require 'pathname'
code_files = ARGV
code_files.each do |file|
file = Pathname(file)
contents = file.read
contents.gsub!(/(^#import .*\n)+/) do |imports|
imports = imports.split("\n")
imports.map! do |import|
View options.rb
# Option 1
info = if publication
"Title: #{ publication.title } (ID: #{ publication.id })"
else
'N/A'
end
# Option 2
info = case publication
when Publication then puts "Title: #{ publication.title } (ID: #{ publication.id })"
@alloy
alloy / 4.rb
Last active Aug 29, 2015 — forked from anonymous/4.rb
View 4.rb
module ProMotion
class StaticPageView < PageView
def self.method_missing(method_name, obj_or_klass, *args)
options = args.last if args.last.is_a?(Hash)
options ||= {}
# then do rest
end
end
end
@alloy
alloy / 0_reuse_code.js
Created Jan 30, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View PLCrashReporter.podspec
Pod::Spec.new do |s|
s.name = "PLCrashReporter"
s.version = "1.2-rc2"
s.summary = "Reliable, open-source crash reporting for iOS and Mac OS X."
s.description = <<-DESC
Plausible CrashReporter provides an in-process crash reporting
framework for use on both iOS and Mac OS X, and powers many of
the crash reporting services available for iOS, including HockeyApp,
Atlassian JMC, Crittercism, and Flurry.
View cocoapods_public_headers.rb
require 'rubygems'
require 'cocoapods-downloader'
require 'cocoapods-core'
require 'cocoapods'
@spec = Pod::Spec.new do |s|
s.name = "MSActiveConfig"
s.version = "1.0.1"
s.summary = "Remote configuration and A/B Testing framework for iOS."
s.homepage = "https://github.com/mindsnacks/MSActiveConfig"
View gist:5830240
When he’s not sorting coloured LEDs, soldering DIY synthesisers,
or sharing/forcing his extensive hands-on ‘X design’/browser experience
knowledge with/on the twittersphere, he leads a small app consultancy
shop known for their continuous striving for doing things well.
View gcd_map.mm
#import <Foundation/Foundation.h>
#import <libkern/OSAtomic.h>
@interface NSArray (ConcurrentMap)
- (NSArray*)semaphore_map:(id (^)(id))block;
- (NSArray*)serial_map:(id (^)(id))block;
- (NSArray*)spinlock_map:(id (^)(id))block;
- (NSArray*)direct_map:(id (^)(id))block;
@end
View gist:5412471
Pod::Spec.new do |spec|
spec.name = 'DTLoupe'
spec.version = '1.3.0'
spec.platform = :ios, '4.3'
spec.license = 'COMMERCIAL'
spec.source = { :git => 'git@git.cocoanetics.com:parts/dtloupe.git', :tag => spec.version.to_s }
spec.source_files = 'Core/Source/*.{h,m}'
spec.frameworks = 'QuartzCore'
spec.requires_arc = true
spec.homepage = 'http://www.cocoanetics.com/parts/dtloupeview/'
@alloy
alloy / gist:4267777
Created Dec 12, 2012 — forked from anonymous/gist:4267712
Define hookable API in module that’s included, this way other clients can include a module that overrides those hooks. Because including modules inserts the methods in the ancestor lookup chain (i.e. the power of Ruby), this allows the use of super etc.
View gist:4267777
module APIExposable
def expose_api(mod = nil, &block)
if mod.nil?
if block.nil?
raise "Either a module or a block that's used to create a module is required."
else
mod = Module.new(&block)
end
elsif mod && block
raise "Only a module *or* is required, not both."
You can’t perform that action at this time.