Skip to content

Instantly share code, notes, and snippets.

View geowa4's full-sized avatar
🏠
Working from home

George Adams geowa4

🏠
Working from home
View GitHub Profile
@geowa4
geowa4 / main.go
Created October 26, 2018 01:39
Merge Sort in Go
package main
import (
"fmt"
"math/rand"
)
func fill(size int) []int {
slice := make([]int, 0, size)
for i := 0; i < size; i++ {
@geowa4
geowa4 / tour_of_go_web_crawler.go
Created September 2, 2018 03:05
My solution to the Tour of Go Web Crawler (Hint: read the sync package docs at https://golang.org/pkg/sync/.)
package main
import (
"fmt"
"sync"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
@geowa4
geowa4 / digitalocean.sh
Last active March 12, 2019 09:30
Dynamic inventory for DigitalOcean grouping by tag.
#!/usr/bin/env bash
set \
-o nounset \
-o pipefail \
-o errexit
tags=$(doctl compute tag list --output json | jq -r '.[].name')
aggregate=$(jq -n '{ "_meta": { "hostvars": { } } }')
#!/usr/bin/env bash
set \
-o nounset \
-o pipefail \
-o errexit \
-o errtrace \
-o verbose \
-o xtrace
# Create users table and apply indices.
class CreateUsers < ActiveRecord::Migration[5.0]
def change
create_table :users, force: true, id: false, primary_key: 'id' do |t|
t.binary :id, default: 'uuid_v4()'
t.string :login, null: false
t.string :email, null: false
end
add_index :users, :login, unique: true
add_index :users, :email, unique: true
@geowa4
geowa4 / input
Created September 16, 2016 17:36
Find the word with the most repeated characters.
O Romeo, Romeo, wherefore art thou Romeo?
Some people feel the rain, while others just get wet.
ffff ----- '''''' D'd-d'-dd'-dd-' d'd-d'-dd'-dd-'
- name: create load balancer
ec2_elb_lb:
name: '{{ application }}-{{ item.name }}-elb'
region: '{{ region }}'
connection_draining_timeout: 60
cross_az_load_balancing: yes
health_check:
ping_protocol: http
ping_port: 80
ping_path: '{{ item.elb_ping_path|default("/") }}'
- name: create load balancer
ec2_elb_lb:
name: '{{ application }}-{{ item.name }}-elb'
region: '{{ region }}'
connection_draining_timeout: 60
cross_az_load_balancing: yes
health_check:
ping_protocol: http
ping_port: 80
ping_path: '{{ item.elb_ping_path|default("/") }}'
bluetooth.lookup_name('10:53:2F:CA:FC:58')
@geowa4
geowa4 / discover.py
Created March 14, 2016 04:05
Discover Bluetooth addresses.
import bluetooth
nearby_devices = bluetooth.discover_devices(
duration=8, lookup_names=True, flush_cache=True, lookup_class=False
)
for addr, name in nearby_devices:
print("%s - %s" % (addr, name))