Skip to content

Instantly share code, notes, and snippets.

View vikas95prasad's full-sized avatar
😎

Vikas Prasad vikas95prasad

😎
View GitHub Profile
@vikas95prasad
vikas95prasad / git_squash
Created January 21, 2022 08:18 — forked from dineshpanda/git_squash
Squash commits keeping commit messages
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
@vikas95prasad
vikas95prasad / questions.txt
Created December 17, 2021 09:45
10th-CBSE-CS-Assignments
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.
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
@vikas95prasad
vikas95prasad / elements.rb
Last active February 12, 2021 06:48
Element with left side smaller and right side greater in Ruby
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
@vikas95prasad
vikas95prasad / apt.ino
Created June 30, 2020 18:50
Automatic Page Turner Arduino Uno Code
#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);
@vikas95prasad
vikas95prasad / fire.ino
Created June 30, 2020 18:39
Fire Truck Arduino Uno code
/*------ Arduino Fire Fighting Robot Code----- */
// #include <Servo.h>
// Servo myservo;
// int pos = 0;
boolean fire = false;
/*-------defining Inputs------*/
"aggregations": {
"top_users": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": 72833,
"doc_count": 3,
"top_users_hits": {
"hits": {
@vikas95prasad
vikas95prasad / word_count.rb
Created January 20, 2019 18:56
Get word count of a file in ruby
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"
@vikas95prasad
vikas95prasad / ruby_flatten.rb
Created January 20, 2019 18:54
Ruby flatten method with recursive function
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