Skip to content

Instantly share code, notes, and snippets.

/*
* Converts table from [[Header0, Header1, Header2], [Column0Val0, Column1Val0, Column2Val0], ...]
* to {Header0: [ColumnVal0, ...], Header1: [Column1Val0, ...], Header2: [Column2Val0, ...]}
*/
function convertTableToData(table) {
transposed = table[0].map((_, colIndex) => table.map(row => row[colIndex]));
result = {}
for(var i = 0; i < transposed.length; i++) {
header = transposed[i][0]
result[header] = transposed[i].slice(1, 4).map(String);
@flaviut
flaviut / Setting up Emporia Vue 2 with ESPHome.md
Last active August 22, 2024 18:14
Setting up Emporia Vue 2 with ESPHome
@nmwsharp
nmwsharp / printarr
Last active August 15, 2024 01:43
Pretty print tables summarizing properties of tensor arrays in numpy, pytorch, jax, etc. --- now on pip: `pip install arrgh`
Pretty print tables summarizing properties of tensor arrays in numpy, pytorch, jax, etc.
Now on pip! `pip install arrgh` https://github.com/nmwsharp/arrgh
@hrishioa
hrishioa / load_and_process_open_source_licenses.ts
Created May 6, 2023 06:23
Simple Typescript file demonstrating chunked, chained LLM calls to process large amounts of text.
// Requires the gpt library from https://github.com/hrishioa/socrate and the progress bar library.
// Created by Hrishi Olickel ([email protected]) (@hrishioa). Reach out if you have trouble running this.
import { ThunkQueue } from '../../utils/simplethrottler';
import {
AcceptedModels,
Messages,
askChatGPT,
getMessagesTokenCount,
getProperJSONFromGPT,
@carlineng
carlineng / nested_subtotals_gpt4.sql
Created May 14, 2023 00:54
GPT-4's answer to the nested subtotals SQL question
-- Prompt:
--
-- I want help writing a SQL query. I have a database with the two tables:
--
-- CREATE TABLE order_items (
-- created_at timestamp,
-- sale_price decimal,
-- inventory_item_id integer
-- );
--
@markshust
markshust / README.md
Last active March 17, 2025 23:57
GitHub Action to deploy Laravel app

Set up GitHub Actions to handle deployments for your Laravel application. This has similar functionality to Laravel Forge without the recurring cost. GitHub Actions can be used to automate your deployment process on every push to your repository.

Prerequisites

  1. Server Access: Ensure you have SSH access to your server where the Laravel app will be deployed.
  2. Secrets: Store sensitive information such as your server's IP address, SSH username, and private SSH key in GitHub Secrets. Go to your GitHub repository, navigate to "Settings" > "Secrets and variables" > "Actions", and add the following secrets:
    • DEPLOY_SERVER_IP: Your server's IP address.
    • DEPLOY_SERVER_USER: Your SSH username.
    • DEPLOY_SERVER_KEY: Your private SSH key. Make sure this key is authorized to access your server (~/.ssh/authorized_keys).
  • DEPLOY_SERVER_DIR: The directory where you'd like to deploy your app, relative to /var/www/. Ex: example.com