Skip to content

Instantly share code, notes, and snippets.

View ajosanchez's full-sized avatar

Alex Sanchez ajosanchez

  • Walla Walla, WA
View GitHub Profile
require 'socket' # Get sockets from stdlib
require 'json'
require 'active_support/all'
require 'active_record'
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => 'project_db'
require 'socket' # Get sockets from stdlib
require 'json'
require 'active_support/all'
require 'active_record'
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => 'project_db'
@ajosanchez
ajosanchez / app.rb
Created December 2, 2015 02:42
simple api with Sinatra
#!/usr/bin/env/ ruby
require_relative('fp')
require 'sinatra'
require 'json'
t = FlightTracker.new
get '/' do
@ajosanchez
ajosanchez / FO4_terminal_hack.rb
Last active December 16, 2020 13:11
This will help you crack those tricky terminals in the Fallout series. Just run this ruby script and enter each word separated only with a slash and no spaces (ex: kid/cat/pop/dog). It will display each words' total matches minus any words that had no matches. Then once you guess enter in the guess word with the likeness returned from the termin…
class Hack
def initialize words
@words = words.downcase.split(/\/|\s|,\s|\,/)
@splitwords = []
@words.each { |w| @splitwords << w.split('') }
show_likely
end
def deduct
require 'sqlite3'
require 'active_record'
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => 'dbfile_example'
)
@ajosanchez
ajosanchez / cashiers.rb
Created October 16, 2015 00:06
cashiers helping a line of customers
def all_times employees
employees.collect {|employee| employee[:time_working]}
end
def helped_by cust_num, employees
employees.each do |employee|
if employee[:cust_helped].include? cust_num
puts "#{employee[:name].capitalize} helped customer ##{cust_num}."
puts "\n"
end