Skip to content

Instantly share code, notes, and snippets.

View Solnse's full-sized avatar

Chad Solnse

View GitHub Profile
elsif word.include?("qu") #word contains 'qu'.
if word[0..1].include?("qu") #word begins with 'qu'.
result << word[2..-1] + word[0..1] + "ay"
else #'qu' is somewhere else in the word.
position = word.index("qu")
result << word[0..position] + "qu" + word[(position + 2)..-1] + "ay"
end
def translate(word)
word_list = word.split(/ /)
letters = ('a'..'z').to_a
vowels = ['a', 'e', 'i', 'o', 'u']
consonants = letters - vowels
result = ""
word_list.each do |word|
if vowels.include?(word[0]) #translate word beginning with vowels.
result << word + "ay"
def translate(word)
word_list = word.split(/ /)
letters = ('a'..'z').to_a
vowels = ['a', 'e', 'i', 'o', 'u']
consonants = letters - vowels
result = ""
word_list.each do |word|
if word.include?("qu") #word contains 'qu'.
if word[0..1].include?("qu") #word begins with 'qu'.
@Solnse
Solnse / performance.rb
Last active December 11, 2015 00:28
basic performance calculator.
def measure(repeat = 1)
start_calc = 0
end_calc = 0
total_time = 0
repeat.times do
start_calc = Time.now
yield
end_calc = Time.now
total_time = total_time + (end_calc - start_calc)
end
@Solnse
Solnse / Gemfile.lock
Created January 23, 2013 19:43
lock file
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.11)
actionpack (= 3.2.11)
mail (~> 2.4.4)
actionpack (3.2.11)
activemodel (= 3.2.11)
activesupport (= 3.2.11)
builder (~> 3.0.0)
@Solnse
Solnse / cats_spec.rb
Created January 23, 2013 20:19
failure
require 'spec_helper'
describe "Cats" do
it "Has a homepage" do
visit "cats/home"
page.should have_content("About cats")
end
end
@Solnse
Solnse / chkdsk
Created February 16, 2013 04:18
currupt freeagent go drive
Checking file system on D:
The type of the file system is NTFS.
Volume label is FreeAgent Disk.
Unable to query LCN from VCN 0x5 for attribute of type 0x80.
The non resident attribute of type 0x80 is inconsistent. The valid data
length is 0x27c1c000, file size 0x27c1c000, and allocated length 0x4000.
The non resident attribute of type 0x80 is inconsistent. The valid data
length is 0x27c1c000, file size 0x4000, and allocated length 0x4000.
@Solnse
Solnse / form.html
Created July 31, 2013 05:45
post params?
<form name="aspnetForm" method="post" action="signIn.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">
<div>
<input type="hidden" name="hdnServer" id="hdnServer" value=".101" />
<input type="hidden" name="hdnSID" id="hdnSID" value="D8FE96CEB8E545B897D00212D0FF810B" />
<input type="hidden" name="hdnLangCode" id="hdnLangCode" value="en-US" />
<input type="hidden" name="hdnPOS" id="hdnPOS" value="US" />
<input type="hidden" name="hdnClient" id="hdnClient" value="108.185.16.157" />
<input type="hidden" name="hdnInactive" id="hdnInactive" value="false" />
<input type="hidden" name="hdnAccountNumber" id="hdnAccountNumber" value="" />
<input type="hidden" name="hdnAccountNumberE" id="hdnAccountNumberE" value="" />
# missing_number_spec.rb
# Suppose you have an array of 99 numbers. The array contains the digits 1 to 100 with one digit missing.
# Write four different algorithms to compute the missing number.
# Two of these should optimize for low storage and two of these should optimize for fast processing.
require 'rspec'
def missing_number params
sum_total = 5050
chad@zen:~/repos/cybercoders$ cat /home/chad/.rvm/gems/ruby-2.0.0-p247/bin/rspec
#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'rspec-core' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'