Skip to content

Instantly share code, notes, and snippets.

@matan23
matan23 / gist:2816f5e34ee3b1fd2005
Created November 26, 2015 15:20 — forked from floriankugler/gist:6870499
Mapping of NSURLConnection to NSURLSession delegate methods. Created by Mattt Thompson.
NSURLConnection | NSURLSession
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDelegate connectionShouldUseCredentialStorage: |
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDelegate connection:willSendRequestForAuthenticationChallenge: | NSURLSessionDelegate URLSession:didReceiveChallenge:completionHandler:
| N
/*
* This is an example provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
@matan23
matan23 / SDCardManager.java
Created August 6, 2015 13:11
Check if true SDCard is mounted
String strSDCardPath = System.getenv("SECONDARY_STORAGE");
if ((null == strSDCardPath) || (strSDCardPath.length() == 0)) {
strSDCardPath = System.getenv("EXTERNAL_SDCARD_STORAGE");
}
try {
// Open the file
FileInputStream fs = new FileInputStream("/proc/mounts");
DataInputStream in = new DataInputStream(fs);
@matan23
matan23 / gist:6f78dad59f628437eddf
Created May 28, 2015 21:13
ios custom icon tintColor
UIImage *originalImage = [UIImage imageNamed:@"myiconname"];
UIImage *tintedImage = [originalImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UIImageView *imageView = [[UIImageView alloc] initWithImage:tintedImage];
imageView.tintColor = [UIColor redColor];
imageView.frame = CGRectMake(?, ?, ?, ?);
[self.view addSubview:imageView];
@matan23
matan23 / gist:9486482dc4f505a1c360
Created April 17, 2015 14:31
Unix - find and open xcode workspace
open `find . -name '*.xcodeproj' -prune -o -name '*.xcworkspace' -print`
# put this into your config/eydeploy.rb
def bundle
if File.exist?("#{c.release_path}/Gemfile")
info "~> Gemfile detected, bundling gems"
lockfile = File.join(c.release_path, "Gemfile.lock")
bundler_installer = if File.exist?(lockfile)
get_bundler_installer(lockfile)
else
warn_about_missing_lockfile
@matan23
matan23 / psql survival guide
Created February 26, 2014 22:39
psql survival guide
\d list dbs
\c 'mydatabase'
\d -> list tables
\d 'table'
@matan23
matan23 / gist:8956626
Last active August 29, 2015 13:56
Sinatra Exception Handling
class App < Sinatra::Base
configure :development do
set :raise_errors, true
#when set to true display a nice exception page for dev but prevent exception handler from working
set :show_exceptions, false
end
get '/someroute' do
MyModel.might_generate_an_exception

The Worker Pattern

Contents

  • Introduction
  • Definition
  • Examples
  • Links

Introduction

The Worker Pattern

Contents

  • Introduction
  • Definition
  • Examples
  • Links

Introduction