Skip to content

Instantly share code, notes, and snippets.

View carlsverre's full-sized avatar
🪐
Building SQLSync

Carl Sverre carlsverre

🪐
Building SQLSync
View GitHub Profile
~ $ 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==

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:

@carlsverre
carlsverre / samples.sql
Created March 14, 2020 16:15
Interesting approximations of PI (and other ideas) - by MemSQL Engineering
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;
@carlsverre
carlsverre / schema.sql
Created April 30, 2020 22:14
MemSQL Telco Customer Churn Dataset
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 / ec2-ephemeral-setup.sh
Created July 15, 2020 17:30
Setup & merge all ephemeral drives on an EC2 instance
#!/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 / README.md
Created December 9, 2020 00:02
Output all the IP addresses (not CIDR's) for each of the major cloud providers (gcp, azure, aws)
  1. Download process.py
  2. Run
~/csp $ python3 process.py
usage: process.py aws|azure|gcp

~/csp $ python3 process.py aws | head -n 10
3.5.140.0
3.5.140.1
create database if not exists t;
create database if not exists t2;
use t;
create table if not exists x (id int);
delimiter //
create or replace procedure foo (i int) as
begin
@carlsverre
carlsverre / !SingleStore Data Hiding Demo.md
Last active June 30, 2021 17:13
Simple data hiding demo using RBAC in SingleStore

This is an example of how you can use RBAC and the CURRENT_SECURITY_GROUPS function to implement data hiding in SingleStore.

  1. Get a SingleStore free license key from https://portal.singlestore.com
  2. Set your SingleStore license key as an environment variable
export LICENSE_KEY="PUT YOUR LICENSE KEY HERE"
  1. Run SingleStore cluster in a box
docker run -it \
@carlsverre
carlsverre / setup.sh
Created July 16, 2021 16:11
Setup HTTP api on all SingleStore Aggregators
sdb-admin list-nodes --role aggregator -q \
| xargs -I NODEID sdb-admin -y update-config --memsql-id NODEID --key http_api --value on
sdb-admin list-nodes --role aggregator -q \
| xargs -I NODEID sdb-admin -y update-config --memsql-id NODEID --key http_proxy_port --value <port>
sdb-admin list-nodes --role aggregator -q \
| xargs -I NODEID sdb-admin -y query --memsql-id NODEID --sql "RESTART PROXY"