- Roman Numerals Kata
- Things that I applied or learnt along the journey that led to the final solution -
- Approach the problem in small steps. I was solving this kata for the first time, I didn't know of any pattern whatsoever initially,
hence took this problem, one step at a time and it eventually helped me get to solution. Often times one worries about the end solution or just the destination, without traveling the journey bit by bit.
- I know you may think this approach(solving for one test at a time as done in this commit and this one) wouldn't give you the desired solution that'll satisfy all cases, but trust me it will help you eventually get there. That's why this approach is worth it.
- Used the older hash syntax in ruby s
- Learnt how to use
count
witheach_with_index
- This helped me do away with the temp variable
distance
that I had used as a counter.
- This helped me do away with the temp variable
Before - Uses a temp variable called distance
as a counter
class Hamming
VERSION = 1
2.3.0 :001 > require "benchmark/ips" | |
=> true | |
2.3.0 :002 > class Fixnum | |
2.3.0 :003?> VERSION = 1 | |
ROMAN_NUMERALS = { 'M' => 1000, | |
'CM' => 900, | |
'D' => 500, | |
'CD' => 400, | |
'C' => 100, |
require "benchmark/ips" | |
Benchmark.ips do |x| | |
x.report("fast code description") { 38.to_roman_fast} | |
x.report("slow code description") { 38.to_roman_slow } | |
x.compare! | |
end |
Elixir syntax highlighting example
list = [1, 2, 3]
[a, b, c] = list
def foo do
IO.puts "foo"
end
A lot of these are outright stolen from Edward O'Campo-Gooding's list of questions. I really like his list.
I'm having some trouble paring this down to a manageable list of questions -- I realistically want to know all of these things before starting to work at a company, but it's a lot to ask all at once. My current game plan is to pick 6 before an interview and ask those.
I'd love comments and suggestions about any of these.
I've found questions like "do you have smart people? Can I learn a lot at your company?" to be basically totally useless -- everybody will say "yeah, definitely!" and it's hard to learn anything from them. So I'm trying to make all of these questions pretty concrete -- if a team doesn't have an issue tracker, they don't have an issue tracker.
I'm also mostly not asking about principles, but the way things are -- not "do you think code review is important?", but "Does all code get reviewed?".
puts "hi"
a = [4,3,2]
a.each do |each_argument|
puts each_argument
end
If you're getting the error(see the image below) - Bad wkhtmltopdf's path: /usr/bin/wkhtmltopdf
when using the wkhtmltopdf
gem in your rails app to convert an HTML page to a PDF file. Following the below steps should help you get it working on your machine -
- We need to first locate the bin file that converts HTML to pdf. This usually is present inside your
wkhtmltopdf
gem. For me this was located at -/Users/my_user_name/.rvm/gems/ruby-2.1.2@gemset_name/gems/wkhtmltopdf-0.1.2/bin
- If you're using a mac, you'd need the
darwin
version of the bin file. Do asudo cp wkhtmltopdf_darwin_386 /usr/bin/wkhtmltopdf
.- This copies the bin from within the gem directory to the location where all local system bin files are generally present.
- Please note: If you're using the another OS, you'd need to copy the appropriate bin file wrt the OS that you're using.
SE No | Command | Action |
---|---|---|
1 | cmd + option + down arrow | Go to Definition(a new feature in ST3) |
2 | cmd + ctrl + g | Select all occurrences of a word within a file at once |
3 | cmd + d | Selects the next occurence of the same word |
4 | Hold cmd key and click on multiple lines to get multiple cursors | Allows for editing multiple things at a time |
5 | cmd + ctrl + p | Open a project(once saved via Project(Prj) -> Save Prj as) |
6 | cmd + ] | Indents the highlighted code towards the right |
7 | cmd + [ | Indents the highlighted code towards the left |
8 | cmd + r | Search for a method |
/* Abbreviations used : | |
L - Learning */ | |
Question on hand - | |
/* | |
If computerChoice is between 0 and 0.33, make computerChoice equal to "rock". | |
If computerChoice is between 0.34 and 0.66, make computerChoice equal to "paper". | |
If computerChoice is between 0.67 and 1, make computerChoice equal to "scissors". | |
*/ |