Skip to content

Instantly share code, notes, and snippets.

View Dowwie's full-sized avatar

Darin Gordon Dowwie

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name="viewport" />
<link rel="icon" href="data:,">
<title>String art</title>
<script type="text/javascript" src="jquery.min.js"></script>
<style>
html, body {
import collections
import math
import os
import cv2
import numpy as np
import time
MAX_LINES = 4000
N_PINS = 36*8
MIN_LOOP = 20 # To avoid getting stuck in a loop
@Dowwie
Dowwie / public-ip-address.md
Created April 17, 2023 14:10
Ways to get info public IP address

Find out ip address using CLI

wget -qO- icanhazip.com
wget -qO- ipecho.net/plain; echo
curl checkip.amazonaws.com     # ipv4
curl ifconfig.co               # ipv6
@Dowwie
Dowwie / tsrange.ex
Created February 8, 2023 13:16
Elixir Ecto tsrange type
defmodule My.Postgres.TsRange do
@moduledoc """
Wraps a `Postgrex.Range` and casts to a PostgreSQL `tsrange` type.
Works w/ecto 3.8.0, postgrex 0.16
"""
use Ecto.Type
alias Postgrex.Range
defstruct lower: nil,
@Dowwie
Dowwie / instructions.md
Created April 8, 2019 18:10 — forked from harding/instructions.md
Working With Multiple Repositories On GitHub

Working With Multiple Repositories On GitHub

Most projects on GitHub have a main repository that's the focal point of activity. For example, the Example organization has the Example.com repository:

https://github.com/example/example.com

Developers of Example.com typically call this the 'upstream' repository. We'll come back to it in a moment.

@Dowwie
Dowwie / letsencrypt_2018.md
Created June 21, 2018 14:46 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

[dependencies]
serde = "1.0.27"
serde_derive = "1.0.27"
serde_json = "1.0.9"
serde_yaml = "0.7.3"
diesel = { version = "1.1.1", features = ["postgres"] }
r2d2 = "0.8.2"
r2d2-diesel = "1.0.0"
@Dowwie
Dowwie / wtd_choices.py
Last active January 10, 2018 08:37
As of Python3.6, random.choices offers weighted choices
age_groups = [lambda: random.randint(18,25),
lambda: random.randint(25,40),
lambda: random.randint(40,90)]
age_group_probs = [.5, .3, .1]
def get_choices():
pop_choices = random.choices(age_groups, weights=age_group_probs, k=10)
population = list(map(lambda x: x(), pop_choices))
@Dowwie
Dowwie / bench_maplit_hash.rs
Last active January 8, 2018 17:48
bench_maplit_hash.rs
#![feature(test)]
extern crate test;
#[macro_use] extern crate bencher;
#[macro_use] extern crate maplit;
use test::Bencher;
use std::collections::HashSet;
fn test_maplit() -> HashSet<&'static str> {
@Dowwie
Dowwie / working_with_pg_time.py
Last active June 9, 2017 17:13
A Python implementation of Craig Kerstiens's blog post, "Working with Time"
"""
This is a python implementation of Craig Kerstiens blog post:
http://www.craigkerstiens.com/2017/06/08/working-with-time-in-postgres/
"""
from random import randint
import functools
from datetime import datetime
import numpy as np
from arrow import Arrow