Skip to content

Instantly share code, notes, and snippets.

@secretgspot
secretgspot / timelapse.sh
Created September 22, 2020 01:50 — forked from aemkei/timelapse.sh
Create a Timelapse with ffmpeg
ffmpeg -framerate 25 -f image2 -pattern_type glob -i "*.JPG" -s:v 1920x1440 -c:v libx264 -r 25 ../timelapse.mp4
import fs from 'fs';
import path from 'path';
import { promisify } from 'util';
import puppeteer from 'puppeteer';
import notifier from 'node-notifier';
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);
const SEARCH_URL = 'https://vancouver.craigslist.org/search/apa?sort=date&availabilityMode=0&max_price=3500&min_bedrooms=2&min_price=1900&postal=V5T2C2&postedToday=1&search_distance=2';
let arrived = true;
// Create a Promise
const ride = new Promise((resolve, reject) => {
if (arrived) {
resolve('driver arrived');
} else {
reject({msg: 'rejected', code: 222});
}
});
@secretgspot
secretgspot / per.js
Last active December 30, 2019 22:00
// https://www.youtube.com/watch?v=Wim9WJeDTHQ
let steps = 0;
const per = (num) => {
steps++;
let digits = [...String(num)].map(i => Number(i));
let result = digits.reduce((acc, cur) => acc * cur);
if (result == 0
|| String(result).length == 1
/* global localStorage */
import { writable } from 'svelte/store'
const storage = typeof localStorage !== 'undefined' ? localStorage : {
removeItem: key => { if (storage[key]) { delete storage[key] } },
}
/**
* Tracks storage both in `localStorage` and in svelte's `writable` stores
* Usage: `const name = storable('name', 'arxpoetica')`
// https://www.youtube.com/watch?v=ff4fgQxPaO0
/*
Because the JSON grammar is much simpler than JavaScript’s grammar, JSON can be
parsed more efficiently than JavaScript. This knowledge can be applied to improve
start-up performance for web apps that ship large JSON-like configuration object
literals (such as inline Redux stores).
*/
const data = { foo: 42, bar: 1337 }; // 🐌
// https://blog.logrocket.com/know-your-javascript-data-structures/
/*
* STACK
* LIFO - Last in, First out
* - Need to accept a value
* - Add that value to top of our Stack
* - Track the length of our stack to track stack's index
*/
/*
.__..__ .__ .__.. , __.
[__][__)[__)[__] \./ (__
| || \| \| | | .__)
*/
let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 2, 3, 4, 5, 7, 7];
/* ▀▀▀ // Shuffle array */
/*
.___. .. . __ .___.._..__.. . __.
[__ | ||\ |/ ` | | | ||\ |(__
| |__|| \|\__. | _|_|__|| \|.__)
*/
/* ▀▀▀ // Curried function */
function addition(x) {
return function(y) {
return x + y;
/*
.__ .___ __ .__..__ .__..___..__..__ __.
| \[__ / `| |[__)[__] | | |[__)(__
|__/[___\__.|__|| \| | | |__|| \.__)
*/
/* ▀▀▀ once()
once(fn): creates a version of the function that executes only once.
It’s useful for an initialization function, where we want to make sure it
runs only once, no matter how many times it is called from different places.