Skip to content

Instantly share code, notes, and snippets.

View funkyboy's full-sized avatar

Cesare funkyboy

View GitHub Profile
target 'AblyTest' do
use_frameworks!
pod 'Ably', :git => 'https://github.com/ably/ably-ios.git', :branch => 'fix-memory-consumption-bug'
end
require 'sinatra'
get '/' do
puts "ua is #{request.user_agent}"
end
WWDC
AltConf
360iDev
CocoaConf
iOSDevUK
MDevCon (rebranding/renaming next year AFAIK)
MCE
NSNorth
YOW
CocoaLove (it's no more, probably won't make sense to include it)
@funkyboy
funkyboy / nginx.md
Last active October 6, 2016 08:10 — forked from joewiz/post-mortem.md
Recovery from nginx "Too many open files" error on Amazon AWS Linux

On Tue Oct 27, 2015, history.state.gov began buckling under load, intermittently issuing 500 errors. Nginx's error log was sprinkled with the following errors:

2015/10/27 21:48:36 [crit] 2475#0: accept4() failed (24: Too many open files) 2015/10/27 21:48:36 [alert] 2475#0: *7163915 socket() failed (24: Too many open files) while connecting to upstream...

An article at http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/ provided directions that mostly worked. Below are the steps we followed. The steps that diverged from the article's directions are marked with an *.

    • Instead of using su to run ulimit on the nginx account, use ps aux | grep nginx to locate nginx's process IDs. Then query each process's file handle limits using cat /proc/pid/limits (where pid is the process id retrieved from ps). (Note: sudo may be necessary on your system for the cat command here, depending on your system.)
  1. Added fs.file-max = 70000 to /etc/sysctl.conf
  2. Added `nginx soft nofile 1
@funkyboy
funkyboy / gist:625f9c3adcc65edf14cde392407b68cd
Last active June 24, 2016 18:40
One way to create a date formatter only once in Swift
class CheapDateFormatter {
private static let dateFormatter = NSDateFormatter()
static func formatter() -> NSDateFormatter {
dateFormatter.dateStyle = .MediumStyle // reconfiguring is as expensive as recreating
dateFormatter.timeStyle = .ShortStyle // not good for performance. See comments below.
return dateFormatter
}
@funkyboy
funkyboy / gist:9c7e3e06bea0625cb9b0e643e5498af2
Last active May 3, 2016 01:16
Circle view that progressively fills its border
import UIKit
import XCPlayground
let viewWidth: CGFloat = 300
var end: CGFloat = 0
let lineWidth: CGFloat = 20
let circleView = UIView(frame: CGRectMake(0, 0, viewWidth, viewWidth))
XCPlaygroundPage.currentPage.liveView = circleView
let circleLayer = CAShapeLayer()
let width = circleView.frame.size.width;
func pageViewController(pageViewController: UIPageViewController,
viewControllerBeforeViewController viewController: UIViewController) -> UIViewController? {
guard let viewControllerIndex = orderedViewControllers.indexOf(viewController) where viewControllerIndex > 0 else {
return nil
}
return orderedViewControllers[viewControllerIndex - 1]
}
protocol HomeBlockProtocol {
static func populate(dictionary: [String: AnyObject]) -> HomeBlockProtocol
}
@funkyboy
funkyboy / gist:c273c9d3767ea0e274a0
Created March 20, 2015 14:02
To run BaasBox on Docker
# To pull the image
docker pull funkyboy/baasbox:0.9.2
# To run
docker run -d -p 9000:9000 -v /folder/on/host/machine:/baasbox/db funkyboy/baasbox:0.9.2
[BAAUser loginWithUsername:@"test"
password:@"test"
completion:^(BOOL success, NSError *error) {
if (success) {
BAAClient *c = [BAAClient sharedClient];
[c postPath:@"/plugin/addcar.bb"
parameters:@{@"name" : @"ferrari"}
success:^(id responseObject) {