Skip to content

Instantly share code, notes, and snippets.

View doughsay's full-sized avatar
⌨️
clickety clack

Chris Dosé doughsay

⌨️
clickety clack
View GitHub Profile
@doughsay
doughsay / .gitconfig
Created March 14, 2019 02:03
git aliases
[alias]
up = "!git remote update -p; git merge --ff-only @{u}"
mup = "!git checkout master; git up"
u="!git merge --ff-only @{u}"
del = "!git-rm-merged"
clean-branches="!git_clean_branches"
@doughsay
doughsay / results.md
Last active June 28, 2018 04:20
ical occurrences benchmarks

Generating the first 1000 occurrences of the following icalendar recurrence rule:

DTSTART:19970101T123000
RRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,WE,FR

i.e.: Starting on 1997-01-01 12:30:00, every other week on Mondays, Wednesdays and Fridays.

Cocktail:

@doughsay
doughsay / lc-practice.py
Created January 7, 2018 02:58
Python List Comprehension Practice Problems
def identity(nums):
"""Identity:
Given a list of numbers, write a list comprehension that produces a copy of the list.
>>> identity([1, 2, 3, 4, 5])
[1, 2, 3, 4, 5]
>>> identity([])
[]
@doughsay
doughsay / index.js
Last active December 21, 2017 04:58
node.js event based game loop
const bigInt = require('big-integer')
function getCurrentMonoTime () {
const [s, n] = process.hrtime()
return bigInt(s).times(1000000000).plus(n)
}
const bootGameTime = 0
const bootMonoTime = getCurrentMonoTime()
@doughsay
doughsay / echo_server.cr
Created August 4, 2017 03:51
Crystal Echo Server
require "socket"
def handle_connection(socket, client_id)
puts "#{client_id}: client connected"
loop do
message = socket.gets
if message
puts "#{client_id}: received #{message}"
socket << message + "\n"
else
@doughsay
doughsay / 2d-case.txt
Created July 23, 2017 22:28
Chunk meshing algorithm
for each y going from -1 to MAX_Y:
for each x going from -1 to MAX_X:
if (x, y) is air:
if (x, y + 1) is NOT air:
draw a south facing wall at (x, y + 1)
if (x + 1, y) is NOT air:
draw a west facing wall at (x + 1, y)
else:
if (x, y + 1) IS air:
draw a north facing wall at (x, y)
@doughsay
doughsay / buffer-test.cr
Created July 7, 2017 06:29
Crystal OpenGL type safety test
# gotta have an opengl context to do the below...
require "lib_glfw"
LibGLFW.init
LibGLFW.window_hint LibGLFW::CONTEXT_VERSION_MAJOR, 3
LibGLFW.window_hint LibGLFW::CONTEXT_VERSION_MINOR, 3
LibGLFW.window_hint LibGLFW::OPENGL_FORWARD_COMPAT, 1
LibGLFW.window_hint LibGLFW::OPENGL_PROFILE, LibGLFW::OPENGL_CORE_PROFILE
window = LibGLFW.create_window 800, 600, "foo", nil, nil
@doughsay
doughsay / dotenv
Last active September 20, 2016 23:20
Dotenv bash helpers
#!/bin/bash
export DOTENV_ENV=${DOTENV_ENV:-dev}
GIT_DIR=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
DOTENV_FILE=$GIT_DIR/.env.$DOTENV_ENV
if [ -e $DOTENV_FILE ]; then source $DOTENV_FILE; fi
$@

Keybase proof

I hereby claim:

  • I am doughsay on github.
  • I am doughsay (https://keybase.io/doughsay) on keybase.
  • I have a public key ASDJDoHmARusPsAkDmvXxZvftA_sVBmE1tfZ3FURQUb59Qo

To claim this, I am signing this object:

@doughsay
doughsay / example_usage.rb
Last active August 29, 2015 14:22
Mongoid serialization and deserialization of Virtus value objects
class Bar
include Virtus::ValueObject
include Virtus::ValueObject::Mongoize
values do
attribute :bar, String
end
end
class Foo