Skip to content

Instantly share code, notes, and snippets.

View ARolek's full-sized avatar

Alexander Rolek ARolek

View GitHub Profile
@ARolek
ARolek / gmailSMTP.go
Last active May 5, 2017 05:34
A quick and dirty implementation of the Golang SMTP package used with GMail.
package tools
import (
"fmt"
"net/smtp"
)
var (
username string = ""
password string = ""
@ARolek
ARolek / ImageMagick-Amazon-Linux.md
Last active February 10, 2023 00:07
Install ImageMagick from source on Amazon Linux

I needed a newer version of ImageMagick than is available on the yum packages on Amazon Linux. I tried using the remi repo but it failed with dependency errors. Here is what I did to install ImageMagick with support for PNG, JPG, and TIFF.

download the most recent package

wget http://www.imagemagick.org/download/ImageMagick.tar.gz

uncomress the package

@ARolek
ARolek / colors-by-area.go
Created July 2, 2014 20:27
Sorting structs in GoLang
package main
import "fmt"
import "sort"
type Color struct {
Area float64
}
type ByArea []Color
@ARolek
ARolek / index.html
Last active August 29, 2015 14:04 — forked from tmcw/index.html
Mapbox feature layer custom data pass
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>A simple map</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox.js/v1.6.4/mapbox.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/v1.6.4/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@ARolek
ARolek / hasTransparency.go
Created June 3, 2015 23:34
detect if an image has a transparent pixel
package main
import (
"encoding/base64"
"image"
"log"
"strings"
_ "image/jpeg"
_ "image/png"
@ARolek
ARolek / ReaderReplacerWriter.go
Created June 18, 2015 20:21
HTTP GET read body -> replace strings -> write to buffer
package main
import (
"bufio"
"bytes"
"log"
"net/http"
"strings"
)
@ARolek
ARolek / HttpToHttps.go
Last active August 29, 2015 14:24
HTTP -> HTTPS redirect from Amazon's ELB in Go
import (
"fmt"
"net/http"
)
func ServeHTTP(w http.ResponseWriter, r *http.Request) {
// HTTP -> HTTPS redirects for Amazon ELB
// sniff for X-Forwarded-Proto header
proto := r.Header.Get("X-Forwarded-Proto")
// if our protocol is http, redirect to https
@ARolek
ARolek / string_to_color.go
Created July 20, 2017 21:36
Golang StringToColor
package main
import (
"fmt"
"strconv"
)
// port of https://stackoverflow.com/questions/3426404/create-a-hexadecimal-colour-based-on-a-string-with-javascript
func StringToColor(str string) string {
var hash uint
for i := range []rune(str) {
Failed to insert point(288) POINT (-13037461.1 3865598.235)
MULTIPOINT (-13042067.95 3864579.713,-13042067.95 3869624.556,-13039354.37 3864579.713,-13042067.95 3866305.517,-13037023.11 3869624.556,-13042056.68 3866305.668,-13042056.58 3866293.725,-13042055.88 3866206.792,-13042055.87 3866205.596,-13042055.87 3866205.564,-13042055.86 3866182.987,-13042055.86 3866182.97,-13042055.82 3866169.57,-13042035.26 3866169.637,-13041985.78 3866169.801,-13041951.11 3866169.919,-13041914.25 3866170.041,-13041889.98 3866170.122,-13041866.08 3866170.2,-13041845.09 3866170.271,-13041822.98 3866170.34,-13041801.25 3866170.414,-13041780.62 3866170.485,-13041756.73 3866170.562,-13041717.41 3866170.691,-13041663.32 3866170.868,-13041654.57 3866170.897,-13041627.94 3866170.758,-13041598.4 3866170.601,-13041596.64 3866170.591,-13041551.34 3866170.338,-13041498.46 3866170.074,-13041408.24 3866169.71,-13041311.18 3866169.324,-13041285.13 3866169.219,-13041251.08 3866169.082,-13041240.57 3866169.039,-13041195.3 3866169.09,-13041188.
@ARolek
ARolek / test_tabs.sh
Created February 24, 2020 18:59
detecting tabs in bash
#/bin/bash
str="AIN TRA"
delimiter=$(echo $str | perl -ne "print /AIN(.{1})/")
echo "delimiter is '$delimiter'"
if [[ $delimiter = [^\t] ]]; then
echo "ok"
else
echo "no"