Skip to content

Instantly share code, notes, and snippets.

View HParker's full-sized avatar
💭
🥦

Adam Hess HParker

💭
🥦
View GitHub Profile
@HParker
HParker / gist:62b060b982b4a428898d8aa11248dfa5
Last active July 1, 2021 03:48
Totally-Fine-Library.puzzlescript
title Totally Fine Library
author Adam Hess
homepage www.hparker.xyz
========
OBJECTS
========
Player
@HParker
HParker / polymorphic_mixed_id_types.rb
Last active June 2, 2021 01:50
Mixed typed polymorphic keys
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails", branch: "main"
@HParker
HParker / ruby_dup_optimization
Created March 17, 2021 22:32
Ruby dup optimization
⋊> ~/c/ruby on getlocal-of-same-object-becomes-dup ⨯ ./ruby --version 15:27:30
ruby 3.1.0dev (2021-03-17T21:17:37Z getlocal-of-same-o.. 383292776f) [x86_64-darwin19]
⋊> ~/c/ruby on getlocal-of-same-object-becomes-dup ⨯ /Users/hparker/.rbenv/shims/ruby --version 15:27:53
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
⋊> ~/c/ruby on getlocal-of-same-object-becomes-dup ⨯ benchmark-driver benchmark/repeated_local.rb -e ./ruby -e /Users/hparker/.rbenv/shims/ruby 15:27:55
Calculating -------------------------------------
./ruby /Users/hparker/.rbenv/shi
@HParker
HParker / reaction_time.c
Created June 25, 2020 15:58
little raylib example
#include <raylib.h>
#include <stdio.h>
#include <stdlib.h>
struct Target {
Vector2 position;
int size
};
@HParker
HParker / Look.cs
Created October 12, 2019 23:53
Simple "Can I see X" script for unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class looker : MonoBehaviour
{
[SerializeField] private GameObject target;
[SerializeField] private float viewAngle = 30f;
[SerializeField] public RaycastHit hit;
module SqlParser exposing (..)
import Parser exposing ((|.), (|=), Parser, Trailing(..), float, keyword, spaces, succeed, symbol)
import Set
type alias Query =
{ select : List SelectField
, from : String
}

Keybase proof

I hereby claim:

  • I am hparker on github.
  • I am hparker (https://keybase.io/hparker) on keybase.
  • I have a public key ASBiPFYaMqFUtiIFyB3ysinEdyiFWdF-MfyoOc1_-1uV3Ao

To claim this, I am signing this object:

@HParker
HParker / array-gc-stats.md
Created March 9, 2016 22:53
Ruby Array gc stats
x = []
10_000_000.times {
  x = x.concat([1])
}
p GC.stat
x = []
10_000_000.times {
@HParker
HParker / gist:8a2c88d604d3c2c3fd34
Created October 31, 2014 21:51
String operations in ruby
puts "double assignment:"
puts Benchmark.measure {
100_000_000.times { "abc" }
}
# double assignment:
# 9.320000 0.010000 9.330000 ( 9.316967)
puts "double comparisons:"
x = "a"
@HParker
HParker / gist:24ec9bae7b41c571cc0f
Last active August 29, 2015 14:07
Example Guard clause usage.

Good use of guard clauses

Avdi Grimm's book has a section on guard classuses showing a refactor from

# From
def log_reading(reading_or_readings)
  readings = Array(reading_or_readings)
  readings.each do |reading|
    puts "[Reading] %3.2f" % reading.to_f
  end
end