Skip to content

Instantly share code, notes, and snippets.

View descartez's full-sized avatar

Ryan Stong descartez

View GitHub Profile
from microbit import *
while True:
moisture = pin0.read_analog()
if button_a.is_pressed():
if moisture <= 1023 and moisture > 0:
display.scroll(moisture)
else:
display.show(Image.SAD)
sleep(5000)
@descartez
descartez / bullet-time.py
Created May 6, 2019 19:36
code club dueling game
# Add your Python code here. E.g.
from microbit import *
import random
playing = False
winner = "-"
min_time = 300
max_time = 700
while True:
@descartez
descartez / master.py
Last active February 28, 2019 22:39
tic tac toe with microbits
# Add your Python code here. E.g.
from microbit import *
import radio
nodes = ["00","01","02","10","11","12","20","21","22"]
board = [
["","",""],
["","",""],
["","",""]
]
@descartez
descartez / The Technical Interview Cheat Sheet.md
Last active August 16, 2017 16:24 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

Array

Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
def multiples_up_to(multiple, limit)
# Rather than calculate every number and evaluate whether that number is a multiple, there's a handy bit of math I found that checks how many multiples are in any number of integers.
# We then keep adding up the "multiple", doing basic arithmetic until we reach the limit
start = 0
((limit - multiple + 1)/multiple).times do
start += multiple
p start
end
end
class String
# Opens up string class, to allow these methonds to be called directly on the string rather than passed as a variable to a method.
def rev_string
# Splits the string into an array, for iterative purposes
str_arr = self.chars
# Builds a temporary array
tmp_arr = []
str_arr.length.times do
# grabs the end of the str_array, and makes it the first of our new array
tmp_arr << str_arr.pop
require "test/unit"
class ListTester < Test::Unit::TestCase
def test_node_integrity
node = Node.new(1)
assert_equal(1,node.value)
assert_equal(nil,node.next_node)
assert_equal(nil,node.previous_node)
end
@descartez
descartez / rails_activerecord_cheatsheet.md
Last active September 3, 2015 17:04 — forked from amejiarosario/rails_activerecord_cheatsheet.md
Rails ActiveRecord (association) - Cheatsheet

Rails ActiveRecord (association) - Cheatsheet

http://guides.rubyonrails.org/association_basics.html

Types of associations

  • belongs_to : TABLE_NAME
  • has_one : TABLE_NAME [:through => :TABLE_NAME]
  • has_many : TABLE_NAME [:through => :TABLE_NAME]
  • has_and_belongs_to_many : TABLE_NAME [:join_table => :TABLE_NAME]