Skip to content

Instantly share code, notes, and snippets.

View devinrhode2's full-sized avatar
😀

Devin Rhode devinrhode2

😀
View GitHub Profile
import { execaCommandSync } from 'execa'
/** @type {(cmdString: string, debug?: 'debug') => [string | undefined, string | unknown]} */
export const exec = (cmdString, debug) => {
let exception
let result
try {
result = execaCommandSync(cmdString, {
env: {
// @ts-expect-error - not application code
@devinrhode2
devinrhode2 / safeCall.ts
Last active December 30, 2022 20:23
safely call function, and return `returnValue | Error` https://www.swyx.io/errors-not-exceptions
/**
* Calls `callback`, catches any errors and returns `returnValue | Error`
*
* TODO: create npm package
*
* See: https://dev.to/devinrhode2/comment/1fcga
*/
export const safeCall = <
TCallback extends (
...args: unknown[]
@adbutterfield
adbutterfield / prettier.config.js
Last active July 6, 2024 04:05
Default prettier config with comments and links to prettier rules
module.exports = {
/**
* Print Width
* https://prettier.io/docs/en/options.html#print-width
*
* Specify the line length that the printer will wrap on.
*
* printWidth: <int>
* default: 80
*/
// It's composable
const compose = (a,b) => v => a(b(v))
const isValid = valid => fn => (...p) => valid(...p) && fn(...p)
const hasTwoParams = isValid((...params) => params.length === 2)
const firstParamIsArray = isValid(a => Array.isArray(a))
const hasTwoFirstArray = compose(hasTwoParams, firstParamIsArray)
const myValidatedFn = hasTwoFirstArray((a, b) => console.log('It worked', a, b))
@1951FDG
1951FDG / asuswrt-merlin.md
Last active October 10, 2024 10:35
Instructions for installing and configuring Squid caching proxy server on Asuswrt-Merlin

Setup Entware on Asuswrt-merlin

Entware is a modern alternative to Optware.

For those unfamiliar with Optware: it's a software repository that offers various software programs that can be installed on your router. They allow you to add new functionality to your router (provided you have the know-how to properly configure them).

Entware system library is specially modified (patched) so that standard linux files that are normally located in /etc directory are now located in /opt/etc/ directory. To simplify things let's consider /etc/passwd file. On Asuswrt-merlin it normally looks something like:

admin:x:0:0:admin:/root:/bin/sh

nas:x:100:100:nas:/dev/null:/dev/null

@ernsheong
ernsheong / access-mac-localhost-from-parallels-desktop-ie-edge.md
Last active November 7, 2024 12:31
Accessing macOS localhost from Parallels Desktop IE or Edge

Access macOS localhost from IE or Edge within Parallels Desktop

This issue is so infuriating that I'm going to take some time to write about it.

  1. MOST IMPORTANT. Your local development server must be bound to IP address 0.0.0.0. Some do this by default, but many don't. You need to make sure that you run your local server with correct IP bindings. You may need to provide additional flags to your serve commands e.g. polymer serve --hostname domain.local, hugo serve --bind 0.0.0.0. If you use a named domain like domain.local, it has to be defined in /etc/hosts and pointing at 0.0.0.0.

  2. My Parallels setting is using Shared Network, nothing special there.

  3. Open macOS Terminal and type ifconfig. Look for the value under vnic0 > inet. It is typically 10.211.55.2.

An example of a simple form

Consider the following markup:

<form class="root" state:theme=dark state:compact>
  <div class="input-area">
    <label for="username" class="label">Username:</label>
    <input id="username" class="input" type="text">
  </div>
@swannodette
swannodette / inference.md
Last active August 7, 2023 16:13
Externs Inference

Externs Inference

Integrating third party JavaScript libraries not written with Google Closure Compiler in mind continues to both be a source of error for users when going to production, and significant vigilance and effort for the the broader community (CLJSJS libraries must provide up-to-date and accurate externs).

In truth writing externs is far simpler than most users imagine. You only need externs for the parts of the library you actually intend to use from ClojureScript. However this isn't so easy to determine from Closure's own documentation. Still in the process of writing your code it's easy to miss a case. In production you will see the much dreaded error that some mangled name does not exist. Fortunately it's possible to enable some compiler flags :pretty-print true :pseudo-names true to generate an advanced build with human readable names. However debugging missing externs means compiling your production build for each missed case. So much time wasted for such simple mistakes damages our sen

@aaugustin
aaugustin / question.md
Last active July 24, 2024 03:05
Accessibility in browsers: zoom level vs. font size

Scroll to the bottom for the answer

Question

There's two ways to increase the default font size in browsers:

  1. set a default zoom level > 100% ("page zooming")
  2. set a default font size > 16px ("text scaling")

Option 1 relies on the browser's proportional scaling. This feature was

@rwjblue
rwjblue / application.controller.js
Created December 14, 2015 18:07 — forked from barneycarroll/application.controller.js
Can't access object values by dynamic key in Handlebars
import Ember from 'ember';
export default Ember.Controller.extend({
numbers:['1','2','3','4'],
letters:['a','b','c','d']
});