Skip to content

Instantly share code, notes, and snippets.

View kevinmungai's full-sized avatar

Kevin Mungai kevinmungai

View GitHub Profile
kevinmungai /
Last active April 5, 2024 07:59
How to add tailwind prettier plugin to sveltekit project with pnpm
  1. Install latest prettier and plugins
pnpm add -D prettier@latest prettier-plugin-svelte@latest prettier-plugin-tailwindcss@latest
  1. Change the default .prettierrc to prettier.config.js and replace with the following.
/** @type {import("prettier").Config} */
export default {
	useTabs: true,
kevinmungai / +layout.server.ts
Created September 1, 2023 21:05 — forked from ciscoheat/+layout.server.ts
Superforms with sveltekit-flash-message
export { load } from 'sveltekit-flash-message/server';
kevinmungai /
Created February 22, 2023 18:22 — forked from riceissa/
my current understanding of Anki's spacing algorithm
This is my understanding of the Anki scheduling algorithm, which I mostly
got from watching
and from reading
There is also but I find
it really hard to understand.
Things I don't bother to implement here: the random fudge factor (that Anki
kevinmungai / MetricsUtil.kt
Created November 29, 2021 11:04 — forked from kevinhaitsma/MetricsUtil.kt
Convert dp to px and px to dp in Kotlin for Android
import android.content.Context
import android.content.res.Resources
import android.util.DisplayMetrics
* Provides utilities for metrics.
* Original at:
* @see <a href="">stack overflow answer</a>
kevinmungai / initialization.sql
Created November 29, 2021 07:16 — forked from jbrown123/-Recursive Queries Using Common Table
Creating arbitrary-depth recursive queries in SQLITE (works for any SQL compliant system) using CTEs (common table expressions)
CREATE TABLE users (name, cn, title, manager);
-- create a CTE (common table expression)
-- think of this as creating a temporary table that only exists during this query
-- works somewhat like CREATE TEMPORARY TABLE bosspath(cn, path)
WITH RECURSIVE bosspath(cn,path) AS
kevinmungai / idb.js
Created June 3, 2021 10:29 — forked from TalAter/idb.js
IndexedDB upgrade code to add index to an existing object store
request.onupgradeneeded = function(event) {
var db =;
var upgradeTransaction =;
var objectStore;
if (!db.objectStoreNames.contains("my-store")) {
objectStore = db.createObjectStore("my-store");
} else {
objectStore = upgradeTransaction.objectStore('my-store');


<script lang="ts">

import { onMount, setContext } from "svelte";
import { firebaseStore } from "../stores/firebase_store";
import {Child} from "../components/Child.svelte";

setContext("firebaseStore", firebaseStore);
kevinmungai /
Created December 27, 2020 07:15
Sapper with Firebase Hosting
  1. Create Directory for your app mkdir my-app
  2. get the sapper template npx degit "sveltejs/sapper-template#rollup"
  3. Install the packages npm i
  4. Install express server npm i express
  5. Initialize Firebase firebase init
kevinmungai / CurrencyPtBrInputFormatter.dart
Created December 4, 2020 07:51 — forked from andre-bahia/CurrencyPtBrInputFormatter.dart
Flutter TextInputFormatter Currency pt_BR
import 'package:flutter/services.dart';
import 'package:intl/intl.dart';
class CurrencyPtBrInputFormatter extends TextInputFormatter {
TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
if(newValue.selection.baseOffset == 0){
return newValue;
kevinmungai / web-component-v1.cljs
Created April 3, 2020 15:02 — forked from thheller/web-component-v1.cljs
create web-component v1 in cljs without class
(defn component []
(js/Reflect.construct js/HTMLElement #js [] component))
(set! (.-prototype component)
(js/Object.create (.-prototype js/HTMLElement)
#js {:connectedCallback
#js {:configurable true
(fn []
(this-as this