Skip to content

Instantly share code, notes, and snippets.

View rjloura's full-sized avatar

Rui Loura rjloura

View GitHub Profile
@rjloura
rjloura / memory.d
Created March 27, 2020 14:10 — forked from rhb2/memory.d
#!/usr/sbin/dtrace -s
#pragma D option quiet
pid$target::malloc:entry
{
self->size = arg0;
}
pid$target::malloc:return
/self->size/
@rjloura
rjloura / diesel_enums_with_fields_in_variants.rs
Last active October 3, 2019 19:23
How to implement diesel's ToSql and FromSql for enums that have variants with fields
use diesel::deserialize::{self, FromSql};
use diesel::serialize::{self, IsNull, Output, ToSql};
use diesel::backend;
use std::io::Write;
use diesel::sql_types;
#[derive(Debug, Clone, Copy, PartialEq, FromSqlRow, AsExpression)]
#[sql_type="sql_types::Text"]
pub enum EvacuateObjectStatus {
@rjloura
rjloura / postgres-cheatsheet.md
Created April 9, 2019 13:45 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@rjloura
rjloura / url_get_query_params.rs
Last active March 29, 2019 23:37
How to add get query params to hyper.rs URL
extern crate url;
extern create hyper;
use url::Url;
use hyper::{Client, Uri};
let mut url = Url::parse("http://api.openweathermap.org/data/2.5/weather").unwrap();
url.query_pairs_mut()
.append_pair("q", "some query")
@rjloura
rjloura / trunk-images.md
Last active March 27, 2020 13:21 — forked from jperkin/trunk-images.md
Test pkgsrc trunk bootstraps and images

consider using 20200124 images and tools

pkgsrc trunk packages and images

Now that pkgin has refresh support and the macOS trunk builds have proven that a rolling trunk release works well, I am happy to make SmartOS/illumos trunk packages and images available again for testing.

These are rolling builds of pkgsrc trunk every day (or so), providing the latest packages without having to upgrade across quarterly releases. Just install once then pkgin full-upgrade to keep up-to-date.

This is primarily of interest to:

@rjloura
rjloura / trunk-images.md
Created February 5, 2019 20:53 — forked from papertigers/trunk-images.md
Test pkgsrc trunk bootstraps and images

pkgsrc trunk packages and images

Now that pkgin has refresh support and the macOS trunk builds have proven that a rolling trunk release works well, I am happy to make SmartOS/illumos trunk packages and images available again for testing.

These are rolling builds of pkgsrc trunk every day (or so), providing the latest packages without having to upgrade across quarterly releases. Just install once then pkgin full-upgrade to keep up-to-date.

This is primarily of interest to:

  • Users who just want the latest software.
  • Users who don't want to bother with having to upgrade releases every quarter.

Marlin Image workaround

  1. cd /var/tmp

  2. Determine the UUID of the latest "manta-marlin" image on updates.joyent.com.

    muuid=$(updates-imgadm list name=manta-marlin --latest -H -o uuid)
    
  3. Download directly from a separate manual download area in Manta.

@rjloura
rjloura / README.md
Created September 11, 2018 15:09 — forked from jperkin/README.md
Creating a NetBSD VM on SmartOS

Instructions for building a NetBSD VM

Install

vmadm create < netbsd-install.json
vmadm list
zoneuuid=...
cp NetBSD-6.0-amd64.iso /zones/$zoneuuid/root/netbsd.iso

vmadm boot $zoneuuid order=cd,once=d cdrom=/netbsd.iso,ide

# perform a fresh install of Ubuntu 17.10
# upgrade the kernel to v4.13.10
mkdir ~/kernel-v4.13.10
cd ~/kernel-v4.13.10
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13.10/linux-headers-4.13.10-041310_4.13.10-041310.201710270531_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13.10/linux-headers-4.13.10-041310-generic_4.13.10-041310.201710270531_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13.10/linux-image-4.13.10-041310-generic_4.13.10-041310.201710270531_amd64.deb
sudo dpkg -i *.deb
@rjloura
rjloura / updating_manta_images.md
Last active July 11, 2018 19:53
How to update all manta images to the latest release
  1. When a new release comes out you will need to import all of the new images
    for uuid in `updates-imgadm -C release list name=~manta --latest -H -o uuid`; do sdc-imgadm import $uuid -S https://updates.joyent.com?channel=release; done
    
  2. Export the current manta config with manta-adm show -sj > update.json
  3. Then modify all the image uuids in update.json with the ones that were downloaded in step 1. (A little node script would be nice here)
  4. manta-adm update update.json