Skip to content

Instantly share code, notes, and snippets.

View mateothegreat's full-sized avatar
🤘
it ain't easy.

Matthew Davis mateothegreat

🤘
it ain't easy.
View GitHub Profile
@mateothegreat
mateothegreat / Dockerfile
Last active December 28, 2023 08:16
Mounting Google Cloud Storage Bucket inside of Kubernetes Pod
# __ __
# __ ______ ____ ___ ____ _/ /____ ____ ____/ /
# / / / / __ \/ __ `__ \/ __ `/ __/ _ \/ __ \/ __ /
# / /_/ / /_/ / / / / / / /_/ / /_/ __/ /_/ / /_/ /
# \__, /\____/_/ /_/ /_/\__,_/\__/\___/\____/\__,_/
# /____ matthewdavis.io, holla!
#
FROM node:9.2-alpine
ENV GOPATH /go
@mateothegreat
mateothegreat / ExampleController.ts
Last active July 20, 2023 07:04
Request authorization with nest.js + JWT
@Controller("/foo")
export class SomeController {
@Get("/thisisprotected")
@UseGuards(RequestGuard)
public search(@SessionDecorator() session: Session): Promise<any> {
return { foo: "bar" };
}
}
@mateothegreat
mateothegreat / GlobalExceptionHandler.ts
Created June 21, 2023 17:08
nest.js exception filtering
import { ArgumentsHost, Catch, ConflictException, ExceptionFilter } from '@nestjs/common';
@Catch()
export class GlobalExceptionsFilter implements ExceptionFilter {
public catch(exception: any, host: ArgumentsHost): void {
// const log = {
// date: new Date(),
// source: request.ip,
// url: request.url,
// method: request.method,
@mateothegreat
mateothegreat / capture-browser-screenshot.js
Created April 20, 2023 17:56
Capture a screenshot in the browser
function getDisplayMedia(options) {
if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
return navigator.mediaDevices.getDisplayMedia(options)
}
if (navigator.getDisplayMedia) {
return navigator.getDisplayMedia(options)
}
if (navigator.webkitGetDisplayMedia) {
return navigator.webkitGetDisplayMedia(options)
}
@mateothegreat
mateothegreat / benchmark_test.go
Created April 17, 2023 19:10
Slices vs. Array performance in golang.
package main
import "testing"
var gs = make([]byte, 1000)
var ga [1000]byte
func BenchmarkSliceGlobal(b *testing.B) {
for i := 0; i < b.N; i++ {
for j, v := range gs {

Keybase proof

I hereby claim:

  • I am mateothegreat on github.
  • I am matthewbdavis (https://keybase.io/matthewbdavis) on keybase.
  • I have a public key ASAehsbCoBdkPerCbsKs-2rt3NgU_OawJs4HxthGhWMZigo

To claim this, I am signing this object:

@mateothegreat
mateothegreat / ansible.cfg
Created April 25, 2020 20:35
ansible configuration for speed
[defaults]
host_key_checking = False
retry_files_enabled = False
ansible_python_interpreter=python3
localhost_warning = False
strategy_plugins = plugins/mitogen-0.2.9/ansible_mitogen/plugins/strategy
strategy = mitogen_linear
callback_whitelist = timer, profile_tasks
forks = 50
internal_poll_interval = 0.001

Keybase proof

I hereby claim:

To claim this, I am signing this object:

cat test.json| jq 'to_entries[] | select(.value | index("group3") | not)'
kubectl create clusterrolebinding cluster-admin-binding \
--clusterrole=cluster-admin \
--user=$(gcloud config get-value core/account)