Skip to content

Instantly share code, notes, and snippets.

Avatar
🚧
Building many things

Frederic kiasaki

🚧
Building many things
View GitHub Profile
@kiasaki
kiasaki / indexes.js
Last active Jan 29, 2020
FaunaDB role
View indexes.js
CreateCollection({name: "users"})
CreateCollection({name: "accounts"})
CreateCollection({name: "items"})
CreateIndex({
name: "allUsers",
source: Collection("users"),
permissions: {read: null},
})
CreateIndex({
name: "allAccounts",
@kiasaki
kiasaki / base32.js
Created Jan 27, 2020
Base32 encode/decode in Javascript
View base32.js
// From https://technote.fyi/code/javascript/base32-encoding-and-decoding-in-javascript/
(function(exports) {
var base32 = {
a: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
pad: "=",
encode: function (s) {
var a = this.a;
var pad = this.pad;
var len = s.length;
var o = "";
@kiasaki
kiasaki / introspect.gql
Created Jan 21, 2019
Graphql Introspection Query
View introspect.gql
query IntrospectionQuery {
__schema {
queryType { name }
mutationType { name }
subscriptionType { name }
types {
...FullType
}
directives {
name
@kiasaki
kiasaki / config
Last active Dec 12, 2018
wsltty / mintty config
View config
BackgroundColour=255,255,255
ForegroundColour=55,59,65
CursorColour=38,38,38
Black=29,31,33
BoldBlack=150,152,150
Red=204,102,102
BoldRed=204,102,102
Green=181,189,104
BoldGreen=181,188,104
Yellow=240,198,116
@kiasaki
kiasaki / main.go
Created Jan 8, 2018 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
View main.go
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
View Elo.java
import java.lang.Math;
public class Elo {
public int k;
public Elo(int k) {
this.k = k;
}
public double expectedScoreForDifference(int difference) {
View s3-public-website-policy.txt
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
View async_lazy_load_assets.js
/*!
*
* Copyright 2016 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@kiasaki
kiasaki / readme.md
Last active Aug 3, 2020
ubuntu: vboxdrv module signing for secureboot to load it
View readme.md

Since kernel version 4.4.0-20, it was enforced that unsigned kernel modules will not be allowed to run with Secure Boot enabled. Because you want to keep Secure Boot, then the next logical step is to sign those modules.

So let's try it.

Create signing keys

openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=Descriptive name/"
@kiasaki
kiasaki / compile.js
Created Jul 24, 2016
regexes for fun, and pr... really just for fun
View compile.js
function compile(code) {
code = code.replace(/def\s+([a-zA-Z0-9_$]+)((?:\s[a-zA-Z0-9_$]+)+)\s+=((?:(?!\n\n)[\s\S])+)/g, function (_, functionName, args, functionBody) {
var functionArgs = args.trim().replace(/\s+/g, ', ');
return ['function ', functionName, '(', functionArgs, ') {\n return ', functionBody.trimLeft(), ';}'].join('');
});
code = code.replace(/let((?:(?!in)[\s\S])+)in/g, function(_, args) {
return 'var ' + args.trim() + ';;';
});
code = code.replace(/\n[\n]+/g, ';\n');
code = code.replace(/\n$/g, ';\n');