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 / 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".
*/
@boddhisattva
boddhisattva / RubyTest.sublime-settings
Created May 17, 2015 07:14
Setting up RubyTest package to work with Sublime Text 3 in order to run your specs from within the editor
{
"check_for_rvm": true
}
@boddhisattva
boddhisattva / getting_started.md
Last active April 28, 2023 23:16
Writing a spec from scratch for a plain ruby script(no rails) using TDD

Steps -

  • Create the filename.rb file for which you’d like to create a filename_spec.rb
  • Run the command rspec --init from the same working directory as to where you have filename.rb
  • the above command will create a .rspec file for you
  • It will create a new spec directory within which you need to place your specs
  • It will create spec_helper.rb where you need continually require the ruby files that you would want to write specs for
  • Create the filename_spec.rb within the spec directory
  • [optional] Edit the .rspec file to add the option: --format documentation
  • The above addition gives your running tests more readability as to what they do or what they stand for when they are run.
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')