Skip to content

Instantly share code, notes, and snippets.

Avatar

raghu bhupatiraju raghuvarmabh

View GitHub Profile
@raghuvarmabh
raghuvarmabh / restaurant.rb
Created Jul 10, 2018
Bare minimum rails project to experiment on models
View restaurant.rb
# Instead of loading all of Rails, load the
# particular Rails dependencies we need
require 'sqlite3'
require 'active_record'
require 'pry'
# Set up a database that resides in RAM
ActiveRecord::Base.establish_connection(
adapter: 'sqlite3',
database: ':memory:'
View generate document from google sheets
function onOpen() {
var ui = SpreadsheetApp.getUi();
// Or DocumentApp or FormApp.
ui.createMenu('XYZ Menu')
.addItem('Generate PO', 'createDcument')
.addToUi();
}
function createDcument() {
var activeSheet = SpreadsheetApp.getActiveSpreadsheet();
View joel coding challenge.patch
From 98e66e960491f10d543686211b30c3c6a8d61192 Mon Sep 17 00:00:00 2001
From: ydarbleoj <brady.joel@gmail.com>
Date: Tue, 16 Oct 2018 15:11:17 -0700
Subject: [PATCH 1/4] Added event model and migration
---
app/models/event.rb | 3 +++
db/migrate/20181016215050_create_events.rb | 11 +++++++++++
db/schema.rb | 10 +++++++++-
test/fixtures/events.yml | 13 +++++++++++++
View erik coding challenge.patch
From 43bbfa63f3efa6b10abcd7454d2953cb37b9efc9 Mon Sep 17 00:00:00 2001
From: Raghu <raghuvarma.bhr@gmail.com>
Date: Mon, 15 Oct 2018 15:34:18 -0700
Subject: [PATCH 1/2] Code challenge
---
vue-spa/src/App.vue | 14 ++++++++++++--
vue-spa/src/components/TrackableEvent.vue | 17 +++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
create mode 100644 vue-spa/src/components/TrackableEvent.vue
View alex coding challenge.patch
diff --git a/app/models/provider.rb b/app/models/provider.rb
index c468731..d4afb3a 100644
--- a/app/models/provider.rb
+++ b/app/models/provider.rb
@@ -1,3 +1,4 @@
class Provider < ApplicationRecord
has_many :customers, as: :company
+ has_many :tracking_events
end
diff --git a/app/models/shipper.rb b/app/models/shipper.rb
@raghuvarmabh
raghuvarmabh / gist:9a68edddbd78f37fc9f5dfed9d2ad711
Last active Aug 8, 2019
Multi Threading synchronization example
View gist:9a68edddbd78f37fc9f5dfed9d2ad711
import java.util.Arrays;
public class SyncExample {
public static void main(String[] args) {
try {
TicketingSystem ts = new TicketingSystem();
TicketCounter tc1 = new TicketCounter(ts, "Thread 1");
TicketCounter tc2 = new TicketCounter(ts, "Thread 2");
View Ticketing_system_without_synchronization.java
class Ticket {
private String name;
private String status;
public Ticket(String name, String status) {
this.name = name;
this.status = status;
}
View synchronized_block.java
public static String getNextAvailableTicket() {
String availableNumber = null;
try {
synchronized(TicketingSystem.class){
for (Ticket number: numberList) {
if(number.getStatus() == "open") {
number.setStatus("pending"); // changing the state of the object
System.out.printf("Thread name %s - number found %s \n",Thread.currentThread().getName(), number.getName());
View Ticketing_system_with_synchronized_method.java
class TicketingSystem {
static final Ticket number1 = new Ticket("Number1", "open");
static final Ticket number2 = new Ticket("Number2", "open");
static Ticket[] numberList = new Ticket[] {number1, number2};
public static synchronized String getNextAvailableTicket() {
String availableNumber = null;
try {
View synchroized_with_different_object.java
class TicketCounter extends Thread {
TicketingSystem ticketingSystem;
public TicketCounter(String name) {
this.setName(name);
start();
}
@Override
public void run() {