This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://www.mikeash.com/?page=pyblog/friday-qa-2009-08-14-practical-blocks.html | |
// NSURLConnection | |
@implementation NSURLConnection (BlocksAdditions) | |
+ (void)sendAsynchronousRequest: (NSURLRequest *)request | |
completionBlock: (void (^)(NSData *data, NSURLResponse *response, NSError *error))block | |
{ | |
NSThread *originalThread = [NSThread currentThread]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How we store all time views across the entire system for http://gauge.es. | |
# All in one document that gets incremented using MongoDB $inc modifier in | |
# every track. The $inc increments t, year.t, year.month.t, year.month.day.t | |
# so we get to the day numbers. These are in EST, as we are in EST and these | |
# stats are just for us. :) Nothing amazing, but thought I would share. | |
# | |
# >> pp View.all_time | |
{ | |
"_id" => "all_time", | |
"t" => 502352, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Resque | |
def push_with_meta(queue, item) | |
if item.respond_to?(:[]=) | |
item[:meta] = {:queued_at => Time.now.to_f} | |
end | |
push_without_meta(queue, item) | |
end | |
class Job | |
# Returns a Hash of the meta data related to this Job. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Repo.Migrations.CreateProcedures do @doc """ | |
Creates procedure to get and update a local_id number on SaaS apps where | |
next local id is stored in the tenant table. | |
Example trigger is given for the user table | |
""" | |
use Ecto.Migration | |
def up do | |
execute "CREATE OR REPLACE FUNCTION get_local_id(tenant_id integer) RETURNS integer AS $$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
protocol Serializable { | |
static func deserializeInto(bytePtr: UnsafeMutablePointer<UInt8>, bytes: ArraySlice<UInt8>) -> ArraySlice<UInt8> | |
} | |
extension Serializable { | |
typealias WorkaroundSelf = Self | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/lol_json.rb | |
module ActiveSupport | |
module JSON | |
module Encoding | |
class JSONGemEncoder | |
BYPASS_JSONIFY = Set.new | |
alias_method :original_jsonify, :jsonify | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// CustomFontMetrics.swift | |
// | |
// Created by Zachary Waldowski on 6/6/17. | |
// Licensed under MIT. | |
// | |
import UIKit | |
private extension UITraitCollection { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Signal+Extensions.swift | |
// Khan Academy | |
// | |
// Created by Nacho Soto on 10/1/15. | |
// Copyright © 2015 Khan Academy. All rights reserved. | |
// | |
import ReactiveCocoa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import Combine | |
struct State { | |
var isCreatingItem: Bool = false | |
var partialItemName: String = "" | |
var todoItems: [TodoItem] = [] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Config for Nginx to act as a front-end for Riak | |
# The main goal is to proxy all GETs directly to Riak, and disallow anything else (POST, PUT, etc) | |
# Also, disallow use of the map/reduce query links (i.e. /riak/bucket/key/_,_,_) | |
# Config is in /etc/nginx/sites-available/default or somewhere like that | |
# Set up load-balancing to send requests to all nodes in the Riak cluster | |
# Replace these IPs/ports with the locations of your Riak nodes | |
upstream riak_hosts { | |
server 127.0.0.1:8098; |
OlderNewer