This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def flatten(array) | |
flatten_arr = [] | |
array.each do |element| | |
if element.kind_of? Array | |
flatten_arr += flatten(element) | |
else | |
flatten_arr << element | |
end | |
end | |
flatten_arr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file = File.open("SampleTextFile_100kb.txt", "r") | |
words_print = {} | |
file.each_line do |line| | |
words = line.split | |
words.each do |word| | |
puts "previous word => #{word}" | |
word = word.downcase.gsub(/[,()'".]+\z/,'') | |
puts "afterwardsword" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"aggregations": { | |
"top_users": { | |
"doc_count_error_upper_bound": 0, | |
"sum_other_doc_count": 0, | |
"buckets": [ | |
{ | |
"key": 72833, | |
"doc_count": 3, | |
"top_users_hits": { | |
"hits": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*------ Arduino Fire Fighting Robot Code----- */ | |
// #include <Servo.h> | |
// Servo myservo; | |
// int pos = 0; | |
boolean fire = false; | |
/*-------defining Inputs------*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Stepper.h> | |
//Declare variables and assign pin number | |
int in1Pin = 8; | |
int in2Pin = 9; | |
int in3Pin = 10; | |
int in4Pin = 11; | |
const int stepsPerRevolution = 2048;// Update the number of steps per revolution required for your motor | |
// Create a stepper object | |
// Note: We are using 28BYJ-48 5VDC Stepper Motor, for this motor, we need to set wiring sequence to (1-3-2-4) instead of (1-2-3-4) | |
Stepper motor(stepsPerRevolution, in1Pin, in3Pin, in2Pin, in4Pin); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arr = [1,2,10,43,20,80,90] | |
maxArr = [] | |
minArr = [] | |
solution = [] # | |
large = arr[0] #first element | |
small = arr[-1] #last element | |
arr.each_with_index do |num, index| | |
if arr[index] > large |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/routes.rb | |
resources :documents do | |
scope module: 'documents' do | |
resources :versions do | |
post :restore, on: :member | |
end | |
resource :lock | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.Write a program to input a welcome message and print it. | |
2.Program to obtain three number and print their sum. | |
3.program to obtain length and breadth of a rectangle and calculate its area. | |
4.write a program to input a number and print its cube. | |
5.write a program to input two numbers and swap them. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git reset --soft HEAD~n && git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})" | |
* n is the number of commits you want to squash from HEAD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.youtube.com/watch?v=kZcqyuPeDao | |
https://gist.github.com/nateberkopec/2b1f585046adad9a55e7058c941d3850 | |
https://www.speedshop.co/2015/07/15/the-complete-guide-to-rails-caching.html | |
https://www.railsspeed.com/ | |
https://www.speedshop.co/2015/07/29/scaling-ruby-apps-to-1000-rpm.html | |
https://www.speedshop.co/2015/10/07/frontend-performance-chrome-timeline.html | |
https://github.com/ruby-prof/ruby-prof | |
https://github.com/schneems/get_process_mem | |
https://github.com/ko1/allocation_tracer | |
https://github.com/evanphx/benchmark-ips |