Skip to content

Instantly share code, notes, and snippets.

View tonyta's full-sized avatar

Tony Ta tonyta

View GitHub Profile
@tonyta
tonyta / DBC Phase 0 Week 4 - Creating a BoggleBoard Class.md
Last active January 1, 2016 08:49 — forked from dbc-challenges/0.2.1-boggle_class_from_methods.rb
DBC Phase 0 Week 4 - Creating a BoggleBoard Class
@tonyta
tonyta / challenge.md
Last active August 29, 2015 13:55
Project Euler Challenge

Project Euler Challenge

Project Euler is a collection of mathy problems that can be solved with simple algorithms implemented in a program. A lot of these problems can be solved using brute-force techniques while others require clever algorithms. Some of these problems could be solved with application of heavy mathmatical theorems, but I solved the first 25 with simple iternations, recursions, and a bit of cleverness, all using Ruby.

Along the way, I learned a ton about working with arrays, parsing with regex, opening files, writing unit-tests, and even built a little toolbox of frequently used utilities (a module containing methods such as is_prime?, get_divisors, and even one for converting numbers to written-out English words).

The best part is the feeling you get when figuring something out on your own. That "Aha!" moment is really, really rewarding!

Anyway, you all should check it out. It might look intimidating at first, but the first 25 can definitely be solved wi

@tonyta
tonyta / gist:9164378
Created February 23, 2014 00:00
800000000003600000070090200050007000000045700000100030001000068008500010090000400
800000000003600000070090200050007000000045700000100030001000068008500010090000400
@tonyta
tonyta / find_unique.rb
Created February 25, 2014 02:59
sudoku find unique
def find_uniques
(1..9).each do |set_num|
map_unique( get_grid(set_num) )
end
end
def map_unique(set)
last_mapping = 'hello'
loop do
(1..9).each do |value|
@tonyta
tonyta / anne_gram.rb
Created May 15, 2014 16:56
Anagrams with Anne
require 'benchmark/ips'
def anagram_tony?(str1, str2)
str1.chars.sort! == str2.chars.sort!
end
def anagram_enum?(str1, str2)
count = Hash.new {0}
str1.each_char {|char| count[char] += 1}
str2.each_char {|char| count[char] -= 1}
export PS1="\n ࿐࿓ \[\033[4;36m\]\u\[\033[m\] \[\033[2m\]\w\[\033[m\] \[\033[31m\]$(ruby -e 'print RUBY_VERSION')\[\033[m\] $(ruby -e "t=Time.now.hour-12;h=t<0?8+t/6*4:3-t/4;f=h==0?'5;':'';puts\"\033[#{f}31m#{'♥'*h+'♡'*(4-h)}\033[m\"")\[\033[m\]\n༼つ◕_◕༽つ "
@tonyta
tonyta / index.html
Created June 6, 2014 00:24
Southeast Asia
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<script type="text/javascript" src="http://d3js.org/topojson.v1.min.js"></script>
</head>
<body>
@tonyta
tonyta / _README.md
Last active November 10, 2019 13:09
Custom Prompt

My Custom Bash Prompt

terminal

I like that this adds a little color to and otherwise dull looking terminal window. From left to right, I'll describe what it includes:

  • a fun little alien
  • username
  • current directory
  • Ruby version (via rbenv... you'll have to change this if you use rvm)
  • Hearts that deplete throughout the day
@tonyta
tonyta / sunspot_sandbox.md
Last active August 29, 2015 14:05
Sunspot Sandbox

Sunspot Sandbox

This summarizes the things I learned about Sunspot searching while looking throught the source. I included links to specific parts of the source-code. Be sure to check that out if you are curious.

Setting up an Example Object

This Job model will be what the examples below are searching.

class Job < ActiveRecord::Base
  searchable do
    boolean :requires_expertise
    integer :state
 time :deadline_at