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 / col2idx.php
Created July 31, 2021 08:25
convert column name to index number
<?php
/**
* convert column name to index number.
*
* @param string $col 'Z', 'AA', 'ZAA'
*/
function col2idx($col = 'AZ') {
$idx = 0;
$k = count(range('A', 'Z'));
@yokada
yokada / functions.php
Created January 5, 2020 20:37
In WordPress ACF, filter tree of taxonomy field_type
add_filter('acf/fields/taxonomy/wp_list_categories/name=mycat-tree1', 'mycat1_filter', 10, 2);
}
function mycat1_filter($args, $field) {
$cat = get_category_by_slug('mycat1-slug');
if (empty($cat)) {
return $args;
}
$args['parent'] = $cat->cat_ID;
return $args;
@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);
@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 / 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 / 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 / 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 / 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 / .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 / 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",