Skip to content

Instantly share code, notes, and snippets.

Avatar
Keep calm and code on

Carl Sverre carlsverre

Keep calm and code on
View GitHub Profile
@carlsverre
carlsverre / ec2-ephemeral-setup.sh
Created Jul 15, 2020
Setup & merge all ephemeral drives on an EC2 instance
View ec2-ephemeral-setup.sh
#!/usr/bin/env bash
set -eux
DEVICES=$(ls /dev | egrep -o nvme.n1 | sort -u | grep -v $(df -h | egrep -o nvme.n1) | sed 's_\<_/dev/_g')
echo "Setting up the following devices:"
echo ${DEVICES}
read -p "Are you sure? " -n 1 -r
echo
@carlsverre
carlsverre / schema.sql
Created Apr 30, 2020
MemSQL Telco Customer Churn Dataset
View schema.sql
DROP DATABASE IF EXISTS churn_example;
CREATE DATABASE churn_example;
USE churn_example;
CREATE TABLE telco_customer_churn
(
customerID TEXT,
gender TEXT,
SeniorCitizen BOOLEAN,
Partner TEXT,
@carlsverre
carlsverre / samples.sql
Created Mar 14, 2020
Interesting approximations of PI (and other ideas) - by MemSQL Engineering
View samples.sql
create database if not exists pi;
use pi
create table if not exists mc (d int, key() using clustered columnstore);
create table if not exists tries(iter integer, pi float);
delimiter //
CREATE OR REPLACE PROCEDURE px(iter INTEGER) AS
DECLARE
q query(value FLOAT) =
select 4*sum(d)/count(d) from mc;
View network_notes.md

To add a raspberry pi running raspbian jessie to the network add the following lines to the end of /etc/dhcpcd.conf and reboot:

interface eth0
static ip_address=10.110.0.1/24
static routers=10.110.0.1

To add a linux machine to the network run the associate setup_network script:

View gist:63758394dcdca6c351af5c1cf54e354d
~ $ curl -I https://cache.nixos.org/nar/04llx3f88habsh8h8x73k31p3ym0v608bn8j67c7mv15ws263k74.nar.xz
HTTP/1.1 500 Internal Server Error
Content-Type: application/xml
Connection: keep-alive
Date: Fri, 23 Sep 2016 17:39:01 GMT
Server: AmazonS3
Age: 121
X-Cache: Error from cloudfront
Via: 1.1 ae162f6796e551002447afd7c07ec67a.cloudfront.net (CloudFront)
X-Amz-Cf-Id: tZeL92fiegpLt3j6VncFsYdLupW0ZmhCCd7Xf2I-U7F2xN5iYvJwXQ==
View keybase.md

Keybase proof

I hereby claim:

  • I am carlsverre on github.
  • I am carlsverre (https://keybase.io/carlsverre) on keybase.
  • I have a public key whose fingerprint is A940 F6CA 929F 7E26 5E89 C2E1 E5B3 FAD5 BEF7 CFC6

To claim this, I am signing this object:

@carlsverre
carlsverre / .cvimrc
Last active Jul 11, 2016
cVim config
View .cvimrc
set nosmoothscroll
set noautofocus
set typelinkhints
let searchlimit = 30
let scrollduration = 10
let scrollstep = 70
let searchalias g = "google"
let barposition = "bottom"
View example.java
JavaRDD<String> inputFile = sparkContext.textFile(filePath, minPartitions).toJavaRDD();
JavaRDD<byte[]> bytes = inputFile.map(new Function<String, byte[]>(){
@Override
public byte[] call(String str) {
return ByteUtils.utf8StringToBytes(str);
}
});
return Option$.MODULE$.apply(JavaRDD.toRDD(bytes));
@carlsverre
carlsverre / 1_bug.tf
Last active Nov 12, 2015
Terraform bug with ignore_changes
View 1_bug.tf
provider "aws" {
region = "us-east-1"
}
resource "aws_vpc" "default" {
cidr_block = "172.17.0.0/24"
}
resource "aws_subnet" "default" {
vpc_id = "${aws_vpc.default.id}"
@carlsverre
carlsverre / breakpoints.scss
Created Jan 13, 2015
Simple SCSS breakpoint implementation
View breakpoints.scss
$breakpoints: (
zero: 0px,
small: 900px,
medium: 1200px,
medium-large: 1400px,
large: 1600px,
xlarge: 2000px
);
@mixin breakpoint($left, $right: null) {
You can’t perform that action at this time.