Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Boing boom tschak!

vlrmprjct vlrmprjct

:octocat:
Boing boom tschak!
View GitHub Profile
View scrollzoom.js
const pos = { x: 0, y: 0 };
const zoom_target = { x: 0, y: 0 };
const zoom_point = { x: 0, y: 0 };
const factor = 0.1;
const max_scale = 3;
let scale = 1;
const scrolled = (e) => {
const size = {
@vlrmprjct
vlrmprjct / force-scrollbars-visible.css
Created Mar 1, 2021 — forked from IceCreamYou/force-scrollbars-visible.css
Mac OS X hides scrollbars by default. This is annoying for UI design because it means users might not realize that certain areas are scrollable. This public domain Gist forces the scrollbar to always be visible with native behavior in Webkit-based browsers (Chrome and Opera) on Macs.
View force-scrollbars-visible.css
.force-show-scrollbars ::-webkit-scrollbar-track:vertical {
border-left: 1px solid #E7E7E7;
box-shadow: 1px 0 1px 0 #F6F6F6 inset, -1px 0 1px 0 #F6F6F6 inset;
}
.force-show-scrollbars ::-webkit-scrollbar-track:horizontal {
border-top: 1px solid #E7E7E7;
box-shadow: 0 1px 1px 0 #F6F6F6 inset, 0 -1px 1px 0 #F6F6F6 inset;
}
@vlrmprjct
vlrmprjct / getLocaleDateString.js
Last active Dec 28, 2020
Locale Date Formats #javascript #i18n #date #locale
View getLocaleDateString.js
const getLocaleDateString = (locale) => {
const formats = {
'af-ZA': 'yyyy/MM/dd',
'am-ET': 'd/M/yyyy',
'ar-AE': 'dd/MM/yyyy',
'ar-BH': 'dd/MM/yyyy',
'ar-DZ': 'dd-MM-yyyy',
'ar-EG': 'dd/MM/yyyy',
'ar-IQ': 'dd/MM/yyyy',
'ar-JO': 'dd/MM/yyyy',
@vlrmprjct
vlrmprjct / counter.ino
Created Jul 31, 2020
Arduino Simple Counter
View counter.ino
/* Simple Counter
* ——————
*
* This is a simple counter that takes a digital input
*
*/
int ledPin = 13; // choose the pin for the LED
int switchPin =2; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
int counter = 0;
@vlrmprjct
vlrmprjct / react.js
Created Jun 12, 2020
ReactJS multiple optional params
View react.js
<Route path="/section/(page)?/:page?/(sort)?/:sort?" component={Section} />
@vlrmprjct
vlrmprjct / dt37sdm-attiny84.ino
Last active Jul 26, 2020
Damn tiny 3x7 segment display module
View dt37sdm-attiny84.ino
// ATMEL ATTINY84
// +-\/-+
// VCC 1| |14 GND
// (D10) PB0 2|x |13 AREF (D 0)
// (D 9) PB1 3|x |12 PA1 (D 1)
// PB3 4| |11 PA2 (D 2)
// PWM INT0 (D 8) PB2 5|x |10 PA3 (D 3)
// PWM (D 7) PA7 6| |9 PA4 (D 4)
// PWM (D 6) PA6 7| |8 PA5 (D 5) PWM
//
@vlrmprjct
vlrmprjct / webpack.config.dev.js
Created May 3, 2020 — forked from oreofeolurin/webpack.config.dev.js
Webpack file for configuring SCSS with React (create-react-app)
View webpack.config.dev.js
'use strict';
const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
@vlrmprjct
vlrmprjct / delete_multiple_branches.sh
Last active Apr 16, 2020
delete multiple branches #git
View delete_multiple_branches.sh
git branch -d `git branch --list '3.2.*'`
@vlrmprjct
vlrmprjct / array_iteration_thoughts.md
Created Jan 25, 2020 — forked from ljharb/array_iteration_thoughts.md
Array iteration methods summarized
View array_iteration_thoughts.md

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

@vlrmprjct
vlrmprjct / gitkraken-wsl-bash.bat
Created Jan 16, 2020 — forked from carlolars/gitkraken-wsl-bash.bat
Use bash from WSL as sh.exe for GitKraken (5.0.4) for Windows
View gitkraken-wsl-bash.bat
@echo off
REM Make sure that the path to the script is correct!
@bash -l -c "~/bin/gitkraken-wsl-bash.sh %*"