Skip to content

Instantly share code, notes, and snippets.

View timoschilling's full-sized avatar
👻
yolo

Timo Schilling timoschilling

👻
yolo
View GitHub Profile
CustomResponseHeader:
Type: AWS::Serverless::Function
Properties:
# FunctionName: !Sub ${AWS::StackName}-CustomResponseHeader
Handler: index.handler
Runtime: nodejs12.x
AutoPublishAlias: live
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
@timoschilling
timoschilling / 1.md
Created January 15, 2020 12:19
API Gateway use cases

API Gateway use cases

@timoschilling
timoschilling / benchmark_except.rb
Last active April 18, 2021 10:35
Benchmark Hash#except
require 'benchmark/ips'
require 'active_support/hash_with_indifferent_access'
require 'active_support/core_ext/hash'
class Hash
def except_new(*keys)
slice(*(self.keys - keys))
end
end
package main
import (
"strconv"
"github.com/brutella/hc"
"github.com/brutella/hc/log"
"github.com/brutella/hc/accessory"
)
type Bridge struct {
@timoschilling
timoschilling / fizzbuzz.html
Created November 24, 2015 11:52 — forked from moonglum/fizzbuzz.html
This is a FizzBuzz Solution I found on Twitter. It was always shared as a screenshot, so I typed it myself, to try it out ;) Source: https://twitter.com/ericwastl/status/667567483432402944
<html>
<head>
<style>
body {
counter-reset: n;
}
div:before {
counter-increment: n;
content: counter(n);
}
@timoschilling
timoschilling / operation.rb
Last active November 7, 2015 19:02 — forked from stoffie/operation.rb
can be deleted on next cleanup
class Create < Trailblazer::Operation
include Model
model Workflow
contract do
property :name
property :description
collection :steps, populate_if_empty: Step do
property :form, populate_if_empty: lambda { |params, *| Form.find(params[:workflow][:steps][:form][:id]) }
@timoschilling
timoschilling / skip_callbacks.rb
Created November 2, 2015 14:19
Skipable Trailblazer Callbacks
module SkipableCallbacks
def initialize(params, options = {})
@skip_callbacks = params.delete(:skip_callbacks) || {}
super
end
def dispatch!(name = :default)
org_callbacks = self.class.callbacks[name]
self.class.callbacks[name] = org_callbacks.clone
@skip_callbacks[name] && @skip_callbacks[name].each do |callback|
@timoschilling
timoschilling / find_rails_url_helper_name.rb
Created October 21, 2015 14:35
find Rails url helper name
def find_route_name(path)
Rails.application.routes.routes.select do |route|
route.path.match path
end.map(&:name).compact.first
end
@timoschilling
timoschilling / application_controller.rb
Created October 9, 2015 05:08
Trailblazer::WithCurrentUser maps you the current_user in your Trb params hash, this is just a idea and not save for work!
class ApplicationController < ActionController::Base
include Trailblazer::Operation::Controller
include Trailblazer::WithCurrentUser
self.trb_with_current_user_param_key = :current_user
self.trb_with_current_user_method = :current_user
end
@timoschilling
timoschilling / unsubscribe.rb
Created September 29, 2015 15:00
ActiveSupport::Notifications unsubscribe by regex
ActiveSupport::Subscriber.subscribers.flat_map(&:patterns).grep(/trailblazer/).map &ActiveSupport::Notifications.method(:unsubscribe)