Skip to content

Instantly share code, notes, and snippets.

@ericjster
ericjster / plot_dbscan.py
Last active July 12, 2017 07:27
Change for scikit-learn example of dbscan clustering. Improve performance of plot_dbscan.py by minimizing calls to plot.
# -*- coding: utf-8 -*-
"""
===================================
Demo of DBSCAN clustering algorithm
===================================
Finds core samples of high density and expands clusters from them.
"""
print(__doc__)
@ericjster
ericjster / writebinary_test.go
Created May 16, 2019 07:21
Golang write binary file using memory mapped structs
package main
// Example of writing a binary file of float structs.
import (
"log"
"os"
"reflect"
"testing"
"unsafe"
@ericjster
ericjster / argsort.go
Created May 16, 2019 10:22
golang argsort
// https://play.golang.org/p/A3niFJ582wJ
package main
import (
"fmt"
"sort"
)
func main() {
@ericjster
ericjster / main_test.go
Last active February 10, 2023 02:23
Golang regexp timing
package main
// Looking at timing of regex.
// Regex example from Damian Gryski's article:
// https://medium.com/@dgryski/speeding-up-regexp-matching-with-ragel-4727f1c16027
//
// Let's measure a hand-coded regex and compare with the regex library and ragel
// state machine. In this case, the hand-coded version is less than 10% of the
// cost. Obviously 1 line of code is more understandable and maintainable than
// 50 lines with hardcoded constants, but it might be useful to know what could
@ericjster
ericjster / cassandra-hosts-jstack.1.txt
Created April 2, 2020 22:16
jstack for cassandra-hosts with schema having map<text,text>, doing reads against
Captured on 2-apr-2020
cluster = cassandra-hosts
cassandra version 3.11.4.
CREATE TABLE host.agent_metadata_by_host (
org_id bigint,
host_id bigint,
metadata map<text, text>,
PRIMARY KEY ((org_id, host_id))
#!/bin/bash
# Note that virtualenv guides suggest updating pip, and using the system pip to
# bootstrap a user installation of pip.
#
# Here is a great guide to virtualenv, pyenv, pyenv-virtualenv,
# virtualenvwrapper, pyenv-virtualenvwrapper, pipenv.
# https://stackoverflow.com/questions/41573587/what-is-the-difference-between-venv-pyvenv-pyenv-virtualenv-virtualenvwrappe
# One person says virtualenv is the community standard.
# One person says avoid virtualenv after Python 3.3+ and instead use venv from standard shipped library.
#!/bin/bash
# Note that virtualenv guides suggest updating pip, and using the system pip to
# bootstrap a user installation of pip.
#
# Here is a great guide to virtualenv, pyenv, pyenv-virtualenv,
# virtualenvwrapper, pyenv-virtualenvwrapper, pipenv.
# https://stackoverflow.com/questions/41573587/what-is-the-difference-between-venv-pyvenv-pyenv-virtualenv-virtualenvwrappe
# One person says virtualenv is the community standard.
# One person says avoid virtualenv after Python 3.3+ and instead use venv from standard shipped library.
@ericjster
ericjster / ej_ping_forever.sh
Last active July 16, 2020 22:10
Ping forever
#/bin/bash
# Log wifi and internet connectivity info.
# Note that 'airport' can do logging also.
#
# 8.8.8.8 = Google primary dns server
# 8.8.4.4 = Google secondary dns server
# 4.2.2.2 = Level 3 Communications dns server
# 1.1.1.1 = Cloudflare and APNIC dns server
# 208.67.222.222 = Cisco OpenDNS
@ericjster
ericjster / main.go
Created November 10, 2020 06:33
Golang test to find if a string is a well known constant
package main
import (
"fmt"
"reflect"
"unsafe"
)
// This project tries to find a way to determine if a string is a const, in an
// efficient way.
@ericjster
ericjster / README.md
Last active February 10, 2021 00:13
go simpleserver

Simple Server

This is a small golang program to serve files via http. The files are restricted to the base directory and its children, or a specified directory. You will see a nice directory listing in the browser. It is meant to be used with *.html, *.png, and other files.

To use it: go build && ./simpleserver ..

Then in your browser, navigate to: http://localhost:8000/