Skip to content

Instantly share code, notes, and snippets.

View designervoid's full-sized avatar
🌄

designervoid

🌄
View GitHub Profile
@designervoid
designervoid / bearer2.py
Last active April 22, 2023 14:46
Twitter API
import requests
import base64
import secrets
import hashlib
# App's credentials
CLIENT_ID = "top_id" # change this
CLIENT_SECRET = "top_secret" # change this
REDIRECT_URI = "https://ton-design-system-next-typescript.vercel.app/" # change this
@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 / functions.js
Created January 26, 2021 20:54
Get range of dates between two dates
// inspired by:
// https://flaviocopes.com/how-to-get-days-between-dates-javascript/
// and modified entry data
const getDatesBetweenDates = (startDate, endDate) => {
let dates = [];
//to avoid modifying the original date
const theDate = new Date(startDate);
while (theDate < endDate) {
dates = [...dates, new Date(theDate)];
theDate.setDate(theDate.getDate() + 1);
@designervoid
designervoid / Counter.ts
Last active October 7, 2022 10:47
Default MobX pattern in React SPA
// src/stores/Counter.ts
import { makeAutoObservable } from 'mobx';
type State {
counter: number;
};
type Mutations {
increment(): void;
@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
Last active October 7, 2022 10:47
Web app with HTTPS, based on proxy Traefik and Nuxt.js
# my_frontend/Dockerfile
### STAGE 1: Build ###
FROM node:latest as build
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
ENV PATH /usr/src/app/node_modules/.bin:$PATH
COPY package.json /usr/src/app/package.json
RUN npm install --silent
COPY . /usr/src/app
@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;