Skip to content

Instantly share code, notes, and snippets.

View kichiemon's full-sized avatar
🌴
I’m on Fiji time!

きちえもん kichiemon

🌴
I’m on Fiji time!
View GitHub Profile
#!/bin/sh
# e.g. CONTAINER_REGISTRY=asia.gcr.io/your-project-name/gcf/asia-northeast1
CONTAINER_REGISTRY=`WRITE YOUR REGISTRY NAME`
IMAGE_LIST=`gcloud container images list --repository=$CONTAINER_REGISTRY | awk 'NR!=1'`
for line in $IMAGE_LIST; do
gcloud container images delete "$line/worker" --quiet & gcloud container images delete "$line/cache" --quiet &
done
#!/usr/bin/env bash
# carthage.sh
# Usage example: ./carthage.sh build --platform iOS
set -euo pipefail
xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX)
trap 'rm -f "$xcconfig"' INT TERM HUP EXIT
@kichiemon
kichiemon / firebase_cloud_functions_send_slack_when_purchased.ts
Created September 23, 2020 12:04
アプリ内課金の発生時にSlack通知する
import * as functions from "firebase-functions";
import * as request from "request";
exports.sendSlackMessageOnPurchaseCoin = functions
.region("asia-northeast1")
.analytics.event("in_app_purchase_coins")
.onLog((event) => sentMessageToSlack(event, "コインが購入されました"));
exports.sendSlackMessageOnPurchaseSubscription = functions
.region("asia-northeast1")
@kichiemon
kichiemon / offline_firebase_auth.dart
Last active May 8, 2020 14:40
オフラインでもFirebaseAuthentication認証を通過させる
auth.currentUser.then((currentUser) => currentUser == null
? _authUserWithFirebase()
: Future.value(currentUser))
// The default cache size threshold is 100 MB. Configure "cacheSizeBytes"
// for a different threshold (minimum 1 MB) or set to "FirestoreCacheSizeUnlimited"
// to disable clean-up.
let settings = Firestore.firestore().settings
settings.cacheSizeBytes = FirestoreCacheSizeUnlimited
Firestore.firestore().settings = settings
} else if ([@"Firestore#settings" isEqualToString:call.method]) {
FIRFirestoreSettings *settings = [[FIRFirestoreSettings alloc] init];
if (![call.arguments[@"persistenceEnabled"] isEqual:[NSNull null]]) {
settings.persistenceEnabled = ((NSNumber *)call.arguments[@"persistenceEnabled"]).boolValue;
}
if (![call.arguments[@"host"] isEqual:[NSNull null]]) {
settings.host = (NSString *)call.arguments[@"host"];
}
if (![call.arguments[@"sslEnabled"] isEqual:[NSNull null]]) {
settings.sslEnabled = ((NSNumber *)call.arguments[@"sslEnabled"]).boolValue;
@override
Future<void> settings({
bool persistenceEnabled,
String host,
bool sslEnabled,
int cacheSizeBytes,
}) async {
await channel.invokeMethod<void>('Firestore#settings', <String, dynamic>{
'app': app.name,
'persistenceEnabled': persistenceEnabled,
@kichiemon
kichiemon / flutter_modal_push_page.dart
Last active February 19, 2020 15:00
flutter_modal_push_page: The key point is `fullscreenDialog: true,`
Navigator.push(
context,
new MaterialPageRoute(
builder: (BuildContext context) => NextPage(),
fullscreenDialog: true,
),
)
fun <A, B> LiveData<A>.combineLatestWith(other: LiveData<B>): LiveData<Pair<A, B>> {
val mediator = MediatorLiveData<Pair<A, B>>()
mediator.addSource(this) {
it?.let { thisValue ->
other.value?.let { otherValue ->
mediator.value = Pair(thisValue, otherValue)
}
}
}
mediator.addSource(other) {
@kichiemon
kichiemon / replace_undefined_content_type
Created January 24, 2020 03:50
replace undefined content type
grep -R "Content-Type\': undefined" ./* -l | xargs sed -i -e 's|Content-Type\\\': undefined|Content-Type\\\': \'application/x-www-form-urlencoded;application/json;charset=utf-8\'|g