Skip to content

Instantly share code, notes, and snippets.

View nberlette's full-sized avatar
😍
Stage 3 decorators, meet Deno 🦖

Nicholas Berlette nberlette

😍
Stage 3 decorators, meet Deno 🦖
View GitHub Profile
@nberlette
nberlette / HOWTODMG.md
Created January 19, 2021 21:10
How to create a "DMG Installer" for Mac OS X

Creating a "DMG installer" for OS X

A DMG Installer is convenient way to provide end-users a simple way to install an application bundle. They are basically a folder with a shortcut to the Applications directory but they can be customized with icons, backgrounds, and layout properties. A DMG file (.dmg) is a Mac OS X Disk Image file and it is used to package files or folders providing compression, encryption, and read-only to the package.

Creating the DMG file

Disk Utility

@nberlette
nberlette / xterm-256color.svg
Last active March 30, 2021 22:38 — forked from jasonm23/xterm-256color.svg
xterm-256color codes chart, in sections.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nberlette
nberlette / bmw-e90.dbc
Last active May 18, 2024 16:30
BMW E90 CAN bus definitions
VERSION "BMW_E90_0.0.8"
NS_ :
NS_DESC_
CM_
BA_DEF_
BA_
VAL_
CAT_DEF_
CAT_
## Purge macOS Time Machine's Local Snapshots
## By Nicholas Berlette <github.com/nberlette>
## Usage:
## purge_local_snapshots [-q|--quiet]
function purge_local_snapshots() {
quiet=$(echo ${1,,} | grep "\-q")
snapshots=$(tmutil listlocalsnapshotdates | grep "-")
#!/bin/bash
# hex2bash.sh
# rudamentary bash function to format hex colors into RGB form
# and output them as xterm-256color esc-code, with samples :D
# 2021 Nick Berlette
# https://github.com/nberlette
function hex2bash {
@nberlette
nberlette / dbc-patterns.js
Created May 3, 2021 04:25
DBC Regular Expressions
/* dbc-patterns.js */
const VER_REGEX = /^VERSION "(.*)"/
const ECU_REGEX = /^BU_:(.*)/
const MSG_REGEX = /^BO_ (\w+) (\w+) *: (\w+) (\w+)/
const SIG_REGEX = /^SG_ (\w+) : (\d+)\|(\d+)@(\d+)([+|-]) \(([0-9.+-eE]+),([0-9.+-eE]+)\) \[([0-9.+-eE]+)\|([0-9.+-eE]+)\] "(.*)" (.*)/
const SGM_REGEX = /^SG_ (\w+) (\w+) *: (\d+)\|(\d+)@(\d+)([+|-]) \(([0-9.+-eE]+),([0-9.+-eE]+)\) \[([0-9.+-eE]+)\|([0-9.+-eE]+)\] "(.*)" (.*)/
const VAL_REGEX = /^VAL_ (\w+) (\w+) (.*);?/
const VAL_TABLE_REGEX = /^VAL_TABLE_ (\w+) (.*);?/
@nberlette
nberlette / nginx_with_cache.conf
Created May 10, 2021 07:22 — forked from galakhov/nginx_with_cache.conf
Nginx cache example config
# Based on articles:
# https://ruhighload.com/%D0%9A%D1%8D%D1%88%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5+%D1%81+nginx
# https://wiki.enchtex.info/practice/nginx/cache
# https://gist.github.com/yanmhlv/5612256
# https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html
# https://blog.runcloud.io/2017/10/28/nginx-caching-tutorial-wordpress.html
# https://www.digitalocean.com/community/tutorials/how-to-setup-fastcgi-caching-with-nginx-on-your-vps
# https://easyengine.io/wordpress-nginx/tutorials/single-site/fastcgi-cache-with-purging/
@nberlette
nberlette / DBC_Specification.md
Last active May 26, 2021 07:22
DBC Specification for automotive/industrial CAN networks. Lifted from CANpy repo.

DBC Specification

Format description

<...> Required field
<A|B> A or B required
[...] Optional field
[A|B] A or B optional
@nberlette
nberlette / str.scss
Last active January 10, 2024 22:42
SASS string functions for kebabCase, camelCase, titleCase, etc.
/* * * * * * * * * * * * * * * * * * * * * * * * *
SASS string functions:
camelCase, kebabCase, titleCase, toLower, etc.
-------------------------------------------------
2021 Nicholas Berlette - https://git.io/Js3HD
* * * * * * * * * * * * * * * * * * * * * * * * */
@use "sass:string";
/*
upperCase($string)
@nberlette
nberlette / hash.js
Created May 14, 2021 20:45
Quick encryption module for node. Shoutout @feross
/*!
MIT License.
Algorithms compiled by Nicholas Berlette <https://berlette.com>,
originally by Feross Aboukhadijeh <https://feross.org/opensource>
*/
const crypto = require('crypto')
const allowedMethods = ['sha1', 'sha256', 'md5']
async function hash (method = 'sha256', buf, cb = null) {
if (typeof method === 'string' && allowedMethods.includes(method)) {