Skip to content

Instantly share code, notes, and snippets.

View unavailable.html
<html dir="ltr" lang="en"><head>
<meta charset="utf-8">
<meta name="color-scheme" content="light dark">
<meta name="theme-color" content="#fff">
<meta name="viewport" content="width=device-width, initial-scale=1.0,
maximum-scale=1.0, user-scalable=no">
<title>www.contractbook.co</title>
<style>/* Copyright 2017 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
@ahallora
ahallora / A YouTube regExp VideoID and host.md
Last active Feb 17, 2021
Extract video ID and host name from Youtube URL
View A YouTube regExp VideoID and host.md

Extract video ID and host name from Youtube URL

A regular expression to extract video ID and host name from a wide range of different youtube links. Built upon this foundation.

^(?:https?:\/\/)?(?:www\.)?(?:m\.)?((youtu\.be|youtube\.com)(?:\/embed\/watch\\?.+|\/watch\?v=|watch\?.+&v=|.))([\w-]{11})(?:.+)?$

Supported URLs

@ahallora
ahallora / retro.md
Created Feb 11, 2021
How to run a retrospective
View retro.md

How to run retro-spective

Pre-requisites

  1. Make sure you have access to easyretro
  2. Make sure you have access to previous retro board
  3. Create a public retro board in time

How to

  1. send out links to previous + current retro
  2. walk through action points from previous retro (any carry over unfinished action points to current retro)
@ahallora
ahallora / dotPathToObject.js
Last active Feb 4, 2021
Convert string in dot notation into an object with JavaScript
View dotPathToObject.js
const dotPathToObject = (pathStr, value) => pathStr
.split(".")
.reverse()
.reduce((acc, cv, index) => ({
[cv]: index === 1 && value ? {[acc]: value} : acc
}))
console.log("expect:", JSON.stringify({
"a": {
@ahallora
ahallora / README.md
Created Jan 1, 2021
Streambeats Dropbox audio preview snippet
View README.md

Streambeats Dropbox audio preview snippet

Why?

Harris (https://twitter.com/HarrisHeller) has done a remarkable job with Streambeats (https://www.streambeats.com) and the massive library of high quality music for your streaming needs. The library was so vast that I didn't want to just download everything and listen to it locally, so instead I did what every programmer would do. I did a small code snippet to add a preview pane to the Dropbox experience.

How?

  1. Copy the snippet below
  2. Enter a folder in Dropbox containing music files; e.g. https://www.dropbox.com/sh/1cgxqyptl2jq8f5/AAAeQ1i1rwAV6zIDNN2VHJY6a/8.%20White?dl=0&subfolder_nav_tracking=1
  3. Switch to table view in the folder view
  4. Press CTRL+SHIFT+I (Windows) / CMD+SHIFT+I (Mac) to open Chrome Developer Tools
@ahallora
ahallora / s1ep1.md
Created Jul 28, 2020
Math and JavaScript live problem solving with Anders - episode 1
View s1ep1.md

Math and JavaScript live problem solving - episode 1

Welcome to this mini series of me trying to solve a simple math problem with Javascript. I apologize in advance to everyone more capable in both math and javascript.

Today's objective

  • Divide a number by 100 and limit the result's amount of decimals to 5 tops.
  • Expected outcome: 49.95 becomes 0.4995 and 9.95 becomes 0.0995.

That's easy, you might think.

@ahallora
ahallora / index.html
Created Jun 19, 2020
XSS onerror image example
View index.html
<img src=x onerror="&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041">
@ahallora
ahallora / README.md
Last active May 13, 2020
Webflow API rate limiter workaround (ES6 / Nodejs)
View README.md

Webflow API rate limit workaround

This is a naive work-around to the glitchy rate limiter of the current Webflow API. Any suggestions to optimizations is much appreciated.

How to use

It's a wrapper to your existing webflow-api functions, where you define two parameters:

  1. a collection ID and
  2. the function you want to call

If you have reached the rate limit this wrapper will handle the error and try to reset the rate

@ahallora
ahallora / CsvToJson.js
Created Apr 8, 2020
Javascript function to convert a CSV list into list of JSON objects
View CsvToJson.js
const mapCsvToJson = (csv, delimiter) => {
const lines = csv.split("\n");
let dataArray = [];
let keys = [];
for (i = 0; i < lines.length; i++) {
const line = lines[i];
const data = line.split(delimiter);
if (i === 0) {
@ahallora
ahallora / LambdaCacheController.js
Last active Mar 29, 2020
Simple AWS Lambda Container In-Memory Cache Controller for Node.js / ES6
View LambdaCacheController.js
export class LambdaCacheController {
constructor() {
this.value = null;
this.timestamp = null;
this.ttl = 3000000; // default 5 minutes
}
async getValue() {
return new Promise((resolve, reject) => {
try {