View CursorExtension.kt
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 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) { |
View DraggableGridExample.kt
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
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 |
View ggrep
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
#!/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 -- "$@" |
View app.module.ts
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
... | |
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) { |
View verify-github-webhook.ts
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
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") | |
} |
View hyphenate
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
#!/bin/sh | |
echo $* | awk '{ gsub(/[^A-Za-z]+/, "-"); print tolower($0) }' |
View DomainMapping.yaml
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
# 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: |
View App.yaml
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
AWSTemplateFormatVersion : '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Description: An example SAM template for Lambda Safe Deployments. | |
Globals: | |
Api: | |
BinaryMediaTypes: | |
- '*/*' | |
Resources: |
View firebase_test_helper.ts
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
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 } |
View jnippet.ts
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 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);"; |
NewerOlder