Skip to content

Instantly share code, notes, and snippets.

@lo
lo / modern_sql_style_guide.md
Created October 17, 2021 11:08 — forked from mattmc3/modern_sql_style_guide.md
Modern SQL Style Guide
layout author title revision version description
default
mattmc3
Modern SQL Style Guide
2019-01-17
1.0.1
A guide to writing clean, clear, and consistent SQL.

Modern SQL Style Guide

@lo
lo / main.go
Created January 7, 2018 19:33 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@lo
lo / SparkRowConverter.scala
Created July 6, 2017 11:06 — forked from debugger87/SparkRowConverter.scala
Convert Array[org.apache.spark.sql.Row] to Array[Map[String, Any]]
import org.apache.spark.sql.catalyst.expressions.Row
import org.apache.spark.sql.catalyst.types._
import scala.collection.mutable.{ArrayBuffer}
object SparkRowFormatter {
def formatRowsWithSchema(rowArr: Array[Row], schema: StructType) = {
rowArr.map(r => formatStruct(schema.fields, r))
}
@lo
lo / Schema2CaseClass.scala
Created July 6, 2017 10:53 — forked from yoyama/Schema2CaseClass.scala
Generate case class from spark DataFrame/Dataset schema.
/**
* Generate Case class from DataFrame.schema
*
* val df:DataFrame = ...
*
* val s2cc = new Schema2CaseClass
* import s2cc.implicit._
*
* println(s2cc.schemaToCaseClass(df.schema, "MyClass"))
*
@lo
lo / eltool.sh
Created June 15, 2017 12:35 — forked from dimkir/eltool.sh
Tool for building dependencies for electron on Amazon Linux (and maybe on CentOS / RHEL)
#!/bin/bash
DIST_DEPS=0
CENTOS_DEPS=0
GCONF_COMPILE=0
GCONF_INSTALL=0
PIXBUF_INSTALL=0
PIXBUF_COMPILE=0
@lo
lo / nightmare-on-amazon-linux.MD
Created June 15, 2017 11:30 — forked from dimkir/nightmare-on-amazon-linux.MD
How to run nightmare on Amazon Linux

Running nightmare on Amazon Linux

You may have thought of running nightmare on AWS Lambda. But before we can run it on Lambda, we need first to make it run on Amazon Linux.

Provision instance which replicates Lambda environment

According to AWS Documentation on Lambda Execution Environment and available Libraries we would need this AMI image with this alias amzn-ami-hvm-2016.03.3.x86_64-gp2. Keep in mind that AMI-image-id for this instance would be different in different regions (eg):

  • In eu-west-1 - ami-f9dd458a
  • In us-east-1 - ami-6869aa05

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }
@lo
lo / go_kinesis_with_structs.go
Created October 5, 2015 21:23 — forked from pricees/go_kinesis_with_structs.go
Go + AWS Kinesis + Encode/Decode Structs
/**
NOTE:
Assumes env contains aws credentials:
AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY
AWS_SECRET_KEY_ID or AWS_SECRET_KEY
and AWS_REGION_NAME (e.g. 'US-EAST-1')
see EnvAuth() below
*/
@lo
lo / gist:82218496ff8d564dd600
Last active August 29, 2015 14:26 — forked from mcastilho/gist:e051898d129b44e2f502
Cheap MapReduce in Go
package main
import (
"bufio"
"encoding/csv"
"encoding/json"
"fmt"
"io"
"os"
"path/filepath"