Skip to content

Instantly share code, notes, and snippets.

View smockle's full-sized avatar

Clay Miller smockle

View GitHub Profile
@smockle
smockle / llama.sh
Created July 20, 2023 20:14
Instructions and a script for running Llama 2 (13b-chat) on an Apple Silicon Mac
#!/usr/bin/env zsh
#
# --- SETUP ---
#
# 1. Clone https://github.com/ggerganov/llama.cpp.
# 2. In the `models` directory, clone https://github.com/facebookresearch/llama.

Emoji Test

👋 Hello, world!

👋 Hi, world!

👋 Hey, world!

👋 Yo, world!

@smockle
smockle / stddev.mjs
Created February 15, 2022 18:24
Average and standard deviation functions
// To use in the Node.js REPL:
// const { getAverage, getStandardDeviation } = await import("./stddev.mjs");
// @ts-check
export function getAverage(...values) {
return values.reduce((sum, value) => sum + value, 0) / values.length;
}
export function getStandardDeviation(...values) {
const average = getAverage(...values);
const squaredDifferences = values.map((value) =>
@smockle
smockle / exclude.js
Created September 17, 2019 02:02
Output a regular expression which matches branch names _except_ the given name
#!/usr/bin/env node
//@ts-check
const branchName = process.argv[2];
if (!branchName) {
throw new TypeError(`Expected a branch name but did not receive one.`)
}
const validCharactersRegExp = /[a-zA-Z0-9\-\_]/;
const validCharacters = [
[ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" ],
@smockle
smockle / index.js
Last active June 20, 2019 21:29
Bluebird.prototype.map with native Promises
#!/usr/bin/env node
//@ts-check
const MAX_CONCURRENCY = 3;
function sayHiAsync() {
console.log("marco");
return new Promise((resolve) => {
console.log("polo");
setTimeout(() => {
#!/usr/bin/env node
// @ts-check
const geoip = require('geoip-lite');
function memoryUsageInMegabytes() {
const memoryUsageInBytes = process.memoryUsage();
const memoryUsageInMegabytes = {};
for (const key in memoryUsageInBytes) {
memoryUsageInMegabytes[key] = `${(memoryUsageInBytes[key] / 1000000).toFixed(2)}MB`;
}
@smockle
smockle / arp.js
Created February 5, 2019 06:40
Merge the results of `arp -a` with known device information for improved output
#!/usr/bin/env node
// @ts-check
const fs = require("fs");
const { spawn } = require("child_process");
const ipAddressRegExp = /\((?<ipAddress>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\)/;
const macAddressRegExp = /(?<macAddress>[a-fA-F\d]{1,2}:[a-fA-F\d]{1,2}:[a-fA-F\d]{1,2}:[a-fA-F\d]{1,2}:[a-fA-F\d]{1,2}:[a-fA-F\d]{1,2})/;
function normalizeMACAddress(macAddress) {
return macAddress
# Set timezone
sudo timedatectl set-timezone "America/Los_Angeles"

# DNS servers
sudo vi /etc/dhcpcd.conf
# static domain_name_servers=1.1.1.1 1.0.0.1

# Install kelvin
$ mkdir -p ~/Downloads && cd $_

Homebridge

On the host

# Download latest Raspbian Stretch Lite from https://www.raspberrypi.org/downloads/raspbian/

# Insert a Micro SD card (at least 8 GB) into the host

# Install Etcher, a utility that flashes SD cards
@smockle
smockle / fizzbuzz.js
Created September 15, 2015 05:15
FizzBuzz, in JavaScript
let array = [];
for (let i = 1; i <= 100; i++) {
let x = '';
if (i % 3 === 0) { x += 'Fizz'; }
if (i % 5 === 0) { x += 'Buzz'; }
if (x.length === 0) { x = i; }
array.push(x)
}
console.log(array.join('\n'));