Skip to content

Instantly share code, notes, and snippets.

@swuecho
swuecho / scala-http-postgres-html-docker.scala
Created January 24, 2024 14:08 — forked from keynmol/scala-http-postgres-html-docker.scala
Sample gist showing how to run a HTTP server with Typelevel Scala libraries, and a postgres docker container
//> using dep "org.http4s::http4s-scalatags::0.25.2"
//> using dep "org.http4s::http4s-dsl::0.23.23"
//> using dep "org.http4s::http4s-ember-server::0.23.23"
//> using dep "org.tpolecat::skunk-core::0.6.0"
//> using dep "com.dimafeng::testcontainers-scala-postgresql::0.41.0"
//> using dep "com.outr::scribe-slf4j::3.12.2"
import skunk.*, codec.all.*, syntax.all.*
import cats.effect.*
import scalatags.Text.all.*
@swuecho
swuecho / proxmox-import-disk-image.txt
Created August 12, 2020 00:56
Add import existing disk image into Proxmox
#
# The official PVE docs on how to prepare cloud-init templates:
# https://pve.proxmox.com/wiki/Cloud-Init_Support#_preparing_cloud_init_templates
#
# Additional guides and resources:
# https://dae.me/blog/2340/how-to-add-an-existing-virtual-disk-to-proxmox/
# https://pve.proxmox.com/pve-docs/qm.1.html
# use the Qemu/KVM Virtual Machine Manager to import the disk
qm importdisk 107 Univention-App-kopano-core-KVM.qcow2 local-lvm
@swuecho
swuecho / Virtual Box Host Only Static IP.md
Created May 31, 2018 05:27 — forked from pjdietz/Virtual Box Host Only Static IP.md
VirtualBox Host-Only Adapter with Static IP

VirtualBox Host-Only Static IP

My typical setup for a development box in VirtualBox uses two NICs. The first uses NAT to allow the box to communicate with the outside world through my host computer’s network connection. (NAT is the default, so shouldn't require any setup.) The second is a "host-only" connection that allows my host and guest to interact.

To create a host-only connection in VirtualBox, start by opening the preferences in VirtualBox. Go to the "Network" tab, and addd a Host-only Network. Modify the host-only network, and disable DHCP. Make a note of the IP address. (Feel free to set the IP address as well, if you like.)

Next, assign this host-only adapter to the virtual machine. Select the VM and press "Settings". Go to the "Network" tab, and select "Adpater 2". Enable the adapter, set it to a "Host-only Adapter", and select the adpater you created above.

Temporary

@swuecho
swuecho / playground.rs
Created December 14, 2017 17:22 — forked from anonymous/playground.rs
Rust code shared from the playground
use std::str::FromStr;
fn main () {
let mut input = "15 Bear".split(' ');
// Need to pull the number and parse it.
let number = input.next()
// Process Option<&'static str> to Option<int>
.and_then(|x| i32::from_str(x).ok() )
.expect("Was not provided a valid number.");
// The next token is our animal.
@swuecho
swuecho / playground.rs
Created December 14, 2017 17:17 — forked from anonymous/playground.rs
Rust code shared from the playground
fn main () {
let number: f64 = 20.;
// Perform a pipeline of options.
let result = Some(number)
.map(inverse) // Described below.
.map(double)
.map(inverse)
.and_then(log) // Described below.
.map(square)
.and_then(sqrt);
@swuecho
swuecho / gist:c0e9394b183edf120362390b6f4b808f
Created March 9, 2017 00:56 — forked from aidanhs/gist:5ac9088ca0f6bdd4a370
Rust binary tree worked example

% Let's build a binary tree!

Let's build a binary tree of strings in Rust. To recap, each node in a binary tree:

  1. must have a value
  2. may or may not have left and/or right children

So we can describe a single node like this:

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@swuecho
swuecho / playground.rs
Created December 21, 2016 17:56 — forked from anonymous/playground.rs
Shared via Rust Playground
struct Point {
x: i32,
y: i32,
}
fn takes_point(Point {x, y}: Point) {
println!("({}, {})", x, y);
}
fn main() {
@swuecho
swuecho / barcodes.csv
Created December 15, 2016 01:35 — forked from audy/barcodes.csv
Demultiplex Ion Torrent Reads
1 CTAAGGTAA
2 TAAGGAGAA
3 AAGAGGATT
4 TACCAAGAT
5 CAGAAGGAA
6 CTGCAAGTT
7 TTCGTGATT
8 TTCCGATAA
9 TGAGCGGAA
10 CTGACCGAA
@swuecho
swuecho / gist:fbebd122af13a15505948482768eda56
Created December 3, 2016 07:23 — forked from NikolayS/file_fdw__csv.sql
Postgres: CSV file as a table using FDW
-- Installs "file_fdw" extension and creates foreign table to work with data from CSV file.
-- See also the comment below which helps to automate the process for Google Spreadsheets
-- Another option would be using Multicorn for Google Spreadsheets, but it requires additional steps
-- (see https://wiki.postgresql.org/wiki/Foreign_data_wrappers).
CREATE EXTENSION file_fdw;
CREATE SERVER import FOREIGN DATA WRAPPER file_fdw;
CREATE FOREIGN TABLE table1_import (
col1 text,
col2 text,