Skip to content

Instantly share code, notes, and snippets.

gcloud logging read --order=asc --format=json '
timestamp>="2019-06-13T12:20:00+09:00" AND timestamp<="2019-06-13T15:00:00+09:00"
AND resource.type="container"
AND logName="projects"
AND severity>=ERROR
AND sample(insertId, 0.001)
'
@valbeat
valbeat / file0.sh
Last active November 22, 2019 13:30
GKEの快適なオペレーション ref: https://qiita.com/kajitack/items/5af6a838bff34724a639
# プロジェクトのリストを表示
$ gcloud projects list
# プロジェクトの切り替え
$ gcloud config set project PROJECT_ID
@valbeat
valbeat / file0.txt
Created September 16, 2018 13:30
EC2インスタンスのPublicDnsNameを一覧で表示するコマンド ref: https://qiita.com/valbeat/items/f73f94b5e738060fa60a
$ aws ec2 describe-instances --query 'Reservations[*].Instances[*].PublicDnsName' --output text
ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com
ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com
ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com
ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com
...
@valbeat
valbeat / file0.cs
Last active November 22, 2019 13:29
ニフティクラウドmobile backendのUnity SDKで匿名ログイン処理 ref: https://qiita.com/kajitack/items/3ca88a20817962684a8c
using UnityEngine;
using System;
using System.Collections;
public class UUIDManager : SingletonMonoBehaviour<UUIDManager> {
Guid guid;
[SerializeField]
string _uuid = "";
public string uuid {
@valbeat
valbeat / SingletonMonoBehaviour.cs
Last active January 21, 2016 03:36
MonoBehaviourを継承したシングルトンの実装 ref: http://qiita.com/kajitack/items/4b0175755b0cc47d4f6e
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// MonoBehaviourを継承したシングルトン
/// </summary>
public class SingletonMonoBehaviour<T> : MonoBehaviour where T : MonoBehaviour {
/// <summary>
@valbeat
valbeat / CheckExitScreen.cs
Created December 31, 2015 04:52
スクリーンから出たかどうかチェックする
void CheckExitScreen(){
if (Mathf.Abs(_Rigidbody.position.x) > Camera.main.orthographicSize * Camera.main.aspect) {
_Rigidbody.position = new Vector3(-Mathf.Sign(_Rigidbody.position.x) * Camera.main.orthographicSize * Camera.main.aspect, 0, _Rigidbody.position.z);
_Rigidbody.position -= _Rigidbody.position.normalized * 0.1f; // 反対側に移動
}
if (Mathf.Abs(_Rigidbody.position.z) > Camera.main.orthographicSize) {
_Rigidbody.position = new Vector3(_Rigidbody.position.x , _Rigidbody.position.y, -Mathf.Sign(_Rigidbody.position.z) * Camera.main.orthographicSize);
_Rigidbody.position -= _Rigidbody.position.normalized * 0.1f; // 反対側に移動
}
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
using UnityStandardAssets.CrossPlatformInput;
using UnityEngine.UI;
public class PlayerJoystick : Joystick, InputGesture {
Image joystickImage;
EventSystem es;
@valbeat
valbeat / mean.cpp
Last active October 29, 2016 04:06
Vectorの平均値と中央値を求める ref: http://qiita.com/valbeat/items/aaf4721c55e372de3c20
float mean(vector<float> v) {
int size = v.size();
float sum = 0;
for (int i = 0; i < size; i++){
sum += v[i];
}
return sum / size;
}
using UnityEngine;
using System.Collections;
public class CameraControl : MonoBehaviour {
private GameObject player = null;
private Vector3 offset = Vector3.zero;
void Start () {
@valbeat
valbeat / Clamp.cs
Created October 22, 2015 09:06
Unityで真上からのカメラで位置のクランプ
void Clamp() {
Vector3 posZToY = position;
posZToY.y = position.z;
Vector3 posInScreen = Camera.main.WorldToViewportPoint(posZToY);
Vector3 pos = position;
posInScreen.x = Mathf.Clamp (posInScreen.x, 0, 1);
posInScreen.y = Mathf.Clamp (posInScreen.y, 0, 1);
Vector3 _pos = Camera.main.ViewportToWorldPoint(posInScreen);
pos.x = _pos.x;
pos.z = _pos.y;