Skip to content

Instantly share code, notes, and snippets.

💭
😐

Kaz jugyo

💭
😐
Block or report user

Report or block jugyo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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% /
View UserDidTakeScreenshot.swift
let mainQueue = OperationQueue.main
NotificationCenter.default.addObserver(forName: NSNotification.Name.UIApplicationUserDidTakeScreenshot, object: nil, queue: mainQueue) { _ in
action()
}
View vs-code-key-bindings.json
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+t",
"command": "workbench.action.quickOpen"
},
{
"key": "ctrl+cmd+left",
"command": "workbench.action.navigateBack"
},
You can’t perform that action at this time.