Skip to content

Instantly share code, notes, and snippets.

View t0dd's full-sized avatar

Todd Mahoney t0dd

  • NWRECC
  • Boise, Idaho
View GitHub Profile
@t0dd
t0dd / musical_freq_calc
Created November 2, 2020 22:53
Ruby implementation of the Formula for calculating frequencies of musical notes
# given a musical note with a specific frequency (in Hz), how do to calculate the frequency of another note?
def note_freq_calc (base_frequency, number_of_steps_to_next_note)
frequency_of_note = base_frequency * 1.059463094359 ** number_of_steps_to_next_note
end
@t0dd
t0dd / Snake.as
Created December 22, 2017 16:34
Kinematics used to develop a snake sprite
package {
import Segment;
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import playerfiles.Player;
import playerfiles.Particle;
import flash.geom.Point;
@t0dd
t0dd / gosu_textinput
Created May 15, 2017 07:11
Gosu TextInput Example
# This example demonstrates the use of the TextInput functionality.
# One can tab through, or click into the text fields and change it's contents.
# At its most basic form, you only need to create a new TextInput instance and
# set the text_input attribute of your window to it. Until you set this
# attribute to nil again, the TextInput object will build a text that can be
# accessed via TextInput#text.
# The TextInput object also maintains the position of the caret as the index
# of the character that it's left to via the caret_pos attribute. Furthermore,
public class overFlow {
public static void main(String[] args) throws FileNotFoundException, IOException {
Map m1 = new HashMap();
try (BufferedReader br = new BufferedReader(new FileReader("file.txt"))) {
StringBuilder sb = new StringBuilder();
String line = br.readLine();
@t0dd
t0dd / gist:f9c28ac6b9aa034611a7
Created December 2, 2015 18:12
Renaming a branch locally and on Github
git branch -m old_branch new_branch # Rename branch locally
git push origin --delete :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@t0dd
t0dd / gist:fb731a4bb08ddf756b8a
Created December 2, 2015 18:09 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@t0dd
t0dd / objects.js
Created October 16, 2013 02:41
Exploring JS topics - Objects and Inheritance
/* =========== JavaScript Objects =================== */
//Prototypes & Inheritance
//Creates a custom prototype object using inherit()
var book = {
title: "",
author: "",
ISBN: null
};
var book1 = inherit(book); //book is prototype for book1
@t0dd
t0dd / quick_union.rb
Last active December 21, 2015 16:39
Ruby implementation of the quick-union algorithm
class QuickUnion
def initialize(n)
@id = Array.new(n) {|i| i}
end
def root(i)
while i != @id[i] do
i = @id[i]
end
@t0dd
t0dd / quick_find_union.rb
Last active December 21, 2015 16:08
My Ruby implementation of the Quick-Find/ Union algorithm
class QuickFindUnion
def initialize(n)
@id = Array.new(n) {|i| i}
end
def connected?(p, q)
puts @id[p] == @id[q]
end
@t0dd
t0dd / a_select
Created May 29, 2013 05:50
Using jQuery to select external & internal links using just attribute and css selectors
//Selecting all the external links of a page
$('a[href^="http://"]')
//Selecting all the internal links of a page
$('a:not(a[href^="http://"])')