just the bare necessities of state management.
Hotlink it from https://unpkg.com/valoo
.
const minute = 60; | |
const hour = minute * 60; | |
const day = hour * 24; | |
const week = day * 7; | |
const month = day * 30; | |
const year = day * 365; | |
/** | |
* Convert a date to a relative time string, such as | |
* "a minute ago", "in 2 hours", "yesterday", "3 months ago", etc. |
Mute these words in your settings here: https://twitter.com/settings/muted_keywords | |
ActivityTweet | |
generic_activity_highlights | |
generic_activity_momentsbreaking | |
RankedOrganicTweet | |
suggest_activity | |
suggest_activity_feed | |
suggest_activity_highlights | |
suggest_activity_tweet |
// These hashes are for algorithmic use cases, such as bucketing in hashtables, where security isn't | |
// needed and 32 or 64 bits is enough (that is, rare collisions are acceptable). These are way simpler | |
// than sha1 (and all its deps) or similar, and with a short, clean (base 36 alphanumeric) result. | |
// A simple, *insecure* 32-bit hash that's short, fast, and has no dependencies. | |
// Output is always 7 characters. | |
// Loosely based on the Java version; see | |
// https://stackoverflow.com/questions/6122571/simple-non-secure-hash-function-for-javascript | |
const simpleHash = str => { | |
let hash = 0; |
/* | |
MIT License | |
Copyright (c) 2020 Egor Nepomnyaschih | |
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 |
// Prop/Method Decorator with no arguments | |
function logDecorator(t, n, descriptor) { | |
const original = descriptor.value; | |
if (typeof original === 'function') { | |
descriptor.value = function(...args) { | |
console.log(`Arguments: ${args}`); | |
try { | |
const result = original.apply(this, args); | |
console.log(`Result: ${result}`); | |
return result; |
/* | |
Two things will happen here: | |
1) normalize()ing to NFD Unicode normal form decomposes combined graphemes into the combination of simple ones. The è of Crème ends up expressed as e + ̀. | |
2) Using a regex character class to match the U+0300 → U+036F range, it is now trivial to globally get rid of the diacritics, which the Unicode standard conveniently groups as the Combining Diacritical Marks Unicode block. | |
*/ | |
export const normalizeChar = char => char.normalize('NFD').replace(/[\u0300-\u036f]/g, '') | |
export const normalizeStr = str => str.split('').map(normalizeChar).join('') |
just the bare necessities of state management.
Hotlink it from https://unpkg.com/valoo
.
# Update Jan 2024 | |
# Deploying Cloud Functions is much simpler than it was 6 years ago. | |
# I'm leaving the gist in it's original 2018 state for now, | |
# but skip the the recent comments below for a simpler solution. | |
variables: | |
GCP_ZONE: us-central1-a | |
stages: | |
- npm-install |
As a developer, it bothers me when someone sends me a large pdf file compared to the number of pages. Recently, I recieved a 12MB scanned document for just one letter-sized page... so I got to googlin, like I usually do, and found ghostscript!
to learn more abot ghostscript (gs): https://www.ghostscript.com/
What we are interested in, is the gs command line tool, which provides many options for manipulating PDF, but we are interested in compressign those large PDF's into small yet legible documents.
credit goes to this answer on askubuntu forum: https://askubuntu.com/questions/3382/reduce-filesize-of-a-scanned-pdf/3387#3387?newreg=bceddef8bc334e5b88bbfd17a6e7c4f9