Skip to content

Instantly share code, notes, and snippets.

View rdlabo's full-sized avatar

Masahiko Sakakibara rdlabo

View GitHub Profile
@rdlabo
rdlabo / which-main-instance.ts
Last active October 11, 2023 06:17
Which Instance is main on Elastic Beanstalk ( NestJS )
@Injectable()
export class AwsService {
public async isMainInstance(): Promise<boolean> {
/*
* インスタンスメタデータを取得するための手続き。IMDSv2で実装。
* https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
*/
const token = await firstValueFrom(
this.http
.put(
import { Component } from '@angular/core';
import { MenuController } from '@ionic/angular';
import { NgZone } from '@angular/core';
@Component({
selector: 'app-tab1',
templateUrl: 'tab1.page.html',
styleUrls: ['tab1.page.scss']
})
export class Tab1Page {
import { Component } from '@angular/core';
import { Plugins, MotionEventResult, MotionOrientationEventResult } from '@capacitor/core';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
alter table tweet drop index geom;
alter table tweet modify geom geometry not null SRID 4326 ;
alter table tweet add spatial index(geom);
UPDATE tweet
SET
geom = CASE
WHEN
area_type = 1
THEN
package jp.rdlabo.capacitor.plugin.screenshotevent;
import com.getcapacitor.JSObject;
import com.getcapacitor.NativePlugin;
import com.getcapacitor.Plugin;
import com.getcapacitor.PluginCall;
import com.getcapacitor.PluginMethod;
import com.getcapacitor.util.HostMask;
import android.os.FileObserver;
@rdlabo
rdlabo / memo.swift
Last active January 14, 2020 06:09
import Foundation
import Capacitor
import AVFoundation
/**
* Please read the Capacitor iOS Plugin Development Guide
* here: https://capacitor.ionicframework.com/docs/plugins/ios
*/
@objc(MlkitPlugin)
@rdlabo
rdlabo / reload.ts
Created September 2, 2019 04:16
reload
let isAlert = false;
setTimeout(() => {
if (!isAlert) {
// Alertをだしてユーザが選択したらreload
}
}, 2000); <= Timeout時間
this.afAuth.auth.currentUser.getIdToken(false)
.then()
.finally(() => isAlert = true);
@rdlabo
rdlabo / ionic.ts
Created August 26, 2019 02:33
Ionic Storage & HTTP
@Injectable({
providedIn: 'root',
})
export class AuthService {
constructor(
public http: HttpClient,
public storage: Storage,
) {}
async getState() {
@rdlabo
rdlabo / gist:e0712194682636d0de648a0fc88a5465
Created August 23, 2019 14:45
Ionic/AngularのAngular 8へのアップデートコマンド
$ yarn add @ionic/angular@4.7.1 @ionic/angular-toolkit@2.0.0 -D
$ yarn add @angular-devkit/architect@0.801.2 @angular-devkit/build-angular@0.801.2 @angular-devkit/core@8.1.3 @angular-devkit/schematics@8.1.3 @angular/cli@8.1.3 @angular/compiler@8.1.3 @angular/compiler-cli@8.1.3
(場合によってはここでnode_moduleを削除しないといけないかも)
$ npx ng update @angular/core@8.1.3 @angular/cli@8.1.3
@rdlabo
rdlabo / keyboard-attach.directive.ts
Last active September 25, 2019 10:02 — forked from Manduro/keyboard-attach.directive.ts
Ionic Keyboard Attach Directive
import { Directive, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';
import { Keyboard } from '@ionic-native/keyboard';
import { Content, Platform } from 'ionic-angular';
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
/**
* @name KeyboardAttachDirective
* @source https://gist.github.com/rdlabo/942671d8c9cffb02676756cdd56aa1c0
* @forked https://gist.github.com/Manduro/bc121fd39f21558df2a952b39e907754