Skip to content

Instantly share code, notes, and snippets.

View kfelter's full-sized avatar
🎧
Flow

Kyle Felter kfelter

🎧
Flow
View GitHub Profile
#!/bin/bash
FNAME="$(date +"%Y_%m_%d_%H_%M_%S").dump"
/opt/homebrew/bin/mysqldump --port=3306 --host=127.0.0.1 \
-u $your_username -p$your_password $your_database_name > $FNAME
gzip $FNAME
# Then, you can add a cron job to run this script every day at 3am:
# 0 3 * * * /path/to/backup-db.sh
@kfelter
kfelter / sliceToMap.go
Created August 18, 2023 16:54
Golang Convert a slice of structs to a map of structs: Mastering Go Application Design
package main
import "fmt"
// sliceToMap creates a new map of type map[string]T and uses func 'f' to set the key of the new map
// from the slice
func sliceToMap[T any](items []T, f func(item T) string) map[string]T {
itemMap := make(map[string]T, len(items))
for _, item := range items {
itemMap[f(item)] = item
@kfelter
kfelter / main.go
Created September 5, 2021 05:03 — forked from cryptix/main.go
using go/ast to find specific function calls and the values of a parameter
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"log"
)
@kfelter
kfelter / minishift.log
Created July 24, 2019 16:30
minishift startup log audio cuts out because it grabs the microphone
minishift start --vm-driver=virtualbox --show-libmachine-logs -v5
-- minishift version: v1.33.0+ba29431
-- Starting profile 'minishift'
Found binary path at /usr/local/bin/minishift
Launching plugin server for driver virtualbox
Plugin server listening at address 127.0.0.1:52396
() Calling .GetVersion
Using API Version 1
() Calling .SetConfigRaw
() Calling .GetMachineName
@kfelter
kfelter / github.sh
Created July 11, 2019 13:39
using go modules with private repos
git config \
--global \
url."https://${user}:${personal_access_token}@github.com".insteadOf \
"https://github.com"
@kfelter
kfelter / sqlite3 for Destiny 2 API
Created November 9, 2018 15:56
This is a method for getting objects from hashes specifically using sqlite3 for the Destiny 2 API
import sqlite3
con = sqlite3.connect('Manifest.content')
cur = con.cursor()
def getItemName(itemHash):
#create id from hash
if (itemHash & (1 << (32 - 1))) != 0:
itemHash = itemHash - (1 << 32)
cur.execute("SELECT json FROM DestinyInventoryItemDefinition WHERE id=?", (itemHash,))
#print(cur.fetchall())