Skip to content

Instantly share code, notes, and snippets.

This is a test file.
There are many like it.
But this test file is mine.
Displaying contents of files
% less filename.txt - writes the contents of a file onto the screen a page at a time
- Press the [space-bar] if you want to see another page
% head filename.txt - writes the first ten lines of a file to the screen.
% head -5 filename.txt - write the first five lines. The number 5 can be changed to display the desired number of lines.
% less filename.txt - displays the last 15 lines of a file
% grep - Searches file for pattern or word
@CliveIMPISA
CliveIMPISA / YAML_to_TSV.rb
Last active August 29, 2015 14:06
YAML_to_TSV.rb
#!/usr/bin/env ruby
require 'yaml'
# Reading file from command line input and declaration of variables
stu_info = YAML.load(File.read(ARGV[0]))
flag = false
keyarr = []
valuearr = []
wholevalue = []
@CliveIMPISA
CliveIMPISA / TSV_to_YAML.rb
Created September 27, 2014 13:29
TSV_to_YAML.rb
#!/usr/bin/env ruby
require 'yaml'
# Only runs if and argument is provided at the command prompt
if ARGV[0]
file = File.open(ARGV[0], 'r')
linelist = []
keyarr = []
valuearr = []
flag = false
@CliveIMPISA
CliveIMPISA / fiizzbuzz.rb
Created September 27, 2014 13:10
Shortest Ruby FizzBuzz Implementation
# Shortest FizzBuzz
def fizzbuzz(size)
1.upto size do |num|
yield num % 15 == 0 ? 'FizzBuzz' : num % 5 == 0 ? 'Buzz' : num % 3 == 0 ? 'Fizz' : num.to_s
end
end