Skip to content

Instantly share code, notes, and snippets.

View kiasaki's full-sized avatar
🚧
Building many things

kiasaki kiasaki

🚧
Building many things
View GitHub Profile
@kiasaki
kiasaki / uid.rb
Created September 21, 2014 00:48
Rails UID Concern
module Uid
extend ActiveSupport::Concern
included do
before_create :generate_uid
end
def to_param
self.uid
end
@kiasaki
kiasaki / base32.js
Created January 27, 2020 16:48
Base32 encode/decode in Javascript
// 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 / readme.md
Last active September 6, 2022 11:13
ubuntu: vboxdrv module signing for secureboot to load it

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 / styles.css
Created May 17, 2022 18:39
Bearblog.dev Styles
body {
margin: auto;
padding: 32px;
max-width: 640px;
text-align: left;
word-wrap: break-word;
overflow-wrap: break-word;
line-height: 1.5;
font-size: 18px;
font-family: monospace;
@kiasaki
kiasaki / indexes.js
Last active January 29, 2020 16:25
FaunaDB role
CreateCollection({name: "users"})
CreateCollection({name: "accounts"})
CreateCollection({name: "items"})
CreateIndex({
name: "allUsers",
source: Collection("users"),
permissions: {read: null},
})
CreateIndex({
name: "allAccounts",
@kiasaki
kiasaki / introspect.gql
Created January 21, 2019 19:35
Graphql Introspection Query
query IntrospectionQuery {
__schema {
queryType { name }
mutationType { name }
subscriptionType { name }
types {
...FullType
}
directives {
name
@kiasaki
kiasaki / config
Last active December 12, 2018 12:54
wsltty / mintty 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 January 8, 2018 06:07 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@kiasaki
kiasaki / emacs_cheatsheet.md
Last active December 19, 2017 09:15
emacs_cheatsheet

Learning of emacs in progres...

  • M-x eval-buffer : Self-explanatory

  • M-x replace-string : Self-explanatory

  • C-x C-c : Quit emacs

  • C-g : Cancel current command (keyboard-quit)

Buffers

@kiasaki
kiasaki / Elo.java
Created June 17, 2017 05:08
Java Elo
import java.lang.Math;
public class Elo {
public int k;
public Elo(int k) {
this.k = k;
}
public double expectedScoreForDifference(int difference) {