Skip to content

Instantly share code, notes, and snippets.

View ptdorf's full-sized avatar

Peter Wilmersdorf ptdorf

View GitHub Profile
@ptdorf
ptdorf / README.md
Created March 26, 2024 10:51 — forked from bmcculley/README.md
A Go embed example of serving static files at the root URL path.
@ptdorf
ptdorf / uuid-vs-sha1.rb
Created July 16, 2023 13:10 — forked from pd/uuid-vs-sha1.rb
UUID v5 vs SHA1 hexdigest
require 'json-schema'
require 'digest/sha1'
require 'benchmark'
N = 5000
SCHEMAS = Dir['test/schemas/*.json'].map { |f| File.read(f) }
Benchmark.bmbm do |x|
x.report('v5') do
N.times do
@ptdorf
ptdorf / echo-server.yml
Created September 3, 2020 11:50 — forked from chukaofili/echo-server.yml
Echo Server Deployment
apiVersion: v1
kind: Namespace
metadata:
name: echoserver
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: echoserver
namespace: echoserver
@ptdorf
ptdorf / example_local_file.tf
Created November 2, 2019 20:28 — forked from arnobroekhof/example_local_file.tf
Terraform 0.11.x loop through a map and create files with content based on a maps --> key, value
variable "object_list" {
type = "map"
default = {
content1 = "this is example content 1",
content2 = "this is example content 2"
}
}
resource "local_file" "local_files" {
count = "${length(var.object_list)}" # perform this action based on the amount of items in the map
@ptdorf
ptdorf / gh-pages-deploy.md
Created August 2, 2017 19:58 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

site :opscode
cookbook 'apt'
cookbook 'nginx'
metadata
@ptdorf
ptdorf / server.sh
Created April 15, 2017 00:47 — forked from justecorruptio/server.sh
Bash www server. Golfed from github.com/jaburns/ngincat
#!/bin/bash
:|((read f g h
[[ -f .$g&&$g != *..* ]]&&echo "$h 200 OK
"&&cat .$g)|nc -lp$1)>/dev/fd/0;$0 $1
@ptdorf
ptdorf / 2048.c
Created April 15, 2017 00:46 — forked from justecorruptio/2048.c
Tiny 2048 in C!
M[16],X=16,W,k;main(){T(system("stty cbreak")
);puts(W&1?"WIN":"LOSE");}K[]={2,3,1};s(f,d,i
,j,l,P){for(i=4;i--;)for(j=k=l=0;k<4;)j<4?P=M
[w(d,i,j++)],W|=P>>11,l*P&&(f?M[w(d,i,k)]=l<<
(l==P):0,k++),l=l?P?l-P?P:0:l:P:(f?M[w(d,i,k)
]=l:0,++k,W|=2*!l,l=0);}w(d,i,j){return d?w(d
-1,j,3-i):4*i+j;}T(i){for(i=X+rand()%X;M[i%X]
*i;i--);i?M[i%X]=2<<rand()%2:0;for(W=i=0;i<4;
)s(0,i++);for(i=X,puts("\e[2J\e[H");i--;i%4||
puts(""))printf(M[i]?"%4d|":" |",M[i]);W-2