Links
Add
Broken
Capturing LLDP Packets Using tcpdump | Baeldung on Linux
https://www.baeldung.com/linux/tcpdump-lldp-packets-cli
Added 11 months ago
Agile Testing: Configuring OpenLDAP as a replacement for NIS
http://agiletesting.blogspot.ca/2005/10/configuring-openldap-as-replacement.html
Added 10 years ago
Renewable Technology Resources
http://renewabletechnologyresources.com/
Apple Dell Lenovo HP Hewlett Packard Asus Chromebook ipad iphone laptop tablet convertible desktop ios osx android windows office repair virus removal data recovery screen repair hard drive replacement ram memory upgrade installation wholesale recycling IT equipment RAM HDD Hard Drives adapters motherboards logic board
Added 10 years ago
Albums That Never Were: The Grateful Dead - Lazy River Road
https://albumsthatneverwere.blogspot.com/2019/10/the-grateful-dead-lazy-river-road.html
Cement Framework
http://builtoncement.com/
The most advanced, and feature-full CLI framework for Python development.
Added 10 years ago
Streaming Audio Databases - Music Library - InfoGuides at George Mason University
https://infoguides.gmu.edu/music/streamingaudio
InfoGuides: Music Library: Streaming Audio Databases
20 Useful Terminal Emulators for Linux
https://www.tecmint.com/linux-terminal-emulators/
In this article, you will learn the list of best terminal emulators available for Linux, along with screenshots and installation instructions.
Added 8 years ago
NANPA : Reports - Central Office Code Reports
https://www.nationalnanpa.com/reports/reports_cocodes_assign.html
Added 8 years ago
The Grateful Dead World
https://gratefuldeadworld.blogspot.com/
Using a Yubikey as a touchless, magic unlock key for Linux | Kevin Liu
https://kliu.io/post/yubico-magic-unlock/
Yubikeys are great for security, but their benefits decrease somewhat when you leave them in your computer unattended. I also have login passwords that are way too long. How to solve these problems? Use a Yubikey to unlock your computer!
Added 7 months ago
1821 tornado was one of the strongest storms ever in NH
https://www.wmur.com/article/new-hampshire-tornado-1821/62115359?mc_cid=caa5f703ff
Automated Malware Analysis - Cuckoo Sandbox
https://cuckoosandbox.org/index.html
Automated Malware Analysis – Cuckoo Sandbox Home About Download […]
Added 10 years ago
Fakin' the Funk - Google Search
https://www.google.com/search?client=firefox-b-1-e&q=Fakin%27+the+Funk
Verizon Wireless - Landing Overview Page
https://b2b.verizonwireless.com/sms/#/overview
Added 6 years ago
Asterisk FreePBX Feature Code Reference - Byte Solutions - Computer Support, Network Support, South Florida
https://www.bytesolutions.com/asterisk-freepbx-feature-code-reference/
These are the default star (*) codes for a FreePBX system. They are also generally a standard used by many phone systems. They can be changed in the FreePBX
Added 5 years ago
SysVinit to Systemd Cheatsheet - FedoraProject
https://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet
Added 10 years ago
Defined Networking
https://www.defined.net/
Nebula Overlay Networks: Extend network access with on-demand, encrypted tunnels between any hosts on any network. Defined Networking is the company behind the Nebula open-source project.
Added 7 months ago
Fire and Forget Wardriving • Hackaday.io
https://hackaday.io/project/2535-fire-and-forget-wardriving
My project consists of a wardriving platform based around the Raspberry Pi that requires no maintenance after an initial setup.
Added 10 years ago
Python: check script is not already running
https://jeromejaglale.com/doc/python/check_script_not_already_running
Added 6 years ago
Kerberos.io - free and cheap motion detection video surveillance security system
https://kerberos.io/
A video surveillance security system. Protect your property or building with bleeding edge motion detection video security surveillance software. Use any type of cameras, including IP cameras and USB cameras (webcams).
Added 8 years ago
Importing your existing AWS Route53 records into Terraform
https://filip-prochazka.com/blog/importing-your-existing-aws-route53-records-into-terraform
When you start with a cloud, you rarely get everything just right on the first try. Most projects begin with IaCafter they’ve already been using AWS for some time - which means you’ll have a bunch of resources that have been created using the AWS Console,and they have to be imported into Terrafor...
Added 2 years ago
Using Postfix Transport Maps for Email Address Specific Aliasing
http://www.docunext.com/blog/2011/01/using-postfix-transport-maps-for-email-address-specific-aliasing.html
Added 10 years ago
Blogger: User Profile: KubilayKhan
https://www.blogger.com/profile/02656228724432286691
Blogger ist ein Veröffentlichungs-Tool von Google, mit dem du ganz einfach deine Gedanken der Welt mitteilen kannst. Mit Blogger kannst du problemlos Texte, Fotos und Videos in deinem persönlichen Blog oder deinem Team-Blog veröffentlichen.
Secrets of Stockfish: The Ultimate Open Source Chess AI | by Robert Keith Rippetoe | Medium
https://rkrippetoe.medium.com/secrets-of-stockfish-the-ultimate-open-source-chess-ai-c466980d3ab6
Build a Timber Frame Style Backyard Pavilion Part 2 | MAN about TOOLS
https://manabouttools.com/build-a-timber-frame-style-wood-backyard-pavilion-part-2/
Build your own Timber Frame style Gazebo. Plans available for this Western Red cedar and Douglas Fir Gazebo. Timber Framing knowledge is not required.
Added 6 years ago
Operation Atlas » Dylan and Amy's Tiny House Build
http://operationatlas.blog/
Added 9 years ago
Common Greywater Mistakes and Preferred Practices
http://oasisdesign.net/greywater/misinfo/
A counter to the tidal wave of misinformation on the web, and pointer to accurate, up-to-date guideance on greywater best practices how-to
Added 7 years ago
Broken
voices.nmfs.noaa.gov torrent
https://btdig.com/4a00cd31a4a3f96bee2bfdfb43f97da50b759615/billy-joel-shea
Added 8 months ago
Karakeep
https://karakeep.app/
The Bookmark Everything app. Hoard links, notes, and images and they will get automatically tagged AI.
Added 7 months ago
Telecom Technical Bulletins to Fix Problems from sandman.com
http://www.sandman.com/bulletin.html
Telecom and IT Knowledgebase Articles from the Telecom Experts at sandman.com. Learn how to fix the unfixable.
Added 8 years ago
A Barebones pf IPv6 Firewall Ruleset
https://content.pivotal.io/blog/a-barebones-pf-ipv6-firewall-ruleset
“My ISP is deploying IPv6, and I want to use it, but I don’t know what my firewall rulesets should look like.” In this blog post, we discuss a basic set of IPv6 rules which will allow the firewall...
Added 7 years ago
I'm Tim Ferriss, and This Is How I Work
http://lifehacker.com/5961603/im-tim-ferriss-and-this-is-how-i-work
When we kicked off the How I Work series in August, we encouraged readers to tell us whose productivity tips and tricks they were dying to know. No
Added 10 years ago
USB-WiFi/home/The_Short_List.md at main · morrownr/USB-WiFi · GitHub
https://github.com/morrownr/USB-WiFi/blob/main/home/The_Short_List.md
USB WiFi Adapter Information for Linux. Contribute to morrownr/USB-WiFi development by creating an account on GitHub.
Tank Glass | USA – Tank Glass | Los Angeles
https://tankglass.com/
Simply superior glass. Tank beakers are hand blown in Los Angeles, CA and made to last.
Added 4 years ago
Suffield Academy Network Documentation - Google Search
https://www.google.com/search?q=Suffield+Academy+Network+Documentation&oq=Suffield+Academy+Network+Documentation&aqs=chrome..69i57.260j0j7&sourceid=chrome&ie=UTF-8
Added 8 years ago
Ask HN: Best current model routers for OpenWRT, DD-WRT, Tomato, etc.? | Hacker News
https://news.ycombinator.com/item?id=6828699
Added 10 years ago
LLDPd - Know your network neighbors
https://tobru.ch/lldpd-know-your-network-neighbors/
An introduction into LLDP
What is LLDP?
LLDP is a network layer 2 protocol, called "Link Layer Discovery Protocol". It
transmits many information about the device and ports to all
network neighbors. It is vendor independent and specified in IEEE 802.1AB
[http://standards.ieee.org/getieee802/download/802.1AB-2009.
Added 11 months ago
Converting Debian 10/11/12 to Netplan.io | Pedro Rodrigues
https://pedroagrodrigues.com/posts/Debian_To_Netplan/
Netplan Migration
Added 5 months ago
Arduino Controlled Wifi Antenna
http://forum.arduino.cc/index.php?topic=63761.0
Greetings,
I would like to devellop an arduino program that rotates a wave-guide antenna 360 degree's using a pan servo, and then points to the strongest signal, and then tracks it. I am fine on the hardware side, but I…
Added 10 years ago
OpenBSD 7.5 router with VLANs
https://jf.si/posts/2024-07-14-openbsd-7-5-router-with-vlans/
Added 1 year ago
RusticiSoftware/TinCanPHP · GitHub
https://github.com/RusticiSoftware/TinCanPHP
PHP library for the Experience API (Tin Can API). Contribute to RusticiSoftware/TinCanPHP development by creating an account on GitHub.
Added 10 years ago
Kea Configuration for Small Office or Home Use
https://kb.isc.org/docs/kea-configuration-for-small-office-or-home-use
Added 6 months ago
Welcome to nornir’s documentation! — nornir 3.5.0 documentation
https://nornir.readthedocs.io/en/latest/
Added 11 months ago
debian - ISC DHCP client (dhclient) alternative? - Server Fault
https://serverfault.com/questions/1108989/isc-dhcp-client-dhclient-alternative
Added 11 months ago
Recommended RSS feeds : r/hacking
https://www.reddit.com/r/hacking/comments/k47bnj/recommended_rss_feeds/
Mounting An Encrypted USB Drive From the Command Line | The Cloistered Monkey
https://necromuralist.github.io/posts/mounting-an-encrypted-usb-drive/
Added 8 months ago
create self signed certificates · GitHub
https://gist.github.com/xenogenesi/1b2137f769aa80b6c99d573071f5d086
create self signed certificates. GitHub Gist: instantly share code, notes, and snippets.
Added 6 years ago
Cedar Knoll Log Homes - The place for all your log home needs
http://cedarknollloghomes.com/index.html
Added 8 years ago
unix - Console commands to change virtual ttys in Linux and OpenBSD - Super User
http://superuser.com/questions/33065/console-commands-to-change-virtual-ttys-in-linux-and-openbsd
Added 11 years ago
Calomel.org :: Open Source Research and Reference
http://dant.net.ru/calomel/index.html
Rolling out an API for your cakePHP app Part 1: The Problems | Deadly Technology
http://deadlytechnology.com/php/api-cakephp-app/
Rolling out an API for your cakePHP app Part 1: The Problems
Added 10 years ago
Including Single- & Archive- templates for Custom Post Type in WordPress Plugins | Pat Eason - JavaScript and WordPress Developer
http://pateason.com/including-single-archive-templates-custom-post-type-wordpress-plugins/
Added 10 years ago
Forrst | XMPP MUC bot with Node.js - Some code from VrtakCZ
http://zurb.com/forrst/posts/XMPP_MUC_bot_with_Node_js-IIQ
Added 9 years ago
GitHub - astral-sh/uv: An extremely fast Python package and project manager, written in Rust.
https://github.com/astral-sh/uv
An extremely fast Python package and project manager, written in Rust. - astral-sh/uv
Added 7 months ago
netbox-plugin-dns/examples/ansible/using_netbox_dns_with_ansible.md at main · peteeckel/netbox-plugin-dns
https://github.com/peteeckel/netbox-plugin-dns/blob/main/examples/ansible/using_netbox_dns_with_ansible.md
NetBox DNS is a NetBox plugin for managing DNS data. - netbox-plugin-dns/examples/ansible/using_netbox_dns_with_ansible.md at main · peteeckel/netbox-plugin-dns
Added 5 months ago
VoIP: SIP-over-TLS and sRTP: Grandstream
https://www.traud.de/voip/grandstream.htm
Added 4 years ago
Send your systemd journal logs to Graylog | Steve Horsfield
https://stevehorsfield.wordpress.com/2019/10/08/send-your-systemd-journal-logs-to-graylog/
How do you get your system logs to Graylog? The Graylog sidecar is compatible with Elastic Beats, but FileBeat does not support the systemd journal (yet, see here). Well, here’s a simple implementation of a basic log exporter. It doesn’t have support for some of the features you may want, such as back-pressure, but it…
Added 10 months ago
nathom/streamrip: A scriptable music downloader for Qobuz, Tidal, SoundCloud, and Deezer
https://github.com/nathom/streamrip
A scriptable music downloader for Qobuz, Tidal, SoundCloud, and Deezer - nathom/streamrip
Creating a key generator to reset a Hikvision IP camera's admin password
https://neonsea.uk/blog/2018/08/01/hikvision-keygen.html
Unfortunately, generic IP cameras are notorious for their poor security practices. Most of the time, the manufacturers don't force secure passwords, and more...
Added 7 years ago
Introducing Nebula, the open source global overlay network from Slack - Engineering at Slack
https://slack.engineering/introducing-nebula-the-open-source-global-overlay-network-from-slack/
“What is the easiest way to securely connect tens of thousands of computers, hosted at multiple cloud service providers in dozens of locations around the globe?” If you want our answer, it’s Nebula, but I recommend that you read the rest of this short post before clicking that shiny link. At Slack, we asked ourselves this…
Added 11 months ago
CD Quality Internet Radio - High Resolution Audio
https://www.hiresaudio.online/cd-quality-internet-radio/
How to listen to CD Quality Internet Radio in lossless FLAC with browsers and apps plus a list of CD Quality Internet Radio stations.
The Book — Nanos.org
https://nanos.org/thebook
The nanos unikernel runs your
applications as secure, isolated virtual machines faster than bare metal
installs.
Added 6 months ago
Claudia - The Elegant Desktop Companion for Claude Code
https://claudiacode.com/
Transform your AI coding workflow with a beautiful GUI that makes managing Claude sessions, creating custom agents, and tracking usage effortless.
Added 5 months ago
netenglabs/suzieq: Using network observability to operate and design healthier networks
https://github.com/netenglabs/suzieq/?tab=readme-ov-file
Using network observability to operate and design healthier networks - netenglabs/suzieq
Added 10 months ago
linux - How to disable IPv6 on Debian Wheezy? - Super User
https://superuser.com/questions/546788/how-to-disable-ipv6-on-debian-wheezy
Added 10 years ago
About tony · big balls of mud killer
http://mcfiredrill.github.io/about.html
Logwatch: once a week is enough | Primož Verdnik.com
http://primozverdnik.com/2011/05/logwatch-once-a-week-is-enough/
Added 10 years ago
MPD to Sonos with Icecast :: jasper.la
https://jasper.la/posts/mpd-to-sonos-with-icecast/
Before I switched to Sonos as my primary way of listening to audio I’ve used MPD for years. As such I collected a fair amount of audio files that Rdio, Tidal or Spotify claim I’m not allowed to stream in my region. And while Sonos is great, there’s not really a way to control it the way you can control an MPD server for which there are many clients and libraries.
dotfiles/bashrc at master · da-n/dotfiles · GitHub
https://github.com/da-n/dotfiles/blob/master/bashrc
Added 10 years ago
Random MAC Address Generator
http://www.hellion.org.uk/cgi-bin/randmac.pl?scope=local&type=unicast
Added 10 years ago
GitHub - pucherot/Pi.Alert: WIFI / LAN intruder detector. Check the devices connected and alert you with unknown devices. It also warns of the disconnection of "always connected" devices
https://github.com/pucherot/Pi.Alert
WIFI / LAN intruder detector. Check the devices connected and alert you with unknown devices. It also warns of the disconnection of "always connected" devices - pucherot/Pi.Alert
Added 10 months ago
Streaming audio with MPD and Icecast2 on Raspberry Pi
https://stmllr.net/blog/streaming-audio-with-mpd-and-icecast2-on-raspberry-pi/
The main purpose of my Raspberry Pi is to act as a central music box. This task can easily be solved with MPD and Icecast2. Read on and get it working within...
The Python GTK+ 3 Tutorial — Python GTK+ 3 Tutorial 3.4 documentation
https://python-gtk-3-tutorial.readthedocs.io/en/latest/index.html
GitHub - Tnze/esp32_beaconSpam: Creates up to a thousand WiFi access points with custom SSIDs.
https://github.com/Tnze/esp32_beaconSpam
The Arduino sketch comes with 50 default SSID names, but you can edit that list easily in the source code :).
By constantly broadcasting the so called beacon frames, your standard WiFi scanner will think there are active networks nearby and adds them to the list.
Added 11 months ago
WordPress Maintenance Mode Without a Plugin · Sivel.net
http://sivel.net/2009/06/wordpress-maintenance-mode-without-a-plugin/
Added 7 years ago
Take My Advice: Letters to the Next Generation from People Who Know a Thing or Two: Harmon, James L.: 9781416578352: Amazon.com: Books
https://www.amazon.com/Take-My-Advice-Letters-Generation/dp/1416578358/?tag=braipick-20
Take My Advice: Letters to the Next Generation from People Who Know a Thing or Two | Harmon, James L. | ISBN: 9781416578352 | Kostenloser Versand für alle Bücher mit Versand und Verkauf duch Amazon.
Added 7 months ago
woodworkers resources « openMaterials
http://openmaterials.org/woodworkers-resources/
Added 6 years ago
Government Surplus Supplies & Equipment for Sale | USA.gov
http://www.usa.gov/shopping/supplies/supplies.shtml
Added 10 years ago
ClearOS – OS for your Server, Network, and Gateway Systems
https://www.clearos.com/
Added 10 years ago
4 Psychological Reasons You Feel Anxious All the Time | by Nick Wignall | Aug, 2023 | Medium
https://nickwignall.medium.com/4-psychological-reasons-you-feel-anxious-all-the-time-c2e8ee03d4a7?source=email-2fa332b6a7ef-1693382020616-digest.reader--c2e8ee03d4a7----0-2------------------9ab26724_252c_413c_835a_f23ea511f8bf-31
plutoprint/plutoprint: A Python Library for Generating PDFs and Images from HTML, powered by PlutoBook
https://github.com/plutoprint/plutoprint
A Python Library for Generating PDFs and Images from HTML, powered by PlutoBook - plutoprint/plutoprint
Added 5 months ago
Grateful Dead Lyric And Song Finder
http://www.whitegum.com/introjs.htm?/RECTAB3.HTM
Search for words or phrases in Grateful Dead lyrics
Added 6 years ago
Do monks and shamans swim in the same water that schizophrenics drown? - Quora
https://www.quora.com/Do-monks-and-shamans-swim-in-the-same-water-that-schizophrenics-drown
Added 6 years ago
console getty respawns and crashes, spamming the log · Issue #134 · lxc/linuxcontainers.org · GitHub
https://github.com/lxc/linuxcontainers.org/issues/134
Console getty keeps respawning in the guests, spamming the logs. The issue was discussed here: lxc/incus#444 Currently the proposed changes to the templates from images.linuxcontainers.org don't seem to be implemented. It took me an emba...
Added 9 years ago
Growth expectations for a UK MSP : r/msp
https://www.reddit.com/r/msp/comments/1h39nr7/growth_expectations_for_a_uk_msp/
Tuning LibreNMS
https://nsrc.org/workshops/2018/garnet-nsrc-cndo/networking/cndo/en/labs/librenms_tuning.html
Added 6 years ago
Speed up your Xubuntu with these simple tricks | Ubunlog
https://ubunlog.com/en/acelera-tu-xubuntu-con-estos-sencillos-trucos/?utm_source=destacado-inside
Xubuntu is the official Ubuntu flavor intended for computers with few resources. It is not as light as Xubuntu but it is lighter than Kubuntu and
Bill Kreutzmann songs with solo bands
http://www.whitegum.com/cgi-bin/cgiwrap/acsa/findbk.pl
Added 6 years ago
modernc.org/sqlite with Go - The IT Solutions
https://theitsolutions.io/blog/modernc.org-sqlite-with-go
I had long been aware of the [effort of cznic](https://gitlab.com/cznic/sqlite) to automatically translate the C source of SQLite to Go while avoiding the complexity CGo would introduce. SQLite was always meant to be a database you embed into your application, and I was curious what tradeoffs that meant, if any, and just generally how it differed from the usual suspects (PostgreSQL, etc.).
To explore these trade-offs and differences, I decided to dive deeper into the usage of this library.
SQLite is a single-writer multiple-reader database. Using just a single instance of database/sql.DB will not work well with this, because it will make it hard to avoid receiving SQLITE_BUSY errors when multiple writers try to run at the same time (because sql.DB is a connection pool). So we will need to separate readers from writers by making two instances of database/sql.DB and limiting the writer to a single [MaxOpenConn](https://pkg.go.dev/database/sql#DB.SetMaxOpenConns) and the reader to as many as you require.
So far, SQLite is behaving remarkably like other databases apart from the single-writer gotcha; we still have connections and per-connection settings. The usual way to pass these settings is usually in the DSN you pass to [sql.Open](https://pkg.go.dev/database/sql#Open) and this is [definitely possible](https://pkg.go.dev/modernc.org/sqlite#Driver.Open), but I find that it would be more straightforward if I could just run my custom SQL when a new connection is made[1]. We can do that with [sqlite.RegisterConnectionHook](https://pkg.go.dev/modernc.org/sqlite#RegisterConnectionHook).
Now the question is what settings to use, because [there are quite a few of them](https://www.sqlite.org/pragma.html). These are the ones I am using personally:
- `PRAGMA journal_mode = WAL;`
Use write-ahead-logging. Better concurrency, but with an edge-case: with heavy writers, the wal can grow idefinitely ([see for more](https://www.sqlite.org/cgi/src/doc/wal2/doc/wal2.md)). I don't expect this will happen in my use-case. For a good description on the various jornal modes, [see this blogpost](https://www.mycelial.com/learn/sqlite-journal-mode-options).
- `PRAGMA synchronous = NORMAL;`
Since with the WAL journal mode, this is safe, there is no reason to use FULL.
- `PRAGMA temp_store = MEMORY;`
Let's store temporary indices, tables, etc. in memory, my use-case is not very resource-constrained to require using the filesystem (also, [this is a fun read](https://www.sqlite.org/fasterthanfs.html) if we are talking about additional syscalls to the kernel)
- `PRAGMA mmap_size = 30000000000; -- 30GB`
Just making sure, access to my database is always done with memory-mapped I/O.
- `PRAGMA busy_timeout = 5000;`
How much time to wait in milliseconds after which SQLITE_BUSY is returned when waiting for the db to unlock.
- `PRAGMA automatic_index = true;`
Make sure [automatic indexing](https://www.sqlite.org/optoverview.html#autoindex) is enabled, it can only help, and is a great way to get warnings about indexes that should be created.
- `PRAGMA foreign_keys = ON;`
Make sure foreign key enforcement is enabled.
- `PRAGMA analysis_limit = 1000;`
Make sure [ANALYZE](https://www.sqlite.org/lang_analyze.html#approx) returns quickly in case the DB gets large.
- `PRAGMA trusted_schema = OFF;`
No idea what security audited functions are, but this setting makes sure only those can be run. The manual page tells me to turn it off anyway, so let's do that.
Not all of these settings are per-connection settings, but it doesn't hurt to always run all of these on every connection, and having a single "Init SQL" makes things simpler.
Let's deal with explicit transactions next. The default transaction mode is DEFERRED, meaning that it depends on the next statement what type of transaction is started (if a SELECT statement comes first, a read transaction is started, with the possibility of upgrading it to a write transaction depending on the statements that follow). With our setup, there should never be multiple writers concurrently, so making all transactions write transactions from the get-go (with BEGIN IMMEDIATE) can only help us show if this invariant is violated.
Putting this all together, this is the code we arrive at:
```go
package main
import (
"bytes"
"context"
"crypto/sha1"
"database/sql"
"database/sql/driver"
"encoding/hex"
"fmt"
"time"
"modernc.org/sqlite"
)
type DB struct {
dbPath string
Read *sql.DB
Write *sql.DB
}
const initSQL = `
PRAGMA journal_mode = WAL;
PRAGMA synchronous = NORMAL;
PRAGMA temp_store = MEMORY;
PRAGMA mmap_size = 30000000000; -- 30GB
PRAGMA busy_timeout = 5000;
PRAGMA automatic_index = true;
PRAGMA foreign_keys = ON;
PRAGMA analysis_limit = 1000;
PRAGMA trusted_schema = OFF;
`
func New(ctx context.Context, dbPath string) (db *DB, err error) {
db = &DB{
dbPath: dbPath,
}
// make sure every opened connection has the settings we expect
sqlite.RegisterConnectionHook(func(conn sqlite.ExecQuerierContext, _ string) error {
_, err = conn.ExecContext(ctx, initSQL, nil)
return err
})
write, err := sql.Open("sqlite", "file:"+db.dbPath)
if err != nil {
return
}
// only a single writer ever, no concurrency
write.SetMaxOpenConns(1)
write.SetConnMaxIdleTime(time.Minute)
if err != nil {
return
}
read, err := sql.Open("sqlite", "file:"+db.dbPath)
if err != nil {
return
}
// readers can be concurrent
read.SetMaxOpenConns(100)
read.SetConnMaxIdleTime(time.Minute)
db.Read = read
db.Write = write
return
}
func (db *DB) InTransaction(ctx context.Context, tx func(context.Context, *sql.Conn) error) (err error) {
// cancel anything that takes longer than 5 seconds
var cancel func()
ctx, cancel = context.WithTimeout(ctx, time.Duration(5*time.Second))
defer cancel()
// separate conn thats just for us
// so that the transactions queries are executed together
conn, err := db.Write.Conn(ctx)
if err != nil {
return
}
defer conn.Close()
_, err = conn.ExecContext(ctx, "BEGIN IMMEDIATE TRANSACTION")
if err != nil {
return
}
defer func() {
if r := recover(); r != nil || err != nil {
if _, err = conn.ExecContext(ctx, "ROLLBACK"); err != nil {
return
}
}
}()
err = tx(ctx, conn)
if err != nil {
return
}
_, err = conn.ExecContext(ctx, "COMMIT")
return
}
```
Just as a small added bonus, it's also very easy to register our own go functions that we can then call from SQL. In this example, we define the sha1 function, receiving and returning a single argument, and always returning the same output for the same input (thus the deterministic). For more information, [see the docs](https://www.sqlite.org/appfunc.html)
```go
func registerFuncs() {
// lets add our own sha1 hash function usable from SQL
sqlite.MustRegisterDeterministicScalarFunction(
"sha1",
1,
func(ctx *sqlite.FunctionContext, args []driver.Value) (driver.Value, error) {
var arg *bytes.Buffer
switch argTyped := args[0].(type) {
case string:
arg = bytes.NewBuffer([]byte(argTyped))
case []byte:
arg = bytes.NewBuffer(argTyped)
default:
return nil, fmt.Errorf("expected argument to be a string, got: %T", argTyped)
}
h := sha1.Sum(arg.Bytes())
return hex.EncodeToString(h), nil
},
)
}
```
In conclusion, this solution works perfectly well for most of the usage scenarios out there where immense scaling is neither expected nor needed. There are faster ways to use SQLite with Go (see the [excellent cvilsmeier benchmarks](https://github.com/cvilsmeier/go-sqlite-bench)), but its still plenty-fast enough, and avoiding CGo makes it very convenient also.
[1]: This is another thing that database/sql.DB being a connection pool makes harder.
Added 7 months ago
Monitoring your Peers (Asterisk extensions) and Trunks | SysAdminMan
https://sysadminman.net/blog/2015/monitoring-your-peers-asterisk-extensions-and-trunks-6557
Added 7 years ago