Skip to content

Instantly share code, notes, and snippets.

- Template:
- 1. Outline use cases, constraints, and assumptions:
- Who is going to use it?
- How are they going to use it?
- How many users are there?
- What does the system do?
- What are the inputs and outputs of the system?
- How much data do we expect to handle?
- How many requests per second do we expect?
- What is the expected read to write ratio?
// progress
const width=125
const h=5
const w = new ListWidget()
w.backgroundColor=new Color("#222222")
const now = new Date()
const weekday = now.getDay() == 0 ? 6 : now.getDay() - 1
const minutes=now.getMinutes()
getwidget(24*60, (now.getHours() + 1)*60+minutes, "Today")
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: red; icon-glyph: calendar-alt;
const TERMS = "nature"
const FORCE_IMAGE_UPDATE = true
const TEST_MODE = false
// Store current datetime
const date = new Date()
@d4rkr00t
d4rkr00t / why-re-rendered.js
Last active December 1, 2019 23:13
Why re-rendererd
componentDidUpdate(prevProps, prevState) {
Object.entries(this.props || {}).forEach(([key, val]) =>
prevProps[key] !== val && console.log(`[debug] ${this.constructor.displayName ||
this.constructor.name} prop '${key}' changed`)
);
Object.entries(this.state || {}).forEach(([key, val]) =>
prevState[key] !== val && console.log(`[debug] ${this.constructor.displayName ||
this.constructor.name} state '${key}' changed`)
);
}
@d4rkr00t
d4rkr00t / aik-talk.md
Last active January 5, 2023 18:18
Aik Talk

Introduction

Hi, my name is Stan. And I moved here with my family just about 2 months ago from Russia.

And I'm very nervous now. Because it's my first talk in English. I hope it goes well. But. Anyway. Let's start.

When I started getting into web development a while ago, I was doing mostly PHP. And do you know what I loved the most about PHP? It's how easy it was to start actually doing something.

MAMP

@d4rkr00t
d4rkr00t / codewars-helpers.js
Last active December 1, 2019 23:12
Codewars Helpers
const removeSpaces = str => str.replace(/\s/g, '');
const pickObjProps = (obj, props) => props.reduce((acc, key) => obj[key] ? acc.concat([obj[key]]) : acc, []);
@d4rkr00t
d4rkr00t / text_length.js
Created May 6, 2015 04:58
Shows length of selected elems text
document.body.addEventListener('click', function chooseElem (e) {
e.preventDefault();
e.stopPropagation();
var text = e.target.innerText;
console.groupCollapsed ('Text');
console.log(text);
console.groupEnd('Text');
@d4rkr00t
d4rkr00t / init_array.js
Created December 23, 2014 07:40
Initialize array with values
Array.apply(null, Array(3)).map(function(x, i) { return i; });
@d4rkr00t
d4rkr00t / all_media_queries.js
Last active August 29, 2015 14:07
Dev Tools Snippet for getting all Media Queries on page
var _pairs = function(obj) {
var resArr = [];
for (k in obj) {
if(obj.hasOwnProperty(k)) {
resArr.push([k, obj[k]]);
}
}
return resArr;
@d4rkr00t
d4rkr00t / grep.md
Last active November 8, 2018 13:48
Grep command snippets

Simple GREP

grep CPU: /var/run/dmesg.boot

Count grepped lines

grep WARNING /var/run/dmesg.boot -c