Skip to content

Instantly share code, notes, and snippets.

View designervoid's full-sized avatar
🌌

designervoid

🌌
View GitHub Profile
@designervoid
designervoid / fruits-iterator.dart
Created April 14, 2021 13:11 — forked from thatisuday/fruits-iterator.dart
Iterator Example in Dart
// A `Fruit` object contains `name` and `color`
class Fruit {
final String name;
final String color;
Fruit( this.name, this.color );
}
// A `Fruits` collection contains the List of `Fruit` object
// `iterator` getter returns an instance of `FruitsIterator` instance
@designervoid
designervoid / detox-ts.md
Last active May 6, 2021 11:38 — forked from solkaz/detox-ts.md
Writing Detox Tests with TypeScript

Usage

This guide assumes you've got a project using Detox with Jest, and you want to write your Detox tests in TypeScript.

  • Refer to this guide if you need to set up such a project.

1. Add TypeScript + ts-jest to package.json

We'll be using ts-jest to run Jest tests with TypeScript.

@designervoid
designervoid / array_iteration_thoughts.md
Created November 2, 2020 23:11 — forked from ljharb/array_iteration_thoughts.md
Array iteration methods summarized

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and

@designervoid
designervoid / Dockerfile
Created August 22, 2020 00:11 — forked from oze4/Dockerfile
Dockerfile / traefik.toml / docker-compose.yml
FROM node:lts-alpine AS build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM nginx:stable-alpine
COPY --from=build-stage /app/dist /usr/share/nginx/html
# this isn't necessary - you don't have to expose a port here
@designervoid
designervoid / detect-unused-css-selectors.js
Created May 30, 2020 19:55 — forked from victor-homyakov/detect-unused-css-selectors.js
Detect unused CSS selectors. Show possible CSS duplicates. Monitor realtime CSS usage.
/* eslint-disable no-var,no-console */
// detect unused CSS selectors
(function() {
var parsedRules = parseCssRules();
console.log('Parsed CSS rules:', parsedRules);
detectDuplicateSelectors(parsedRules);
var selectorsToTrack = getSelectorsToTrack(parsedRules);
window.selectorStats = { unused: [], added: [], removed: [] };
console.log('Tracking style usage (inspect window.selectorStats for details)...');
@designervoid
designervoid / detectResizedImagesRu.js
Created May 30, 2020 19:55 — forked from victor-homyakov/detectResizedImagesRu.js
Проверка на масштабирование изображений в браузере
/* eslint-disable no-var,no-console */
/**
* Проверка на масштабирование изображений в браузере.
* Срабатывает, если натуральный размер изображения намного больше отображаемого на странице,
* то есть браузер грузит большую картинку и масштабирует её до маленькой.
*/
(function() {
if (!window.Promise || !String.prototype.startsWith || window.MSInputMethodContext) {
// Не запускаем проверку в IE11 и браузерах, не поддерживающих нужные API
return;
// Measure page scroll speed
(function() {
if (document.body.scrollHeight <= window.innerHeight) {
console.log('Scrolling measurement is only possible if the window can actually be scrolled!');
return;
}
function calcScrollTime(startTime, iterations) {
return Math.round((Date.now() - startTime) / iterations) / 1000;
}
@designervoid
designervoid / localhost-ssl-certificate.md
Created May 25, 2020 17:10 — forked from ethicka/localhost-ssl-certificate.md
Localhost SSL Certificate on Mac OS Sierra and High Sierra

This gives you that beautiful green lock in Chrome. I'm assuming you're putting your SSL documents in /etc/ssl, but you can put them anywhere and replace the references in the following commands. Tested successfully on Mac OS Sierra and High Sierra.

Set up localhost.conf

sudo nano /etc/ssl/localhost/localhost.conf

Content:

[req]