Skip to content

Instantly share code, notes, and snippets.

View ajosanchez's full-sized avatar

Alex Sanchez ajosanchez

  • Walla Walla, WA
View GitHub Profile
@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
require 'sqlite3'
require 'active_record'
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => 'dbfile_example'
)
@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
@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
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 / dr.html
Created June 14, 2016 19:07
dynamic html in react
<div>
<form className="ui-filterable" id="searchbar">
<input id="inset-autocomplete-input" data-type="search" placeholder="Search foods..."></input>
</form>
<ul data-role="listview" data-inset="true" data-filter="true" data-filter-reveal="true" data-input="#inset-autocomplete-input">
{Object.keys(this.state.foods).forEach((food) => {
return (
<li><a href="#">food</a></li>
);
})}
<div>
<form className="ui-filterable" id="searchbar">
<input id="inset-autocomplete-input" data-type="search" placeholder="Search foods..."></input>
</form>
<ul data-role="listview" data-inset="true" data-filter="true" data-filter-reveal="true" data-input="#inset-autocomplete-input">
{Object.keys(this.state.foods).forEach((food) => {
return (
<li><a href="#">food</a></li>
);
})}
@ajosanchez
ajosanchez / dr.html
Created June 14, 2016 19:10
dynamic html with react
<div>
<form className="ui-filterable" id="searchbar">
<input id="inset-autocomplete-input" data-type="search" placeholder="Search foods..."></input>
</form>
<ul data-role="listview" data-inset="true" data-filter="true" data-filter-reveal="true" data-input="#inset-autocomplete-input">
{Object.keys(this.state.foods).forEach((food) => {
return (
<li><a href="#">food</a></li>
);
})}
def valid_word? word
letters = {
'e' => 12,
'a' => 9,
'i' => 9,
'o' => 8,
'n' => 6,
'r' => 6,
't' => 6,
'l' => 4,