Skip to content

Instantly share code, notes, and snippets.

@veevidify
veevidify / cmd.sh
Last active March 12, 2023 02:02
Cloudy
#!/bin/bash
# CF
aws cloudformation deploy --template-file template.yaml --stack-name Ec2Ssh --parameter-overrides file://params.json
aws cloudformation delete-stack --stack-name Ec2Ssh
# ECR
aws ecr get-login-password --region region | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com
docker tag hello-world:latest aws_account_id.dkr.ecr.region.amazonaws.com/hello-repository
docker push aws_account_id.dkr.ecr.region.amazonaws.com/hello-repository
@veevidify
veevidify / GrommetTable.tsx
Created June 26, 2022 09:38
React snippets
import React, { useState, useEffect } from 'react';
import { DataTable, Box, Text, Button, TextInput, Select } from 'grommet';
import { ChevronLeft, ChevronRight } from './Icons';
import { intArr } from '../utils/functions';
const PaginatedTable: React.FC<{ [key: string]: any }> = props => {
const { pageSize, data } = props;
const [currentPage, changeCurrentPage] = useState(0);
const [currentPageSize, changeCurrentPageSize] = useState(pageSize);
@veevidify
veevidify / gpg.md
Last active March 23, 2022 11:39
Commit signing

New GPG key

  • Gen key
$ gpg --full-gen-key
  • List
$ gpg --list-keys
  • Export pub key
@veevidify
veevidify / bs.scala
Created April 13, 2021 11:33
Scala snippets
import scala.math.Ordering.{String => StringOrdering}
import scala.collection.Searching._
import scala.util.Sorting
implicit class Search[A, LS](val coll: LS)(implicit ls2idxseq: LS => IndexedSeq[A]) {
def binarySearch[B >: A](elem: B, from: Int = 0, to: Int = coll.length)
(implicit ord: Ordering[B]): SearchResult = {
if (to == from) InsertionPoint(from) else {
val idx = from + (to - from - 1) / 2
math.signum(ord.compare(elem, coll(idx))) match {
@veevidify
veevidify / clean.sh
Last active March 1, 2021 01:17
Docker scripts
# images
docker images -f dangling=true -q --no-trunc | xargs docker rmi
# containers
docker container ls -a -f status=exited -q --no-trunc | grep "search_container" | grep -v 'CONTAINER' | awk '{print $1}' | xargs docker container rm
# volumes
docker volume ls -qf dangling=true | xargs -r docker volume rm
# network
@veevidify
veevidify / backend-func.md
Last active October 19, 2021 06:21
HTTP backend framework checklist

auth

  • OAuth2
  • JWT
  • session (web)
  • RBAC
  • middlewares

config

  • pick up ENV
  • dev / staging / prod
@veevidify
veevidify / BST.hs
Last active April 11, 2019 00:18
Haskell snippets
module BST where
import Data.List
data Tree a = EmptyTree | Node a (Tree a) (Tree a) deriving (Show, Read, Eq)
unitTree :: a -> Tree a
unitTree x = Node x EmptyTree EmptyTree
treeAdd :: (Ord a) => a -> Tree a -> Tree a
@veevidify
veevidify / OOP.ts
Last active March 20, 2024 21:16
JS/TS snippets
class Base extends Object {
public baseProp: string
constructor() {
super();
this.baseProp = 'b';
}
}
class Derived extends Base {
public derivedProp: string
@veevidify
veevidify / JWTCustomPayload.php
Last active March 10, 2019 02:31
PHP snippets
<?
$claims = [
'exp' => JWTFactory::getTTL(),
'a' => $a,
'b' => $b,
'now' => \Carbon\Carbon::now()->toDateTimeString(),
];
$factory = JWTFactory::customClaims($claims);
$payload = $factory->make();