Skip to content

Instantly share code, notes, and snippets.

View bsmth's full-sized avatar

Brian Smith bsmth

View GitHub Profile
@bsmth
bsmth / TCko-reference-links.md
Created January 30, 2024 10:59
Markdown tables reference style links
@bsmth
bsmth / index.js
Created September 1, 2023 08:09
Adding list of phone numbers into pg database
const Pool = require("pg").Pool;
const pool = new Pool({
user: "bsmth",
host: "localhost",
database: "demo_db",
password: "password",
port: 5432,
});
// CREATE TABLE phone_numbers (person_name TEXT, phone_number int);
@bsmth
bsmth / cspell.json
Last active January 2, 2023 12:34
Testing .vscode/cspell.json
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"language": "en",
"languageId": "*",
"dictionaries": [
"bash",
"css",
"cpp",
"django",
@bsmth
bsmth / transform-css.html
Last active December 28, 2022 13:47
Using 'transform-style' with 2d elements
<!DOCTYPE html>
<html>
<style>
.wrapper {
transform-style: preserve-3d;
}
.wrapper2 {
transform-style: flat;
}
@bsmth
bsmth / indexeddb.js
Last active October 20, 2022 15:20
Updating IndexedDB objectstore item by key
const customerData = [
{ ssn: "444-44-4444", name: "Bill", age: 35, email: "bill@company.com" },
{ ssn: "555-55-5555", name: "Donna", age: 32, email: "donna@home.org" },
];
const dbName = "my_database";
const request = indexedDB.open(dbName, 2);
request.onerror = (event) => {
console.log(event);
@bsmth
bsmth / install_node_19.sh
Created October 20, 2022 07:51
Installing node 19 with global modules from 18
# Using 19
node -v
v19.0.0
yarn && yarn start
zsh: command not found: yarn
# of course, everything is broken
# try reinstall 19 with all of the global modules from 18
nvm install 19 --reinstall-packages-from=18
@bsmth
bsmth / .zshrc
Created August 16, 2022 08:30 — forked from zanshin/.zshrc
My .zshrc file (from Mark Nichols -> @zanshin)
# Path to your oh-my-zsh configuration.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
#export ZSH_THEME="robbyrussell"
export ZSH_THEME="zanshin"
@bsmth
bsmth / qdb.sh
Created August 19, 2021 08:19
Starting QDB from bin
mkdir bin_dir && cd bin_dir
wget https://github.com/questdb/questdb/releases/download/6.0.4/questdb-6.0.4-no-jre-bin.tar.gz
tar -xvf questdb-6.0.4-no-jre-bin.tar.gz
cd questdb-6.0.4-no-jre-bin
./questdb.sh start -d /path/to/my_data_dir
./questdb.sh stop
# /path/to/my_data_dir will create a new root directory for QuestDB
# If a server config file exists already, it will be loaded, i.e.
@bsmth
bsmth / import.py
Created June 29, 2021 12:48
Import CSV to QuestDB from Python
import urllib.request
import pandas as pd
import requests
def import_data(file_name, table_name):
params = {}
params['timestamp'] = 'TradeDate'
params['partitionBy'] = 'MONTH'
url_values = urllib.parse.urlencode(params)
query_url = "http://%s:9000/imp?" % (server_ip) + url_values
import time
import socket
HOST = 'localhost'
PORT = 9009
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
sock.connect((HOST, PORT))
sock.sendall(('eod,instrument=fut open=141.5,high=142.0,low=139.9,close=142.0,settle_price=143.7,value=42.27\n').encode())