Skip to content

Instantly share code, notes, and snippets.

View definiteIymaybe's full-sized avatar

definiteIymaybe

View GitHub Profile
@definiteIymaybe
definiteIymaybe / postgresql-copy-csv-import-export.md
Created August 29, 2022 23:48 — forked from zaiste/postgresql-copy-csv-import-export.md
Using PostgreSQL's COPY to import & export CSV files

Using PostgreSQL's COPY to import & export CSV files

COPY can read/write data not only from/to CSV, but also from/to binary files. For the import, the table must exist along with its columns matching CSV columns.

Export table to CSV

COPY <table> TO 'file.csv' DELIMITER ',' CSV HEADER; 
@definiteIymaybe
definiteIymaybe / basUnReplicate.bas
Created November 12, 2022 04:24
Unreplicate Access Database
Attribute VB_Name = "basUnReplicate"
Option Compare Database
Option Explicit
Public Function UnReplicate() As Boolean
' This function copies or imports all the objects and database startup
' properties from a replicated database into an un-replicated database.
' It removes tablename_Conflict tables and removes replication-related
' fields like s_GUID, etc.
@definiteIymaybe
definiteIymaybe / compare-files.js
Created December 2, 2022 03:43 — forked from loilo/compare-files.js
Compare File Lists in Node.js
import revHash from 'rev-hash'
import { readFileSync, statSync } from 'fs'
import { resolve } from 'path'
/**
* Calculate the rev hash for a file
*
* @param {string} file The path to the file to hash
* @returns {string}
*/
@definiteIymaybe
definiteIymaybe / flatten-objects.jq
Created November 16, 2023 11:59
jq flatten json recursively
# concise version:
# 'map(def flatten($prefix): . as $in | reduce keys[] as $key ({}; . + (if ($in[$key] | type) == "object" then $in[$key] | flatten(($prefix + $key + ".")) else {($prefix + $key): $in[$key]} end));flatten(""))'
# unwrapped for readabiliy:
map(
# Recursive function to flatten an object
def flatten($prefix):
. as $in
| reduce keys[] as $key (
{}; . + (
@definiteIymaybe
definiteIymaybe / termiWidget.js
Created January 7, 2024 00:29 — forked from spencerwooo/termiWidget.js
🍋 TermiWidget - Terminal-like Widget for iOS 14, made with Scriptable.
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: orange; icon-glyph: quote-right;
// Change these to your usernames!
const user = "spencer"
const jike = "4DDA0425-FB41-4188-89E4-952CA15E3C5E"
const telegram = "realSpencerWoo"
const github = "spencerwooo"
@definiteIymaybe
definiteIymaybe / ChatGPT-translation.py
Created January 25, 2024 23:26 — forked from ymoslem/ChatGPT-translation.py
Minimal working code for translation with GPT-4, "gpt-3.5-turbo" (a.k.a. ChatGPT) and "text-davinci-003"
# pip3 install openai
import openai
import time
OPENAI_API_KEY = "your_api_key_here"
openai.api_key = OPENAI_API_KEY
prompt = """French: La semaine dernière, quelquun ma fait part de sa gratitude envers notre travail.
addEventListener('scheduled', event => {
event.waitUntil(handleSchedule(event.scheduledTime))
})
async function handleSchedule(scheduledDate) {
const url = `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${WORKFLOW_ID}/dispatches`
await fetch(url, {
method: 'POST',
headers: {
'Accept': 'application/vnd.github+json',
@definiteIymaybe
definiteIymaybe / split-log-by-date.sh
Last active February 14, 2024 01:08
input.log with lines prefixed with [YYYY-MM-DD] > YYYY-MM-DD.log files, with entries for respective dates
#!/bin/bash
# input: log lines prefixed with "[YYYY-MM-DD" e.g. "[2024-02-13]", "[2024-02-13 00:00:41]" etc.
# output: YYYY-MM-DD.log files, with entries for respective dates
# Input file
input_file=$1
gawk '
# For each line
@definiteIymaybe
definiteIymaybe / cidr-range.notion.txt
Last active January 3, 2026 03:55
CIDR to IP Range (Notion Formula)
/**
# CIDR to IP Range (Notion Formula)
A correct, integer-based CIDR to IP range converter implemented as a Notion formula.
Handles all IPv4 CIDR prefixes (`/0–/32`), avoids octet-based hacks, and defines explicit behavior for invalid input.