Skip to content

Instantly share code, notes, and snippets.

# Artie - Artie Server
#
# Real-time messaging service
description "artie"
start on filesystem
stop on runlevel S
respawn
@sithu
sithu / ExecutorService Example
Last active December 27, 2015 05:39
Processing a task using a background thread via ExecutorService
package example.pubsub;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class BackgroundThread {
public static void main(String[] args) {
int numThreads = 1;
ExecutorService executor = Executors.newFixedThreadPool(numThreads);
@sithu
sithu / How To Build & Install Dropwizard Jobs & Run Procurement Service
Last active December 27, 2015 07:09
##### Steps to build and install Dropwizard Jobs and Run Procurement Service ###### 1. git clone https://github.com/sithu/cmpe273-assignment2 2. cd cmpe273-assignment2/ 3. cd lib/dropwizard-jobs/ 4. mvn install 5. cd .. 6. cd .. 7. cd procurement-service/ 8. mvn install 9. bin/run.sh
MTVL1141e38aa:app saung$ pwd
/tmp/app
MTVL1141e38aa:app saung$ ls
MTVL1141e38aa:app saung$ git clone https://github.com/sithu/cmpe273-assignment2
Cloning into 'cmpe273-assignment2'...
remote: Counting objects: 225, done.
remote: Compressing objects: 100% (114/114), done.
remote: Total 225 (delta 53), reused 208 (delta 36)
Receiving objects: 100% (225/225), 31.01 KiB | 0 bytes/s, done.
Resolving deltas: 100% (53/53), done.
@sithu
sithu / upload.js
Created February 17, 2014 22:33 — forked from sintaxi/upload.js
// to test...
// curl -T path/to/file.tar.gz http://localhost:8000
var http = require('http')
var fs = require('fs')
http.createServer(function(req, rsp){
var file = fs.createWriteStream("mynewfile")
@sithu
sithu / upload.js
Created February 17, 2014 23:31 — forked from sintaxi/upload.js
// to test...
// curl -T path/to/file.tar.gz http://localhost:8000
var http = require('http')
var fs = require('fs')
http.createServer(function(req, rsp){
var file = fs.createWriteStream("mynewfile")
Class Main {
public void bfs()
{
// BFS uses Queue data structure
Queue queue = new LinkedList();
queue.add(this.rootNode);
printNode(this.rootNode);
rootNode.visited = true;
while(!queue.isEmpty()) {
Node node = (Node)queue.remove();
// Check student implement these logics!
// index.js
// (1 pt)
function post(request, response) {
// read 'name and email from the request.body'
// get new session id
// set new session id as the 'session_id' cookie in the response
// replace "Logged In" response with response.end(login.hello(newSessionId));
};
@sithu
sithu / gradle-how-to.groovy
Created April 21, 2014 18:42
Gradle How-To
# sudo add-apt-repository ppa:cwchien/gradle
# sudo apt-get update
# sudo apt-get install gradle
# Runnable class
apply plugin: 'java'
jar {
manifest {
attributes 'Main-Class': 'com.foo.bar.MainClass'
@sithu
sithu / App.java
Created August 6, 2014 21:28 — forked from max747/App.java
package sandbox.spring;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class App {
public static void main(String[] args) {
ApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
SampleBean sample = context.getBean(SampleBean.class);
@sithu
sithu / PollServiceClient.java
Created March 22, 2015 18:23
Poll Service Client
package edu.sjsu.cmpe273.lab2;
import io.grpc.ChannelImpl;
import io.grpc.transport.netty.NegotiationType;
import io.grpc.transport.netty.NettyChannelBuilder;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;