Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A class for storing and retrieve compressed objects into local storage. | |
*/ | |
export class CompressedStorage { | |
async get(key: string) { | |
const base64 = localStorage.getItem(key); | |
if (base64 === null) { | |
return null; | |
} | |
const blob = await this.fromBase64Url(base64); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A simple way to store binary data inside a js/ts file with a density of 1 char per byte. | |
// Even though each char takes 2 bytes. | |
const b256enc = (buff: Uint8Array) => [...buff].map(i => String.fromCodePoint(i + 192)).join(''); | |
const b256dec = (str: string) => str.split('').map(c => c.charCodeAt(0) - 192); | |
// Example 1: Basic usage | |
const data = new Uint8Array([ 127, 127, 168, 226, 120, 62, 44, 146, 82, 213, 0, 30 ]); | |
const encoded = b256enc(data); | |
console.log(encoded); // 'ĿĿŨƢĸþìŒĒƕÀÞ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function packUUID(uuid: string): string { | |
let v; | |
let bytes = ''; | |
// Parse ########-....-....-....-............ | |
bytes += String.fromCharCode((v = parseInt(uuid.slice(0, 8), 16)) >>> 24); | |
bytes += String.fromCharCode((v >>> 16) & 0xff); | |
bytes += String.fromCharCode((v >>> 8) & 0xff); | |
bytes += String.fromCharCode(v & 0xff); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="loader"></div> | |
<style> | |
.loader { | |
--size: 5rem; | |
--weight: .5rem; | |
--background: rgba(127, 127, 127, .1); | |
--color: rgba(127, 127, 127, .9); | |
--duration: 1s; | |
position: fixed; | |
top: calc(50% - var(--size) / 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Unsubscribe from all "orgName" repositories in https://github.com/watching | |
* | |
* https://github.com/isaacs/github/issues/641 | |
* @param string orgName | |
*/ | |
function unwatchOrgRepos(orgName) { | |
if (!window.location.href.startsWith('https://github.com/watching')) { | |
throw new Error('This script is intended to be run in "https://github.com/watching"') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Locale strings | |
* You can get it from https://github.com/iamkun/dayjs/blob/dev/src/locale/ | |
*/ | |
const loc = { | |
future: 'in %s', | |
past: '%s ago', | |
s: 'a few seconds', | |
m: 'a minute', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
name = Pavan Kumar Sunkara | |
email = [email protected] | |
username = pksunkara | |
[core] | |
editor = vim | |
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol | |
excludesfile = ~/.gitignore | |
[sendemail] | |
smtpencryption = tls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this in your ~/.gitconfig or ~/.config/git/config | |
# Windows users: "~" is your profile's home directory, e.g. C:\Users\<YourName> | |
[user] | |
name = Your Full Name | |
email = [email protected] | |
[color] | |
# Enable colors in color-supporting terminals | |
ui = auto | |
[alias] | |
# List available aliases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IsValidEan13 return true if given ean13 number is valid | |
func IsValidEan13(code string) bool { | |
if len(code) != 13 { | |
return false | |
} | |
oddSum := 0 | |
evenSum := 0 | |
for i, n := range code[:12] { | |
digit := int(n - '0') |
NewerOlder