Skip to content

Instantly share code, notes, and snippets.

View jasonmccallister's full-sized avatar

Jason McCallister jasonmccallister

View GitHub Profile
@andrebrait
andrebrait / keychron_linux.md
Last active April 18, 2024 16:05
Keychron keyboards on Linux + Bluetooth fixes

Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.

Note: many newer Keychron keyboards use QMK as firmware and most tips here do not apply to them. Maybe the ones related to Bluetooth can be useful, but everything related to Apple's keyboard module (hid_apple) on Linux, won't work. As far as I know, all QMK-based boards use the hid_generic module instead. Examples of QMK-based boards are: Q, Q-Pro, V, K-Pro, etc.

Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.

Make Fn + F-keys work (NOT FOR QMK-BASED BOARDS)

Older Keychron keyboards (those not based on QMK) use the hid_apple driver on Linux, even in the Windows/Android mode, both in Bluetooth and Wired modes.

@jasonmccallister
jasonmccallister / main.go
Created November 2, 2020 01:27
Changing directories with Go exec.command
package main
import (
"flag"
"log"
"os"
"os/exec"
)
func main() {
@mattstein
mattstein / db-test.php
Last active March 28, 2023 23:01
PHP MySQL/PostgreSQL Connection Test
<?php
/**
* Database Connection Tester
* A quick-and-dirty standalone script for checking PHP’s connection to a
* MySQL (or MariaDB) or PostgreSQL database.
*
* To use, enter the settings below and run the following from your terminal:
* ```
* php -f db-test.php
docker run -d \
--restart=always \
-p 33060:3306 \
-e MYSQL_ROOT_PASSWORD=root \
-v ~/docker/volumes/mysql:/var/lib/mysql \
--name mysql-5.7 \
mysql:5.7 \
--sql-mode="NO_ENGINE_SUBSTITUTION"
admin:
access_log_path: /tmp/admin_access.log
address:
socket_address:
protocol: TCP
address: 127.0.0.1
port_value: 9901
static_resources:
listeners:
- name: listener_0
@abn
abn / slugify.postgres.sql
Last active March 14, 2024 20:29
A slugify function for postgres
-- original source: https://medium.com/adhawk-engineering/using-postgresql-to-generate-slugs-5ec9dd759e88
-- https://www.postgresql.org/docs/9.6/unaccent.html
CREATE EXTENSION IF NOT EXISTS unaccent;
-- create the function in the public schema
CREATE OR REPLACE FUNCTION public.slugify(
v TEXT
) RETURNS TEXT
LANGUAGE plpgsql
@milesjordan
milesjordan / vpc.yaml
Last active April 4, 2024 02:37
Cloudformation template for a VPC with ipv6, with public and private subnets, calculating the subnet ipv6 CIDR blocks on the fly.
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Public VPC and subnets
Resources:
#
# Public VPC
#
PublicVpc:
@devinodaniel
devinodaniel / gist:8f9b8a4f31573f428f29ec0e884e6673
Created November 21, 2017 20:18
Generate SSH RSA Private/Public Key pair with Golang
// This shows an example of how to generate a SSH RSA Private/Public key pair and save it locally
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"golang.org/x/crypto/ssh"
@fntlnz
fntlnz / self-signed-certificate-with-custom-ca.md
Last active April 9, 2024 16:02
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@rgl
rgl / wait_for_http_json_response.sh
Created August 25, 2016 07:43
Wait for an HTTP endpoint to return a given JSON property value with Bash, curl and jq
bash -c 'while [[ "$(curl -s localhost:9000/api/system/status | jq --raw-output ''.status'')" != "UP" ]]; do sleep 5; done'
# also check https://gist.github.com/rgl/f90ff293d56dbb0a1e0f7e7e89a81f42