Skip to content

Instantly share code, notes, and snippets.

View justsml's full-sized avatar
🔥
#BLM

Dan Levy justsml

🔥
#BLM
View GitHub Profile
@justsml
justsml / RectangleConfig.json
Last active May 19, 2022 21:05
Rectangle: customized config for ⭐️ Mac window layout utility.
{
"bundleId" : "com.knollsoft.Rectangle",
"defaults" : {
"allowAnyShortcut" : {
"bool" : false
},
"almostMaximizeHeight" : {
"float" : 0
},
"almostMaximizeWidth" : {
import path from "path";
import { fileURLToPath } from "url";
/**
* Usage:
* const { __dirname, __filename } = getFileAndDirname(import.meta.url);
*/
export default function getFileAndDirname(importMetaUrl) {
const __filename = fileURLToPath(importMetaUrl);
const __dirname = path.dirname(__filename);
const combiningMarks = /([\0-\u02FF\u0370-\u1AAF\u1B00-\u1DBF\u1E00-\u20CF\u2100-\uD7FF\uE000-\uFE1F\uFE30-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])([\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]+)/gmi;
/**
Remove unicode combining symbols.
Will convert the following string: Z͑ͫ̓ͪ̂ͫ̽͏̴̙̤̞͉͚̯̞̠͍A̴̵̜̰͔ͫ͗͢L̠ͨͧͩ͘G̴̻͈͍͔̹̑͗̎̅͛́Ǫ̵̹̻̝̳͂̌̌͘!͖̬̰̙̗̿̋ͥͥ̂ͣ̐́́͜͞
Into: ZALGǪ!
*/
export const removeCombiningMarks = (input) => {
return input.replace(combiningMarks, (substr, ...args) => {
@justsml
justsml / postgres cheatsheet.md
Created December 10, 2018 00:25 — forked from apolloclark/postgres cheatsheet.md
postgres cheatsheet

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL

@justsml
justsml / terminal-ui-libraries.md
Last active November 19, 2021 20:00
Beautiful Terminal Apps with Nodejs
@justsml
justsml / project-ideas.md
Last active October 14, 2021 18:01
Project ideas for learning a language, framework or library.

Project Ideas

Project ideas for learning a language, framework or library.

UI Components

  • Autocomplete
    • Use local/static JSON data.
    • Use a popular public API (Star Wars API, Pokemon API, GitHub API, etc.)
  • Notes:
postForm('http://example.com/api/v1/users', 'form#userEdit')
.then(data => console.log(data))
function postForm(url, formSelector) {
const formData = new FormData(document.querySelector(formSelector))
return fetch(url, {
method: 'POST', // 'GET', 'PUT', 'DELETE', etc.
body: formData // a FormData will automatically set the 'Content-Type'
})
@justsml
justsml / increase-maxfiles.sh
Last active September 10, 2021 20:40
Fix Open files limit on MacOS OSX 11.4
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
sudo cat << HEREDOC > /Library/LaunchDaemons/limit.maxfiles.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
-- credit: https://spinscale.de/posts/2016-11-08-creating-a-productive-osx-environment-hammerspoon.html
--[[ function factory that takes the multipliers of screen width
and height to produce the window's x pos, y pos, width, and height ]]
function baseMove(x, y, w, h)
return function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
@justsml
justsml / config-overrides.js
Created March 15, 2021 21:18
Reference for 'Rewiring' Create-React-Apps without their rude defaults.
// Follow setup instructions https://github.com/timarney/react-app-rewired
// Example config:
const path = require('path');
const { alias, configPaths } = require('react-app-rewire-alias');
const addRewireScssLoader = require('react-app-rewire-scss-loaders');
const rewireWebpackBundleAnalyzer = require('react-app-rewire-webpack-bundle-analyzer');
module.exports = function override(config, env) {
// Fucking CRApps feel entitled to overwrite tsconfig.json...
alias(configPaths('./tsconfig.paths.json'))(config);