I hereby claim:
- I am mistrikushal on github.
- I am kmistryrubydev (https://keybase.io/kmistryrubydev) on keybase.
- I have a public key ASB4wGyJe6ayMnPZYlV9wftlxJeiSXZmo6ot6Q_cJ9INJAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| # heroku pg restore from first app | |
| $ heroku pg:backups:capture --app sushi | |
| # download the backup (optional) | |
| $ heroku pg:backups:url b001 --app sushi | |
| # in above command b001 is the ID of a backup which will be displayed on terminal once backup is done | |
| # check the backup information | |
| $ heroku pg:backups:info b017 --app sushi |
| COMMANDS = ['DEPEND', 'INSTALL', 'REMOVE', 'LIST'] | |
| @component_dependencies = Hash.new | |
| @installed_components = Array.new | |
| def validate_command(command) | |
| command_size = command.size | |
| command_name = command.split(' ').first | |
| return false unless COMMANDS.include?(command_name) | |
| return false if command_name != command_name.upcase |
| # Create a CSV in Write Mode | |
| CSV.open("#{Rails.public_path}/file_name.csv", 'wb') do |csv| | |
| # Add a first row into CSV which is column names | |
| csv << ['First name', 'Last name', 'Email'] | |
| end | |
| # Now we have CSV file created in the public directory of the rails application and also it has columns ready | |
| # Now Let's add some data into it. please note that the data in each cell of the row should be in order with the columns defined. |
| require 'time' | |
| require 'rubygems' | |
| def calc_time_diff(current_time, end_time, end_time2=nil) | |
| parsed_end_time = Time.parse(end_time) | |
| parsed_current_time = Time.parse(current_time) | |
| result = Hash.new | |
| if parsed_end_time < parsed_current_time | |
| secs_diff = (parsed_current_time - parsed_end_time).to_i.abs |
| Verifying that "kushalmistri.id" is my Blockstack ID. https://onename.com/kushalmistri |
| # perform multiplication on 'a' and 'b' without using X operator | |
| def mul(a, b) | |
| x = 0 | |
| b.times do | |
| x = x + a | |
| end | |
| puts "Multiplication of #{a.to_s} X #{b.to_s} = #{x.to_s}" | |
| end |
| # logic to check longest word from a string | |
| str = 'this string contains a looooooong word' | |
| longest_word = str.split(' ').max_by(&:length) | |
| puts "Longest word of the string is: #{longest_word}" |
| # check first non-repeating element from array | |
| arr = [1,200,1,200,3,4,5] | |
| res = Array.new | |
| arr.detect{|e| res << e unless(arr.count(e) > 1) } | |
| puts "First non-repeated element in Array"+arr.to_s+" is : "+ res.first.to_s | |
| # check even times repeating elements in array | |
| a = [5, 3, 5, 1, 5, 1, 3] | |
| res_arr = Array.new |
| to create a .zip of a directory using bash shell, | |
| $ zip -r filename.zip directory_path_to_zip |