Skip to content

Instantly share code, notes, and snippets.

@xhiroga
xhiroga / versionup.js
Created December 8, 2018 23:35
Upgrade Expo App version
// Put this file on top directory in your expo project.
APP_JSON_FILE = 'app.prod.json'
var app_json = require(APP_JSON_FILE)
version = app_json.expo.version
console.log(`Latest version: ${version}`)
match = /([0-9]+\.[0-9]+\.)([0-9]+)/.exec(version)
major_minor_version = match[1]
patch_version = match[2]
@xhiroga
xhiroga / gist:889dcdd922c6b9a44a387084eb4b2d83
Created June 20, 2019 23:52
Pick an element from an array every day, with 3 conditions. 1. while a loop, the element should not be same. 2. for every loop, order should be random. 3. no external memory.
Pick an element from an array every day, with 3 conditions. 1. while a loop, the element should not be same. 2. for every loop, order should be random. 3. no external memory.
ある配列から、毎日要素を取り出したい。ただし、配列が一周するまでは要素が重複してはいけず、また、毎周の順番が固定でもいけない。
an array.
ある配列がある。
```
["apple", "banana", "carrot"]
```
@xhiroga
xhiroga / kotlinfest2019.md
Last active January 3, 2020 04:19
Kotlin Fest 2019 登壇資料まとめ
@xhiroga
xhiroga / vpc_template_by_cdk.yaml
Created October 5, 2019 23:09
AWS CDKで構築したVPCのテンプレート
Resources:
CDKTESTHIROGA2CBE18D7:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsHostnames: true
EnableDnsSupport: true
InstanceTenancy: default
Tags:
- Key: Name

Keybase proof

I hereby claim:

  • I am hiroga-cc on github.
  • I am hiroga (https://keybase.io/hiroga) on keybase.
  • I have a public key ASBj6eaQbF_bjbHbCWraLgBrwno9_jellWktW-VvXg8V8Ao

To claim this, I am signing this object:

@xhiroga
xhiroga / asdict.py
Created November 20, 2019 00:26
Pythonでdaataclassのうち、値がNoneの項目を除外して辞書化するスニペット
dataclasses.asdict(
obj,
dict_factory=lambda tuples: {tuple[0]: tuple[1] for tuple in tuples if tuple[1] is not None}
)
@xhiroga
xhiroga / cheatsheet.py
Created March 16, 2020 22:53
cheatsheets
# Reference
# TBD...
### Keybase proof
I hereby claim:
* I am xhiroga on github.
* I am hiroga (https://keybase.io/hiroga) on keybase.
* I have a public key whose fingerprint is 1694 5E22 1B0B AF41 3918 A7F1 BAB0 76B5 3124 D139
To claim this, I am signing this object:
@xhiroga
xhiroga / gist:0e24b0e957afd70fdd59482fa62f0bbc
Created October 26, 2020 02:54
[GAS] protect all sheets
function protectAllSheets() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var shs = ss.getSheets();
var me = Session.getEffectiveUser();
for (var i = 0; i < shs.length; i++){
var sheet = shs[i]
var protection = sheet.protect().setDescription('protect sheet by "function protectAllSheets()"');
protection.addEditor(me);
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
@xhiroga
xhiroga / README.md
Last active December 11, 2021 10:11
doit - シンプルなdotfilesマネージャー(企画書)

doitはシンプルなdotfilesマネージャーです。
GitHubで一番人気のあるmathiasbynens/dotfilesの形式に対応しています。 実際、doitの名前はそのリポジトリのbootstrap用シェルスクリプトの関数から取られています。

バイナリをインストールしたら、指定したdotfilesリポジトリのファイルを $HOME にコピーすることしかできません。しかも、同名のファイルがある場合は(確認の後)上書きします。 しかし、テンプレートエンジンやパスワードマネージャーとの統合はサポートされています。(chezmoiに影響されています)

できること

  • バイナリインストール
  • リモート・ローカル両方のdotfilesを指定可能