Skip to content

Instantly share code, notes, and snippets.

View missingno15's full-sized avatar

Kenneth Uy missingno15

  • Tokyo
  • 23:09 (UTC +09:00)
View GitHub Profile
@missingno15
missingno15 / gist:6505948
Created September 10, 2013 07:08
LRtHW PDF Exercise 40
cities = {'CA' => 'San Francisco',
'MI' => 'Detroit',
'FL' => 'Jacksonville'}
cities['NY'] = 'New York'
cities['OR'] = 'Portland'
def find_city(map, state)
if map.include? state
return map[state]
@missingno15
missingno15 / gist:6680426
Last active December 23, 2015 19:09
Recreating the famous Professor Oak Intro from the Pokémon games http://www.youtube.com/watch?v=6jqUMlyvhcU
# Recreating the famous Professor Oak Intro from Pokemon
# http://www.youtube.com/watch?v=6jqUMlyvhcU
# Asks the user for input based on their gender. Must reply with either
# "boy" or "girl" in lower case.
def gender
puts
puts "Now tell me. Are you a boy?\nOr are you a girl?"
@missingno15
missingno15 / gist:7349842
Last active December 27, 2015 15:39
Script to help study and understand conversions from binary to decimal or decimal to binary
puts
puts "Do CTRL+C at anytime to end the program.\nCoded by Kenneth Uy / missingno15"
#Option to study Binary→Decimal or Decimal→Binary
puts "\nPress 1 to study Binary→Decimal\nPress 2 to study Decimal→Binary"
print "> "; option = gets.chomp
#Checks to make sure that user input is only either 1 or 2
until option == "1" || option == "2"
puts "\nSorry! Invalid option! Please try again!"
@missingno15
missingno15 / 0.2.1-boggle_class_from_methods.rb
Last active August 29, 2015 13:55 — forked from dbc-challenges/0.2.1-boggle_class_from_methods.rb
phase 0 unit 2 week 1boggle class challenge
class BoggleBoard
attr_reader :board
def initialize(board)
@board = board
end
def create_word(*coords)
coords.map { |coord| board[coord.first][coord.last]}.join("")
end
@missingno15
missingno15 / 0_reuse_code.js
Created May 5, 2014 15:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@missingno15
missingno15 / rails_resources.md
Created May 5, 2014 15:25 — forked from jookyboi/rails_resources.md
Rails-related Gems and guides to accelerate your web project.

Gems

  • Bundler - Bundler maintains a consistent environment for ruby applications. It tracks an application's code and the rubygems it needs to run, so that an application will always have the exact gems (and versions) that it needs to run.
  • rabl - General ruby templating with json, bson, xml, plist and msgpack support
  • Thin - Very fast and lightweight Ruby web server
  • Unicorn - Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.
  • SimpleCov - SimpleCov is a code coverage analysis tool for Ruby 1.9.
  • Zeus - Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second.
  • [factory_girl](h
require 'csv'
require 'pry'
// external csv file has headers: name_eng, name_jpn, team
// EXAMPLE:
// name_jpn | name_eng | team
// 宮脇咲良 | Miyawaki Sakura | KIV
module Janken
module ModuleA
class ClassInsideModule
end
end
class ClassA
class ClassInsideClass
end
end
@missingno15
missingno15 / nothing_is_something.rb
Last active August 29, 2015 14:20
Code you can run which mimics the "external framework API" that Sandi Metz talks about in her BathRuby 2015 - Nothing is Something talk https://youtu.be/9lv2lBq6x4A
class Animal
DATABASE = [
{ id: 1, name: "Mockingbird" },
{ id: 2, name: "Pheasant" },
{ id: 3, name: "Duck" },
{ id: 4, name: "Platypus" },
{ id: 5, name: "Penguin" },
{ id: 6, name: "Peacock" },
{ id: 7, name: "Hummingbird" },
{ id: 8, name: "Owl" }
@missingno15
missingno15 / parse_album_id.rb
Created June 4, 2015 08:46
parse album ids from attachments
def parse_album_id(type, url)
if type == "photo"
album_id = url.split('/')[-2]
elsif type == "album"
album_id = url.split('/')[-1].split('?')[0]
else
raise "The type, \"#{type}\" is not supported, #{}"
end
end