Skip to content

Instantly share code, notes, and snippets.

View Adamantish's full-sized avatar

Adam Misrahi Adamantish

View GitHub Profile
from math import floor, ceil, log
from typing import Tuple, List
class AppendOnlyList:
"""
Seemed too boring to make something that copies all and reallocates each time it needs expanding.
This is more like an array of pointers to arrays.
"""
size = 0
@Adamantish
Adamantish / digi_7_segment_word.rb
Last active March 14, 2019 11:51
This sounded like a cute, simple task. https://www.youtube.com/watch?v=zp4BMR88260 . Avoiding regex to showoff ruby expressivity
# frozen_string_literal: true
require 'set'
BAD_LETTERS = 'gkmqvwxz'
WORD_LIST_PATH = '/my_path/words_alpha.txt' # Found at https://github.com/dwyl/english-words/blob/master/words_alpha.txt
BAD_LETTERS_SET = BAD_LETTERS.split.to_set
WORD_LIST = File.new(WORD_LIST_PATH)
def word_check(word)
@Adamantish
Adamantish / chock_a_block.rb
Last active February 25, 2016 13:58
Consumes the https://www.stockfighter.io/ simulated market API if given non-expired account codes
require 'httparty'
require 'json'
# require 'yaml'
# dearest_secrets = YAML.load_file('my_dear_secrets.yml')
## Nothing really to be lost by publicly sharing this key
API_KEY = "2e5dd4767307806ae789ce47943c5e880a04fd9c"
@Adamantish
Adamantish / swerve.rb
Last active August 11, 2017 12:40
RTanque bot brain with some supporting classes
class Trig
def self.triangulate_position(my_position, target)
meridian_factor = target.heading < Math::PI ? 0.5000 : 1.500000
meridian = Math::PI * meridian_factor
angle = target.heading.radians - meridian
y_delta = Math::sin(angle.abs) * target.distance
x_delta = Math::cos(angle.abs) * target.distance