Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
😐

Kaz jugyo

💭
😐
  • MUA inc.
  • New York
View GitHub Profile
View DraggableGridExample.kt
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
#!/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
...
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
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
#!/bin/sh
echo $* | awk '{ gsub(/[^A-Za-z]+/, "-"); print tolower($0) }'
View DomainMapping.yaml
# 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
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
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
"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);";
@jugyo
jugyo / systemd-tmpfiles-clean.md
Last active Sep 26, 2018
Arch linux & systemd-tmpfiles-clean
View systemd-tmpfiles-clean.md

/tmp on Arch Linux

Arch linux はメモリーの半分の容量のスペースを tmp ファイルシステムとして /tmp にマウントする。例えば8GBのメモリを積んでいたら /tmp の容量はデフォルトで 4GB になる。試しに手元の環境で df コマンドを実行すると以下のような情報が得られた:

# df -h
Filesystem      Size  Used Avail Use% Mounted on
dev             3.9G     0  3.9G   0% /dev
run             3.9G  384K  3.9G   1% /run
/dev/sda 158G 8.0G 142G 6% /