Skip to content

Instantly share code, notes, and snippets.

Avatar

Sudipta Mondal sudiptamondal

View GitHub Profile
@sudiptamondal
sudiptamondal / Hoppr_interview_question.rb
Last active Dec 16, 2015
Scope: Many programming languages implement scope for variables – and they are context sensitive. For example a global scope variable will be over-ridden using local variable definition. You need to implement simple interpreter which tells us current value of a variable, if its not defined then value should be zero, Input will start with ‘[‘ and…
View Hoppr_interview_question.rb
puts "Enter your statements separated by a carriage return, The matching braces will terminate the loop"
variables = Hash.new(Hash.new)
opening_brackets = 0
closing_brackets = 0
while true
variable = nil
level = nil
value = nil
input = gets.chomp
@sudiptamondal
sudiptamondal / install_gem.sh
Created Jul 8, 2013 — forked from anonymous/install_gem.sh
Complementing a tutorial video with ruby code. Part 1. Installing ruby gem
View install_gem.sh
# Steps
# 1. Install the gem sinatra
gem install sinatra
# you you skip rdoc and ri using
# gem install sinatra --no-rdoc --no-ri
@sudiptamondal
sudiptamondal / hello_world.rb
Last active Dec 19, 2015
Complementing a tutorial video with ruby code. Part 2. Hello World
View hello_world.rb
# hello_world.rb
# This will manage routes and display the content.
# I am sure, you did watch the video before checking this out.
require "sinatra"
set :bind, '127.0.0.1'
set :port, '8080'
get '/hello/:name' do
@sudiptamondal
sudiptamondal / run_server.sh
Created Jul 8, 2013
Complementing a tutorial video with ruby code. Part 3. Running the code
View run_server.sh
# just simply run the ruby file that we created.
ruby hello_world.rb
@sudiptamondal
sudiptamondal / install_gem.sh
Last active Dec 19, 2015
MongoDB Class. Install mongo driver to connect with ruby source files. Part 1 - Install gem
View install_gem.sh
# Steps
# 1. Install the gem mongo
gem install mongo
gem install bson_ext
# bson_ext is for optimal performance of using mongodb.
# You can still use mongo without it.
# But then, it will throw a warning.
# you you skip rdoc and ri using
# gem install mongo --no-rdoc --no-ri
@sudiptamondal
sudiptamondal / magic_sort.rb
Last active Sep 14, 2015
A simple program to sort a list of number ranging 1-130 in ascending order
View magic_sort.rb
require 'benchmark'
def smarter_way(unsorted_array, size, sorted_array)
maggic_array = Array.new(130) {|i| i = ({ i => 0 }) }
unsorted_array.each do |num|
maggic_array.each do |hash|
if hash.keys.first == num
hash[num] = hash[num] + 1
end
end
View CreateNotif.java
private void createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel("1000111", "cld_notif_channel", NotificationManager.IMPORTANCE_DEFAULT);
channel.setDescription("cld_notif_desc");
NotificationManager notificationManager = getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel);
}
}
View CreateNotif.java
final NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "1000111")
.setContentTitle("Notification Title")
.setSmallIcon(R.drawable.ic_stat_name)
.setContentText("Notification Text")
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
View CreateNotif.java
final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
View CreateNotif.java
notificationManager.notify("1001", builder.build());
You can’t perform that action at this time.