Skip to content

Instantly share code, notes, and snippets.

@ErikHellman
ErikHellman / WebViewServer.kt
Last active September 12, 2023 16:10
This class is no longer needed now that Google provides WebViewAssetLoader (see https://developer.android.com/reference/kotlin/androidx/webkit/WebViewAssetLoader)
/*
MIT License
Copyright (c) 2019 Erik Hellman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@aelbore
aelbore / typescript-web-components.md
Last active December 7, 2023 20:14
Step by Step creating web components in typescript using rollup

Getting Started

  • Install Dependencies
    npm init
    npm install --save-dev ts-node typescript tslib express @types/express
    

Create your web server

  • Create server.ts in root folder of your app.
@bryandh
bryandh / .Service Worker Setup.md
Last active January 25, 2023 16:21
Service Worker setup in Typescript

Service Worker Setup

@cecilemuller
cecilemuller / launch.json
Last active March 14, 2024 11:31
Run ts-node in VSCode Debugger
{
"version": "0.2.0",
"configurations": [
{
"name": "Example",
"type": "node",
"request": "launch",
"runtimeExecutable": "node",
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"],
@thejsj
thejsj / pearson-hashing.js
Last active September 11, 2021 03:59
Pearson Hashing Function
'use strict'
// Ideally, this table would be shuffled...
// 256 will be the highest value provided by this hashing function
let table = [...new Array(256)].map((_, i) => i)
const hash8 = (message, table) => {
return message.split('').reduce((hash, c) => {
return table[(hash + c.charCodeAt(0)) % (table.length - 1)]
}, message.length % (table.length - 1))
@ygotthilf
ygotthilf / jwtRS256.sh
Last active April 25, 2024 19:58
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@azu
azu / tsconfig + gulp-typescript.md
Last active August 18, 2020 07:19
tsconfig + gulp-typescript

azu/typescript1.5-es6module-npm at tsconfig-gulp

tsconfigが未対応なtsc1.4でもtsconfig.jsonをただの設定ファイル置き場として使う例。 filesGlobはatom-typescriptの独自拡張だけど

.
├── README.md
├── build
│   ├── bundle.js
@rjcorwin
rjcorwin / create-a-file-and-upload-as-attachment-to-couchdb.js
Created November 15, 2012 15:35
With Javascript, create a new file and send it to a CouchDB database as an attachment to a document
// With Javascript, create a new file and send it to a CouchDB database as an attachment of a Document
// Code inspired by "NEW TRICKS IN XMLHTTPREQUEST2" by Eric Bidelman
// http://www.html5rocks.com/en/tutorials/file/xhr2/
/*
* There are two ways of accomplishing this. The first way will always result in a filename of "blob", which is
* bummer. The second way you will be able to name the file what you want. Note that these examples
* assume you have the ID of the database, the ID of the Document, and the most recent revision hash of that Document.
*/
@Goles
Goles / CountryCodes.json
Created July 29, 2012 05:37
Country and Dial or Phone codes in JSON format
[{"name":"Israel","dial_code":"+972","code":"IL"},{"name":"Afghanistan","dial_code":"+93","code":"AF"},{"name":"Albania","dial_code":"+355","code":"AL"},{"name":"Algeria","dial_code":"+213","code":"DZ"},{"name":"AmericanSamoa","dial_code":"+1 684","code":"AS"},{"name":"Andorra","dial_code":"+376","code":"AD"},{"name":"Angola","dial_code":"+244","code":"AO"},{"name":"Anguilla","dial_code":"+1 264","code":"AI"},{"name":"Antigua and Barbuda","dial_code":"+1268","code":"AG"},{"name":"Argentina","dial_code":"+54","code":"AR"},{"name":"Armenia","dial_code":"+374","code":"AM"},{"name":"Aruba","dial_code":"+297","code":"AW"},{"name":"Australia","dial_code":"+61","code":"AU"},{"name":"Austria","dial_code":"+43","code":"AT"},{"name":"Azerbaijan","dial_code":"+994","code":"AZ"},{"name":"Bahamas","dial_code":"+1 242","code":"BS"},{"name":"Bahrain","dial_code":"+973","code":"BH"},{"name":"Bangladesh","dial_code":"+880","code":"BD"},{"name":"Barbados","dial_code":"+1 246","code":"BB"},{"name":"Belarus","dial_code":"+375","