Skip to content

Instantly share code, notes, and snippets.

View nick96's full-sized avatar
☁️
Chilling in the cloud

Nick Spain nick96

☁️
Chilling in the cloud
View GitHub Profile
@nick96
nick96 / dynamic_dispatch_box.rs
Last active August 10, 2021 13:41
The well rounded rustation
fn count(xs: Vec<Box<dyn std::any::Any>>) -> usize {
let mut n = 0;
for _ in xs {
n += 1;
}
n
}
fn main() {
println!("str: {}", count(vec![Box::new("1"), Box::new("2"), Box::new(1), Box::new(2)]));
@nick96
nick96 / marker_traits.rs
Created August 10, 2021 13:03
The well rounded rustation
use std::thread;
#[derive(Debug)]
struct MyBox(*mut u8);
unsafe impl Send for MyBox {}
fn main() {
let mut x = 5;
let test = MyBox(&mut x);
@nick96
nick96 / crash.log
Last active March 20, 2021 01:55
Terraform crash output
Error: rpc error: code = Unavailable desc = transport is closing
panic: runtime error: invalid memory address or nil pointer dereference
2021-03-20T12:55:02.730+1100 [DEBUG] plugin.terraform-provider-segfault: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x165d902]
2021-03-20T12:55:02.730+1100 [DEBUG] plugin.terraform-provider-segfault:
2021-03-20T12:55:02.730+1100 [DEBUG] plugin.terraform-provider-segfault: goroutine 66 [running]:
2021-03-20T12:55:02.730+1100 [DEBUG] plugin.terraform-provider-segfault: github.com/nick96/terraform-provider-segfault/segfault.dataSegfaultRead(0x188ccc8, 0xc00068e480, 0xc000698500, 0x0, 0x0, 0xc00059a410, 0xc0001e9948, 0x100f818)
2021-03-20T12:55:02.730+1100 [DEBUG] plugin.terraform-provider-segfault: /Users/nicholasspain/devel/personal/terraform-provider-segfault/segfault/provider.go:29 +0x2
@nick96
nick96 / whoami.nomad
Created March 18, 2021 12:57
Example nomad job
job "whoami" {
datacenters = ["dc1"]
type = "service"
update {
max_parallel = 1
min_healthy_time = "10s"
healthy_deadline = "3m"
progress_deadline = "10m"
auto_revert = false

Keybase proof

I hereby claim:

  • I am nick96 on github.
  • I am nspain (https://keybase.io/nspain) on keybase.
  • I have a public key ASDtVLAsYEm_YUuiI1MJbhFdGv1AqPPRg61m5a9IltTEUgo

To claim this, I am signing this object:

@nick96
nick96 / it_project_motivational_model.png
Last active August 1, 2019 08:07
IT Project Lect 1 notes
it_project_motivational_model.png
@nick96
nick96 / dht11-test.ino
Last active September 1, 2017 15:25
Code snippets for blog
/* Code testing out the DHT11 Temperature and Humidity sensor */
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
@nick96
nick96 / config.log
Last active September 1, 2017 11:53
Output of export and contents of config.log for debugging Irssi build
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by irssi configure 1.1-head, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure
## --------- ##
## Platform. ##
@nick96
nick96 / cp-many-files.sh
Created June 8, 2017 07:41
Copy multiple files of the same extension from one directory to another
# Requires find and xargs from GNU's findutils
# Just another example of the joys of composability in the UNIX philosophy
find <src-directory> -name *.<extension> -print0 | xargs -0 -I % cp % <dst-directory>
# Breakdown
# find -- from findutils, does what is says on the tin
# -name -- File name(s) to find, in this case we used the shell glob '*' to get any files with <extension>
# -print0 -- Separate files with a NULL byte
#
@nick96
nick96 / open-app-osx.el
Last active May 27, 2017 05:27
Open an application from Emacs (OSX)
(defun nick/osx-open-app ()
"Open an application in OS X."
(interactive)
(shell-command (format "open -a %S" (read-string "Application: "))))