Slack Slash Command (application/x-www-form-urlencoded) -> API Gateway -> Lambda (application/json)
This file contains hidden or 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 Lib | |
( generatePoem | |
) where | |
import Prelude hiding (Word) | |
import Control.Monad (join) | |
import qualified Data.Map as Map | |
import System.Random (randomRIO) | |
import Data.Maybe (isNothing, fromMaybe, fromJust) | |
import Data.List (intercalate) |
This file contains hidden or 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
function peco-select-git-checkout() { | |
local selected_branch="$(git branch --sort=-committerdate | grep -v '^\*.*' | peco --query "$LBUFFER" | awk -F ' ' '{print $1}')" | |
if [ -n $selected_branch ]; then | |
BUFFER="git checkout $selected_branch" | |
CURSOR=$#BUFFER | |
zle accept-line | |
fi | |
} | |
zle -N peco-select-git-checkout | |
bindkey "^gc" peco-select-git-checkout |
This file contains hidden or 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 UIKit | |
import PlaygroundSupport | |
let scrollView = UIScrollView(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) | |
scrollView.backgroundColor = .red | |
let stackView = UIStackView(frame: CGRect(x: 0, y: 0, width: 1000, height: 100)) | |
stackView.backgroundColor = .gray | |
stackView.axis = .horizontal | |
stackView.spacing = 10 |
This file contains hidden or 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 | |
import Runes | |
struct Recipe { | |
let imageURLString: String? | |
} | |
let recipe = Recipe(imageURLString: "http://hoge/image.png") | |
// default | |
if let imageURLString = recipe.imageURLString, let imageURL = URL(string: imageURLString) { |
This file contains hidden or 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 EitherProtocol { | |
associatedtype Left | |
associatedtype Right | |
func either<Result>(ifLeft: (Left) -> Result, ifRight: (Right) -> Result) -> Result | |
} | |
extension EitherProtocol { |
This file contains hidden or 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
exports.handler = function(event, context, callback) { | |
var aws = require('aws-sdk'); | |
var lambda = new aws.Lambda(); | |
lambda.invoke({ | |
FunctionName: 'your-lambda-function-name', | |
Payload: JSON.stringify(event) | |
}, function(error, data) { | |
if (error) { | |
context.done('error', error); |
This file contains hidden or 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 UIKit | |
import PlaygroundSupport | |
let container = UIView(frame: CGRect(x: 0, y: 0, width: 500, height: 200)) | |
container.backgroundColor = .lightGray | |
let buttonRadius: CGFloat = 50 | |
let buttonSize = CGSize(width: buttonRadius * 2, height: buttonRadius * 2) | |
let buttonPath = UIBezierPath(arcCenter: CGPoint(x: buttonRadius, y: buttonRadius), radius: buttonRadius, startAngle: 0, endAngle: CGFloat.pi * 2, clockwise: true) |
This file contains hidden or 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 | |
struct Hoge { | |
static var staticVar = Date() | |
static var staticComputedVar: Date { return Date() } | |
static let staticLet = Date() | |
static let staticLet2 = { return Date() }() | |
} | |
Hoge.staticVar == Hoge.staticVar // true |
This file contains hidden or 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 UIKit | |
extension UIView { | |
func addBorderViews(top: Bool = false, left: Bool = false, bottom: Bool = false, right: Bool = false, color: UIColor = .black, width: CGFloat = 1.0) { | |
if top { | |
let borderView = UIView() | |
borderView.translatesAutoresizingMaskIntoConstraints = false | |
addSubview(borderView) | |
borderView.topAnchor.constraint(equalTo: topAnchor).isActive = true | |
borderView.leftAnchor.constraint(equalTo: leftAnchor).isActive = true |