Skip to content

Instantly share code, notes, and snippets.

View jugyo's full-sized avatar
🏠
Working from home

Kaz jugyo

🏠
Working from home
  • The League
  • New Jersey
View GitHub Profile
import android.database.Cursor
inline operator fun <reified T> Cursor.get(column: String): T? {
val columnIndex = getColumnIndex(column)
if (columnIndex == -1) {
// Column not found
return null
}
return when (T::class) {
package com.example.compose_drag_and_drop
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.detectDragGesturesAfterLongPress
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.MaterialTheme
#!/bin/bash
# NOTE: based on a snippet found in somewhere in Stack Overflow
find . -type d -name .git -maxdepth 2 | while read line; do
(
cd $line/..
cwd=$(pwd)
echo "$(tput setaf 2)$cwd$(tput sgr0)"
git --no-pager grep -n -- "$@"
...
export class AppModule {
constructor(router: Router, viewportScroller: ViewportScroller) {
router.events.pipe(filter((e) => e instanceof Scroll)).subscribe((e: any) => {
if (e.position) {
// backward navigation
setTimeout(() => {
viewportScroller.scrollToPosition(e.position);
}, 100);
} else if (e.anchor) {
const crypto = require("crypto")
export function verifyGithubWebhook(payload: string, signature: string, secret: string) {
const hmac = crypto.createHmac("sha1", secret)
hmac.update(JSON.stringify(payload))
const calculatedSignature = "sha1=" + hmac.digest("hex")
const valid = crypto.timingSafeEqual(Buffer.from(calculatedSignature), Buffer.from(signature))
if (!valid) {
throw new Error("Invalid github webhook call")
}
#!/bin/sh
echo $* | awk '{ gsub(/[^A-Za-z]+/, "-"); print tolower($0) }'
# Depends on App
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: An example SAM template for Lambda Safe Deployments.
Parameters:
DomainName:
Type: String
CertificateArn:
@jugyo
jugyo / App.yaml
Last active April 13, 2019 04:19
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: An example SAM template for Lambda Safe Deployments.
Globals:
Api:
BinaryMediaTypes:
- '*/*'
Resources:
const test = require("firebase-functions-test")(
{
databaseURL: "https://my-project.firebaseio.com",
storageBucket: "my-project.appspot.com",
projectId: "my-project",
},
"./testServiceAccountKey.json"
)
const functions = require("../index") // NOTE: This has to be called after `require("firebase-functions-test")(...)`
export { functions }
"use strict";
import * as process from "process";
import * as vscode from "vscode";
import * as fs from "fs-extra";
const dirPath = `${process.env.HOME}/.vscode/jsnippet`;
const extension = "snippet";
const template = "console.log($1);";