- Build the image from a
Dockerfile
docker build ./ --tag {name}:latest
. Advisable to use your service name here
- Test if the application is running
docker run -p 8080:8080 -it name
docker run -p 8080:8080 -e ENV=VALUE -it name
- e.g.
docker run -p 8080:8080 -e PORT=8080 -it name
- e.g.
- Configure docker on GCloud CLI
gcloud auth configure-docker gcr.io
gcloud auth configure-docker {region}.gcr.io
- Enable cloud-run if it isn’t enabled, using cloud console or GCloud CLI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET v4_enrichmentsx/_search | |
{ | |
"query": { | |
"bool": { | |
"filter": [ | |
{ | |
"terms": { | |
"FIELD": [ # 64000 | |
"VALUE1", | |
"VALUE2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type EventDef<D> = Event & { detail?: D } | |
type VideoRef = string | HTMLVideoElement | null | |
const eventName = 'image-updated' | |
export default function getVideoSnapshot(videoRef: VideoRef) { | |
if (typeof videoRef === 'string') { | |
videoRef = document.getElementById(videoRef) as HTMLVideoElement | null | |
} | |
if (!videoRef) { | |
throw new Error('Video element not found') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nodeFetch, { type RequestInit, type Response } from "node-fetch"; | |
import type { AbortSignal } from "abort-controller"; | |
const TEN_MEGABYTES = 1000 * 1000 * 10; | |
type StreamOptions = RequestInit & { | |
signal?: AbortSignal; | |
highWaterMark?: number; | |
}; | |
export async function fetch( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See compatibility table for .toBlob() Method | |
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#browser_compatibility | |
interface Option { | |
type: 'image/jpeg' | 'image/png' | 'image/webp' | 'image/bmp' | 'image/gif'; | |
quality?: number; | |
} | |
async function compressImage(file: File, option: Option) { | |
if (!file.type.startsWith('image')) { |
My Elasticsearch cheatsheet with example usage via rest api (still a work-in-progress)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create your stripe customer | |
*/ | |
import * as functions from 'firebase-functions'; | |
import { DocumentSnapshot } from "firebase-functions/lib/providers/firestore"; | |
import * as Stripe from "stripe" | |
const secretKey = functions.config().stripe.key // ensure you have set the configuration | |
const stripe = new Stripe(secretKey) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
use Illuminate\Database\Eloquent\Model; | |
class Comment extends Model | |
{ | |
public function post() | |
{ | |
return $this->belongsTo('\App\Post'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
use Illuminate\Database\Eloquent\Model; | |
class Post extends Model | |
{ | |
public function user() | |
{ | |
return $this->belongsTo('\App\User'); | |
} | |
public function comments() |
NewerOlder