Skip to content

Instantly share code, notes, and snippets.

View danielbh's full-sized avatar

Daniel Hollcraft danielbh

View GitHub Profile
@danielbh
danielbh / groupcache.go
Created January 1, 2021 23:45 — forked from fiorix/groupcache.go
Simple groupcache example
// Simple groupcache example: https://github.com/golang/groupcache
// Running 3 instances:
// go run groupcache.go -addr=:8080 -pool=http://127.0.0.1:8080,http://127.0.0.1:8081,http://127.0.0.1:8082
// go run groupcache.go -addr=:8081 -pool=http://127.0.0.1:8081,http://127.0.0.1:8080,http://127.0.0.1:8082
// go run groupcache.go -addr=:8082 -pool=http://127.0.0.1:8082,http://127.0.0.1:8080,http://127.0.0.1:8081
// Testing:
// curl localhost:8080/color?name=red
package main
import (
@danielbh
danielbh / cheatsheet-elasticsearch.md
Created January 18, 2020 14:46 — forked from ruanbekker/cheatsheet-elasticsearch.md
Elasticsearch Cheatsheet : Example API usage of using Elasticsearch with curl
@danielbh
danielbh / wrapper.go
Created January 30, 2019 00:59 — forked from KarthikNayak/wrapper.go
Go Meetup NYC; 29th Jan
package main
import (
"io"
"os"
"fmt"
"time"
)
type SlowWriter struct {
@danielbh
danielbh / WhyILikeGo.md
Created October 12, 2018 13:36 — forked from freeformz/WhyILikeGo.md
Why I Like Go

A slightly updated version of this doc is here on my website.

Why I Like Go

I visited with PagerDuty yesterday for a little Friday beer and pizza. While there I got started talking about Go. I was asked by Alex, their CEO, why I liked it. Several other people have asked me the same question recently, so I figured it was worth posting.

Goroutines

The first 1/2 of Go's concurrency story. Lightweight, concurrent function execution. You can spawn tons of these if needed and the Go runtime multiplexes them onto the configured number of CPUs/Threads as needed. They start with a super small stack that can grow (and shrink) via dynamic allocation (and freeing). They are as simple as go f(x), where f() is a function.

{
“window.zoomLevel”: 2,
“files.autoSave”: “onFocusChange”,
“editor.formatOnPaste”: true,
“editor.formatOnType”: true,
“editor.detectIndentation”: false,
“editor.minimap.enabled”: false,
“editor.fontLigatures”: true,
“editor.renderIndentGuides”: true,
“editor.renderWhitespace”: “boundary”,
@danielbh
danielbh / loading.js
Created July 30, 2017 12:37
containers/Panel/loading.js
import React from 'react';
import './index.css';
import ReactLoading from 'react-loading'
const PanelLoading = () => (
<div className="panel">
<ReactLoading className="loading-widget" type="bars" color="white" delay={0}/>
</div>
);
#!/bin/bash
yum update -y
yum install httpd24 -y
service httpd start
chkconfig httpd on
echo "<html><body><h1>Hello Cloud Gurus, this is X</h1></body></html>" > /var/www/html/index.html
#!/bin/bash
DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host_run/dbus/system_bus_socket npm start
while true
do
echo "App exited but container is still running to allow web terminal access"
sleep 3600
done
var Promise, app, async, bodyParser, closeHotspot, config, connectOrStartServer, connectionFile, connectionsFromFile, connman, dnsServer, execAsync, express, fs, getIptablesRules, hostapd, ignore, iptables, manageConnection, openHotspot, os, passphrase, port, retryAsync, saveToFile, server, setupHostapd, setupUdhcpd, spawn, ssid, ssidList, startServer, systemd, udhcpd;
Promise = require('bluebird');
connman = Promise.promisifyAll(require('connman-simplified-resin')());
express = require('express');
app = express();
FROM resin/raspberrypi3-debian:jessie
ENV INITSYSTEM on
# Add the key for foundation repository
RUN apt-get update
RUN apt-get install -y wget
RUN wget http://archive.raspberrypi.org/debian/raspberrypi.gpg.key -O - | sudo apt-key add -
# Add apt source of the foundation repository