Skip to content

Instantly share code, notes, and snippets.

View boddhisattva's full-sized avatar
🌷
Vasudhaiva Kutumbakam 🙂

Mohnish G J boddhisattva

🌷
Vasudhaiva Kutumbakam 🙂
View GitHub Profile
@boddhisattva
boddhisattva / roman_numerals_kata_learnings.md
Last active April 10, 2016 13:55
Learnings along the way of completing the Roman Numerals Kata via Exercism
  • 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
@boddhisattva
boddhisattva / hamming_learnings.md
Last active May 31, 2016 01:03
Learnings from solving the Hamming exercise on Exercism(exercism.io)

Hamming Exercise

  • Learnt how to use count with each_with_index
    • This helped me do away with the temp variable distance that I had used as a counter.

Before - Uses a temp variable called distance as a counter

class Hamming
  VERSION = 1
@boddhisattva
boddhisattva / comp_results_via_irb.rb
Created March 31, 2016 01:56
Roman numerals - comparing two implementations
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,
@boddhisattva
boddhisattva / benchmarking_code.rb
Last active March 25, 2016 10:50
Ruby the usage of to_s within a loop by using old hash syntax wrt the constant
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
@boddhisattva
boddhisattva / elixir-syntax-highlighting-support-example.md
Last active September 29, 2018 09:54
How to highlight elixir code in your markdown files - an example

Elixir syntax highlighting example

 list = [1, 2, 3]
 [a, b, c] =  list
 
 def foo do
   IO.puts "foo"
 end
@boddhisattva
boddhisattva / interview-questions.md
Created January 25, 2016 11:20 — forked from jvns/interview-questions.md
A list of questions you could ask while interviewing

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?".

@boddhisattva
boddhisattva / sample_markdown_file.md
Last active August 27, 2015 11:36
A sample markdown file to help explain the advantages of using markdown syntax
puts "hi"

a = [4,3,2]

a.each do |each_argument|
  puts each_argument
end
@boddhisattva
boddhisattva / wkhtmltopdf_path_error.md
Last active August 29, 2015 14:27
Fix for Bad wkhtmltopdf's path: /usr/bin/wkhtmltopdf error that comes when using wkhtmltopdf gem

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 -

Bad wkhtmltopdf's path: /usr/bin/wkhtmltopdf

  • 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 a sudo 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.
@boddhisattva
boddhisattva / sublime_text3_shortcuts.md
Last active February 9, 2020 05:46
Sublime Text 3(ST3) shortcuts for Mac OSX that I use as part of my daily workflow
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".
*/