Skip to content

Instantly share code, notes, and snippets.

View danimal141's full-sized avatar
💁‍♂️
Get wild and tough

Hideaki ishii danimal141

💁‍♂️
Get wild and tough
  • Tokyo, Japan
View GitHub Profile
@danimal141
danimal141 / amz_content_sha256.js
Created January 19, 2025 05:49 — forked from antonbabenko/amz_content_sha256.js
Lambda@Edge (origin-request) for CloudFront OAC with Lambda Function URL integration for POST/PUT
'use strict';
const crypto = require('crypto');
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;
const headers = request.headers;
const method = request.method;
const body = Buffer.from(request.body.data, 'base64').toString();
#!/bin/bash
# コマンドライン引数から入力ファイル名を取得
if [ "$#" -ne 1 ]; then
echo "使用方法: $0 [input-file]"
exit 1
fi
INPUT_FILE="$1"
@danimal141
danimal141 / serializers_model_factory.rb
Created June 9, 2019 09:20
factory_bot DSL for ActiveModelSerializers::Model
if defined?(FactoryBot)
module FactoryBot
module Syntax
module Default
class DSL
# Custom DSL for ActiveModelSerializers::Model
# Original: https://github.com/thoughtbot/factory_bot/blob/v5.0.2/lib/factory_bot/syntax/default.rb#L15-L26
def serializers_model_factory(name, options = {}, &block)
factory = Factory.new(name, options)
proxy = FactoryBot::DefinitionProxy.new(factory.definition)
@danimal141
danimal141 / stuct-sample.go
Created January 11, 2017 11:08
Go struct to another struct sample
package main
import (
"fmt"
)
type aaa struct {
CCC int
}
@danimal141
danimal141 / exercise-web-crawler.go
Created October 12, 2016 01:05
A Tour of Go Exercise: Web Crawler
package main
import (
"fmt"
"sync"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
@danimal141
danimal141 / exercise-equivalent-binary-trees.go
Last active October 11, 2016 13:26
A Tour of Go Exercise: Equivalent Binary Trees
package main
import (
"golang.org/x/tour/tree"
"fmt"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
@danimal141
danimal141 / exercise-images.go
Created October 10, 2016 13:33
A Tour of Go Exercise: Images
package main
import (
"golang.org/x/tour/pic"
"image"
"image/color"
)
type Image struct{
width int
@danimal141
danimal141 / exercise-rot-reader.go
Created October 10, 2016 13:08
A Tour of Go Exercise: rot13Reader
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader
@danimal141
danimal141 / exercise-reader.go
Created October 10, 2016 12:32
A Tour of Go Exercise: Readers
package main
import "golang.org/x/tour/reader"
type MyReader struct{}
func (r MyReader) Read(b []byte) (int, error) {
for i := range b {
b[i] = 'A'
}
@danimal141
danimal141 / exercise-errors.go
Created October 10, 2016 09:16
A Tour of Go Exercise: Errors
package main
import (
"fmt"
"math"
)
type ErrNegativeSqrt float64
func (e ErrNegativeSqrt) Error() string {