extension CLLocation: Encodable { | |
public enum CodingKeys: String, CodingKey { | |
case latitude | |
case longitude | |
case altitude | |
case horizontalAccuracy | |
case verticalAccuracy | |
case speed | |
case course | |
case timestamp |
// | |
// IAPHelper.swift | |
// Bandwagon | |
// | |
// Created by Andy on 2017/9/27. | |
// Copyright © 2017年 Doraemon. All rights reserved. | |
// | |
import Foundation | |
import SwiftyStoreKit |
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html
http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Client.html
DynamoDB's scan
operation fetches only 1MB at one time and it adds LastEvaluatedKey
(LEK) in the response if it has a next page.
# frozen_string_literal: true | |
class AssociationLoader < GraphQL::Batch::Loader | |
attr_reader :klass, :association | |
def initialize(klass, association) | |
raise ArgumentError, "association to load must be a symbol (got #{association.inspect})" unless association.is_a?(Symbol) | |
raise ArgumentError, "cannot load associations for class #{klass.name}" unless klass < ActiveRecord::Base | |
raise TypeError, "association #{association} does not exist on #{klass.name}" unless klass.reflect_on_association(association) | |
@klass = klass |
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.
The goal of this cheatsheet is to make it easy to add hand-rolled authentication to any rails app in a series of layers.
First the simplest/core layers, then optional layers depending on which features/functionality you want.
Specs |
|
---|---|
AUTHOR | Ira Herman |
LANGUAGE/STACK | Ruby on Rails Version 4, 5, or 6 |
module SQLApprovals | |
def verify_sql(name:, &block) | |
# List to store executed queries | |
queries = [] | |
# An event listener to record the normalized queries | |
subscriber = ->(_name, _start, _finish, _id, payload) do | |
# You'll likely need to filter unrelated queries, | |
# this is left as an exercise to the reader | |
queries << PgQuery.normalize(payload[:sql]) |
Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.
This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would