Skip to content

Instantly share code, notes, and snippets.

View electerious's full-sized avatar

Tobias Reich electerious

View GitHub Profile
@electerious
electerious / generateImages.js
Created August 26, 2023 14:02
Image processing with Node.js and sharp
import { parse, format } from 'path'
import Progress from 'cli-progress'
import sharp from 'sharp'
const fit = process.argv[2]
const width = parseInt(process.argv[3])
const height = parseInt(process.argv[4])
const paths = process.argv.splice(5)
const toFile = (path) => {
@electerious
electerious / ackee_scriptable_views_today.js
Last active March 17, 2021 18:32
Ackee iOS widget for Scriptable.app
// On first run only, uncomment line bellow and replace '888...' with the token returned after login
// Keychain.set("ACKEE_KEY", "88888888-8888-8888-8888-888888888888")
// Ackee configuration
const ACKEE_KEY = Keychain.get('ACKEE_KEY')
const ACKEE_API = 'https://ackee.example.com/api'
const TIME_ZONE = 'Europe/Berlin'
const createWidget = async () => {
const viewsToday = await getViewsToday()
{
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": [
"react"
const throttle = (fn, threshold) => {
let last
let timeout
return (...args) => {
const now = Date.now()
const shouldDelay = last && now < last + threshold
const delay = shouldDelay === true ? threshold - (now - last) : 0
@electerious
electerious / absoluteToRelativePath.js
Created November 4, 2018 12:50
Converts absolute SVG coordinates to relative ones in order to create a responsive SVG mask that can be applied using CSS clip-path
"M78,0 L78.8918331,0.216238031 C80.7796201,0.673959707 82.3332983,2.08608489 83.0043945,3.9000001 C83.0192652,3.94019419 83.0330484,3.98600042 83.0457442,4.03741878 L83.0390876,7.96097867 C83.0390545,20.7025492 93.3365052,31 106.039054,31 L268.960946,31 C281.663495,31 291.960946,20.7025492 291.960946,8 C291.960946,7.99147462 291.95879,6.71458263 291.954479,4.16932405 C291.954323,4.07746778 291.970341,3.98630146 292.001801,3.9000001 C292.667785,2.07301174 294.211271,0.676168263 296.108167,0.216238031 L297,0 L335,0 C357.09139,-4.05812251e-15 375,17.90861 375,40 L375,772 C375,794.09139 357.09139,812 335,812 L40,812 C17.90861,812 2.705415e-15,794.09139 0,772 L0,40 C-2.705415e-15,17.90861 17.90861,4.05812251e-15 40,0 L78,0 Z"
.split(' ')
.reduce((acc, entry) => {
// Remove the first character from a string
const removeChars = (str = '') => str.replace(/^[A-Z]/g,'')
// Divide a value with the current divider
const divide = (dividers) => (value, index) => value / dividers[index]
<label for="familyname">Family name</label>
<input id="familyname" name="familyname" type="text" autocorrect="off" autocomplete="family-name" placeholder="Berners-Lee">
<select disabled>
<option value="a">A</option>
<option value="b">B</option>
</select>
<select>
<option disabled>Choose A or B</option>
<option value="a">A</option>
<option value="b">B</option>
</select>
<input placeholder="Jane Doe" ...>
<label for="email">E-Mail</label>
<input id="email" ...>
<input pattern="\d*" ...>
<input type="email" ...>
<input type="url" ...>