Skip to content

Instantly share code, notes, and snippets.

View netroy's full-sized avatar

कारतोफ्फेलस्क्रिप्ट™ netroy

View GitHub Profile
@netroy
netroy / Changes
Last active May 14, 2021 10:01
3018 notes
$3=2
$10=115
$32=1
$100=800.000
$101=800.000
$102=800.000
$110=1500.000
$111=1500.000
$112=1200.000
$120=300.000
@netroy
netroy / code.py
Last active December 12, 2021 06:36
circuitpython clock for Lilygo TTGO T8 ESP32-S2
import struct
import time
import board
import displayio
import rtc
import socketpool
import terminalio
import wifi
from adafruit_display_text import label
@netroy
netroy / lambda-pinpoint.js
Last active March 20, 2024 18:49
Use A Lambda function to send an SMS over Amazon Pinpoint
const appId = [[PINPOINT_APPLICATION_ID]];
const destination = [[YOUR_PHONE_NUMBER]];
const { Pinpoint } = require('aws-sdk');
const pinpoint = new Pinpoint();
const payloadFn = (appId, destination, message) => {
const ApplicationId = appId;
const Addresses = {};
@netroy
netroy / 0-readme.md
Last active November 9, 2019 18:29
Easy theming with CSS vars, calc, & HSL

To test this,

  1. setup Vue prototyping tools yarn global add @vue/cli @vue/cli-service-global, or npm install -g @vue/cli @vue/cli-service-global
  2. run vue serve TestDarkMode.vue
  3. open http://localhost:8080/
  4. profit???
@netroy
netroy / backup.js
Last active November 19, 2019 18:39
backup data from Wunderlist web app
var exporter = requirejs.s.contexts._.defined["backend/export"]
exporter.fetchAllTheData()
.fail(e => console.log("error", e))
.done(data => {
var link = exporter.getBlobLink(data)
document.body.appendChild(link)
link.click()
})
@netroy
netroy / benchmark-resize.js
Created November 14, 2018 13:27
Benchmark image resize modules
const sharp = require('sharp')
const Jimp = require('jimp')
const { Suite } = require('benchmark')
var suite = new Suite()
// add tests
suite
.add('Sharp', {
defer: true,
@netroy
netroy / lambda.js
Created August 20, 2018 12:47
Multi Origin Cloudfront (using Lambda@Edge)
"use strict";
const { promisify } = require('util');
const { resolveCname } = require('dns');
const resolveCnameAsync = promisify(resolveCname);
let resultCache = null;
const deferClearCache = () => setTimeout(() => { resultCache = null }, 1000);
const resolve = async () => {
@netroy
netroy / generators-vs-asyncawait-vs-native-promises.js
Last active November 14, 2018 13:50 — forked from MarkHerhold/generators-vs-asyncawait.js
Generators VS Async/Await Performance
const co = require('co')
const Benchmark = require('benchmark')
const suite = new Benchmark.Suite
const Generate = () => new Promise(resolve => {
// resolve(1)
setImmediate(() => resolve(1))
// setTimeout(() => resolve(1), 10)
})
@netroy
netroy / maze.js
Last active August 15, 2017 08:15
Soundcloud's follower-maze challenge in Javascript
// This code could use comments, tests, & a million other things..
// but since I did not apply at soundcloud, it doesn't matter
const net = require('net')
const split = require('split')
const PriorityQueue = require('priorityqueuejs')
const clients = {}
const followers = {}
const queue = new PriorityQueue((a, b) => b.sequence - a.sequence)
@netroy
netroy / index.js
Last active August 15, 2017 08:17
fitbit oauth
const OAuth2 = require('oauth').OAuth2
const Koa = require('koa')
const router = require('koa-router')()
const querystring = require('querystring')
const FITBIT_KEY = '---'
const FITBIT_SECRET = '---'
const baseUrl = 'https://www.fitbit.com'
const authUrl = '/oauth2/authorize'