Skip to content

Instantly share code, notes, and snippets.

View yokada's full-sized avatar
🏠
Working from home

yokada yokada

🏠
Working from home
View GitHub Profile
@yokada
yokada / Vagrantfile
Created November 30, 2017 09:24
Change memory limit for Vagrant.
...
config.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--memory", 4096] #<= 4096 equals 4GB total memory.
v.customize ["modifyvm", :id, "--cpus", 1]
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
# Set the box name in VirtualBox to match the working directory.
vvv_pwd = Dir.pwd
v.name = File.basename(vvv_pwd)
@yokada
yokada / flatten_request_params.php
Created February 2, 2018 04:41
Flatten keys in which multidimensional array, recursively.
<?php
/**
* 'card_num' => '0444444444444441'
* 'card1.id' => 'card-id-1'
* 'card.#.id' => 'cardlist-id-1'
* 'card.#.name' => 'cardlist-name-1'
* 'card.#.id' => 'cardlist-id-2'
* 'card.#.name' => 'cardlist-name-2'
* 'card_name' => 'hoge'
*
@yokada
yokada / package.json.diff
Last active September 4, 2018 21:22
Upgrade to babel 7.0.0 from older version
diff --git a/package.json b/package.json
index 13f488f..e6e9071 100644
--- a/package.json
+++ b/package.json
@@ -15,8 +15,6 @@
},
"dependencies": {
"awilix": "^3.0.9",
"bluebird": "^3.5.1",
"co": "^4.6.0",
@yokada
yokada / .babelrc.diff
Created September 4, 2018 21:22
Upgrade to babel 7
$ git diff .babelrc
diff --git a/.babelrc b/.babelrc
index 53b35ab..15eefa0 100644
--- a/.babelrc
+++ b/.babelrc
@@ -1,16 +1,16 @@
{
"plugins": [
"source-map-support",
- "transform-runtime"
@yokada
yokada / createFileLayoutFromJson.js
Last active October 7, 2018 19:32
Create file layout from json which is written in yaml.
import path from 'path'
import fs from 'fs'
/**
# Creating Input data
## 1. write source yaml
- a:
- a.txt
@yokada
yokada / docker-compose.yml
Created July 6, 2019 18:30
Create AWS StepFunctions Local docker image and container service on your computer.
# $ docker-compose up -d
# Or,
# $ docker-compose up -d --build --force-recreate
version: "3"
services:
sfn:
image: amazon/aws-stepfunctions-local:1.0.1
ports:
- 18083:8083
@yokada
yokada / running-10sec-statemachine.json
Created July 6, 2019 18:40
Super simple state machine running within 10 seconds for test.
{
"StartAt": "WaitExecution",
"States": {
"WaitExecution": {
"Type": "Wait",
"Seconds": 10,
"End": true
}
}
}
@yokada
yokada / aws-cli-stepfunctions-commands-starter.md
Created July 6, 2019 19:09
AWS Cli StepFunctions commands starter in local with docker

@see For running aws stepfunctions local in docker https://gist.github.com/yokada/5e7ff39b91caff0eb6446a3e41465c3d

Create State Machine

$ aws stepfunctions create-state-machine \
  --endpoint http://localhost:18083 \
  --definition "$(gist -r 799bc111ce4ea7801b2f251e21177aec)" \
  --name WaitExecution \
  --role-arn arn:aws:iam::012345678901:role/DummyRole \
@yokada
yokada / call-statemachine.sh
Created July 6, 2019 19:26
Execute statemachine in bash
#!/bin/env bash
# Before exec, you shold create a statemachine named WaitExecution, like below:
# $ aws stepfunctions create-state-machine --endpoint http://localhost:18083 --definition "$(gist -r 799bc111ce4ea7801b2f251e21177aec)" --name WaitExecution --role-arn "arn:aws:iam::012345678901:role/DummyRole" --region ap-northeast-1
echo bash version: ${BASH_VERSION}
#set -x
endpoint="--endpoint http://localhost:18083"
region="--region ap-northeast-1"
@yokada
yokada / functions.php
Created December 15, 2019 02:55
translate site title using bogo function
<?php
function translated_blogname($title) {
return bogo_translate('blogname', 'blogname', $title);
}
add_filter( 'pre_option_blogname', 'translated_blogname', 10, 1);