Skip to content

Instantly share code, notes, and snippets.

View jzevin's full-sized avatar

Jeremy Zevin jzevin

View GitHub Profile
@jzevin
jzevin / github-copilot-ext.js
Last active September 9, 2022 16:06
github copilot prepend for user cert
const tls = require("tls");
const fs = require("fs");
const origCreateSecureContext = tls.createSecureContext;
tls.createSecureContext = options => {
const context = origCreateSecureContext(options);
const pem = fs
.readFileSync(process.env.NODE_EXTRA_CA_CERTS, { encoding: "ascii" })
@jzevin
jzevin / playing-card-html-symbols.json
Created February 21, 2022 07:35
playing card html entities and other codes
{
"playing card back": {
"title": "playing card back",
"html": "🂠",
"css": "\\1F0A0",
"unicode": "U+1F0A0"
},
"ace of spades": {
"title": "ace of spades",
"html": "🂡",
console.log('hi!')
@jzevin
jzevin / add commas.js
Created April 29, 2020 01:42
JavaScript one liner for adding commas to a number
`3343453545`.split('').sort(()=>-1).reduceRight((p,c,i)=>i&&i%3===0?p+=c+',':p+=c,'')
let re = /hello/i; //insensitive
// Meta chars
re = /^h/; // Starts with lower case h => false
re = /^h/i; // Starts with any case h => true
re = /--$/i; // end with -- => true
re = /^--$/i; // must begin and end with -- => false
re = /w.rld/i; // matches any ONE char => true
re = /w*d/i; // matches any char 0 or more times => true
re = /w?rld/i; // matches optional character => true
@jzevin
jzevin / 8 Useful JavaScript Tricks.md
Created June 7, 2019 21:12
8 Useful JavaScript Tricks

Introduction

Each programming language has its own tricks up in its sleeve. Many of them are known to developers, and yet some of them are pretty hackish. In this article, I will show you a couple of tricks I find useful. Some of them I've used in practice and others are the new way of solving old problems. Enjoy! https://devinduct.com/blogpost/26/8-useful-javascript-tricks

1. Ensure Array Values

Ever worked on a grid where the raw data needs to be recreated with the possibility that columns length might mismatch for each row? Well, I have! For ensuring the length equality between the mismatching rows you can use Array.fill method.

let array = Array(5).fill(''); console.log(array); // outputs (5) ["", "", "", "", ""]

2. Get Array Unique Values

node_modules
build
dist
.DS_Store
*.log
.rpt2_cache
.rts2_cache_cjs
.rts2_cache_es
.rts2_cache_umd
.vscode
@jzevin
jzevin / util.js
Last active March 15, 2022 17:54
rnd
const log = console.log.bind(console);
const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document);
const rnd = {
color: () => `#${Math.floor(Math.random()*16777215).toString(16)}`,
dec: (min=0.0,max=1.0) => Math.random() * (max - min) + min,
int: (min=0,max=1) => Math.floor(Math.random() * (max - min + 1) + min),
pick: (array) => array[Math.floor(Math.random() * array.length)]
@jzevin
jzevin / webpack.config.js
Created May 25, 2017 02:54
webpack 2 demo pf public path in extract
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
const isProd = process.env.NODE_ENV === 'production';
const options = {
entry: './src/js/app.js',