Skip to content

Instantly share code, notes, and snippets.

@bromanko
bromanko / gist:1520474
Created December 26, 2011 03:24
GCD Implementation
- (AQGridViewCell *)gridView:(AQGridView *)gridView cellForItemAtIndex:(NSUInteger)index {
switch ([self numberOfItemsInGridView:gridView] - index) {
case 2:
// Favorites cell
return [TopicListViewController favoritesCell];
case 1:
// Add cell
return [TopicListViewController addCell];
default: {
// Topic cells
@bromanko
bromanko / clone-rackspace-container.js
Created February 20, 2012 16:28
Cloudfiles Copy Container
var cloudfiles = require('cloudfiles');
request = require('request');
// CloudFiles client configuration
var configCloudFiles = {
auth: {
username: '',
apiKey: '',
host: 'auth.api.rackspacecloud.com'
}
** [out :: dashboard.onpremisewine.com] config/schedule.rb:50:in `block in initialize'
** [out :: dashboard.onpremisewine.com] : undefined local variable or method `send_broken_pos_notifications' for #<Whenever::JobList:0x00000001a35f60> (NameError)
** [out :: dashboard.onpremisewine.com] from /www/tastevin-web/shared/bundle/ruby/1.9.1/gems/whenever-0.7.3/lib/whenever/job_list.rb:38:in `every'
** [out :: dashboard.onpremisewine.com] from config/schedule.rb:49:in `initialize'
** [out :: dashboard.onpremisewine.com] from /www/tastevin-web/shared/bundle/ruby/1.9.1/gems/whenever-0.7.3/lib/whenever/job_list.rb:19:in `instance_eval'
** [out :: dashboard.onpremisewine.com] from /www/tastevin-web/shared/bundle/ruby/1.9.1/gems/whenever-0.7.3/lib/whenever/job_list.rb:19:in `initialize'
** [out :: dashboard.onpremisewine.com] from /www/tastevin-web/shared/bundle/ruby/1.9.1/gems/whenever-0.7.3/lib/whenever.rb:15:in `new'
** [out :: dashboard.onpremisewine.com] from /www/tastevin-web/shared/bundle/ruby/1.9.1/gems/
#!/usr/bin/env node
require('coffee-script');
var env = require('./config/env')
, restify = require('restify')
, repl = require('repl').start()
, util = require('util');
repl.context.inspect = util.inspect;
@bromanko
bromanko / gist:2695108
Created May 14, 2012 17:07
ARC or Not
#if !__has_feature(objc_arc)
#define NonatomicRetainedSetToFrom(a, b) do{if(a!=b){[a release];a=[b retain];}}while(0)
#define NonatomicCopySetToFrom(a, b) do{if(a!=b){[a release];a=[b copy];}}while(0)
#else
#define NonatomicRetainedSetToFrom(a, b) do{if(a!=b){a=b;}}while(0)
#define NonatomicCopySetToFrom(a, b) do{if(a!=b){a=[b copy];}}while(0)
#endif
@bromanko
bromanko / test.js
Created July 24, 2012 18:05
node restify HTTPClient multipart form upload
it('should return a BadRequestError if photo is not sent on post to /users/me/photos', function(done) {
var options = {
path: '/users/me/photos',
headers: {
'Content-Type': 'multipart/form-data; boundary=Boundary+0xAbCdEfGbOuNdArY'
}
};
common.httpClient(testUser).post(options, function(err, req) {
req.on('result', function(err, res) {
@bromanko
bromanko / UIImage+Retina4.h
Created September 26, 2012 14:55 — forked from bstahlhood/UIImage+Retina4.h
Swizzled UIImage imageNamed for iPhone 5
//
// UIImage+Retina4.h
// StunOMatic
//
// Created by Benjamin Stahlhood on 9/12/12.
// Copyright (c) 2012 DS Media Labs. All rights reserved.
//
#import <UIKit/UIKit.h>
@bromanko
bromanko / index.js
Created October 25, 2012 14:45
Express Middleware for Bunyan logging
var bunyan = require('bunyan');
module.exports.logger = function logger(log) {
if (typeof (log) !== 'object')
throw new TypeError('log (Object) required');
this.log = log;
var self = this;
return function logger(req, res, next) {
@bromanko
bromanko / S3Upload.mm
Last active December 12, 2016 02:07
File uploading directly to S3 from an iOS app.
AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"https://YOUR_BUCKET.s3.amazonaws.com/"]];
NSDictionary *parameters = @{
@"key": @"uploads/${filename}",
@"AWSAccessKeyId": @"YOUR_AWS_ACCESS_KEY",
@"acl": @"public-read", // or private
@"success_action_redirect": @"http://localhost/",
@"policy": @"YOUR_POLICY_DOCUMENT_BASE64_ENCODED",
@"signature": @"YOUR_CALCULATED_SIGNATURE",
@"Content-Type": @"image/jpeg"

Please publicly post the following Gist, and name it keybase.md

Keybase proof

I hereby claim:

  • I am bromanko on github.
  • I am bromanko (https://keybase.io/bromanko) on keybase.
  • I have a public key ASC9xLX6pFZXnQ0858HBMyeCl6kIoPMOHEWJ95hqr59JFgo