Skip to content

Instantly share code, notes, and snippets.

View Katzy's full-sized avatar

Scott Katz Katzy

View GitHub Profile
@Katzy
Katzy / textalyzer
Last active August 29, 2015 14:05
Textalyzer
require 'open-uri'
def textalyzer (string)
file_name = ARGV[0]
string = open(file_name).read
histogram(freq(count(str_char(sanitize(string)))))
return
end
@Katzy
Katzy / ROTN
Created August 22, 2014 01:54
ROTN
def rot_n(string, n)
rotn_ary = []
n = n % 26
n > 13 ? n2 = (26 - n) : n2 = n # n2 for numbers greater than 13
string.each_char do |char|
if char.ord < 65 || (char.ord > 90 && char.ord < 97) || char.ord > 122
rotn_ary.push(char)
elsif "z".ord - n >= char.downcase.ord && "z".ord - char.downcase.ord + n >= 26
rotn_ary.push((char.ord + n).chr)
else
@Katzy
Katzy / wall.rb
Last active August 29, 2015 14:05
Wall.rb
class Wall
include DataMapper::Resource
property :id, Serial
property :created_by, String
property :title, String
property :description, Text
property :likes, Integer
property :created_at, DateTime
end
require 'openssl'
require 'Base64'
def encryption(data)
cipher = OpenSSL::Cipher::AES.new(128, :CBC)
cipher.encrypt
key = cipher.random_key
iv = cipher.random_iv
@Katzy
Katzy / gist:d6f9f39161c56c90726c
Created September 22, 2014 20:08
example of feedback
68  week-03/to_roman.rb Show notes View
@@ -1,20 +1,62 @@
-# Method name: to_roman
-# Inputs: A number
-# Returns: A String representing the number in roman numerals
-# Prints: Nothing
+def to_roman(num)
-# to_roman takes a number as input and returns that number using Roman numerals
-# See http://en.wikipedia.org/wiki/Roman_numerals
@Katzy
Katzy / Tree
Created October 22, 2014 21:01
Pictr / rspec feature test issue
Sierras-MacBook-Air:pictr-rails Sierra$ tree
.
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── Gemfile
├── Gemfile.lock
├── LICENSE.md
├── README.md
├── README.rdoc
├── Rakefile
@Katzy
Katzy / input & output
Created October 22, 2014 21:11
Rspec issue / test doesn't run with this code
Sierras-MacBook-Air:pictr-rails Sierra$ rspec spec/features/user_account_spec.rb
/Users/Sierra/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `load': /Users/Sierra/code/pictr-rails/spec/features/user_account_spec.rb:18: syntax error, unexpected tIVAR, expecting keyword_do or '{' or '(' (SyntaxError)
...s?(email_address: scott@example.com)).to be_truthy
... ^
/Users/Sierra/code/pictr-rails/spec/features/user_account_spec.rb:18: syntax error, unexpected ')', expecting keyword_end
...ail_address: scott@example.com)).to be_truthy
... ^
from /Users/Sierra/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `block in load_spec_files'
from /Users/Sierra/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `each'
from /Users/Sierra/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.0.4/lib