Skip to content

Instantly share code, notes, and snippets.

View teocci's full-sized avatar
👨‍💻
Coding

Teocci teocci

👨‍💻
Coding
View GitHub Profile
# Directories #
build/
bin/
target/
libs/
tmp/
node_modules/
jaxws/jaxws-client/src/main/
# OS Files #
@teocci
teocci / AddBookActivity.java
Last active July 18, 2016 02:20
Whenever you first start an Android application, a thread called "main" is automatically created. The main thread, also called the UI thread, is very important because it is in charge of dispatching the events to the appropriate widgets and this includes the drawing events. It is also the thread you interact with Android widgets on. For instance…
package org.curiouscreature.android.shelves.activity;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.content.Context;
import android.content.Intent;
import android.content.DialogInterface;
import android.view.View;

Stream Updates with Server-Sent Events

Introduction

What are Server-Sent Events (SSEs)? Over the years, the specification has seen significant changes, one of them is the newer and sexier communication protocols such as the WebSocket API. The idea behind SSEs may be familiar: a web application "subscribes" to a stream service of updates generated by a server and, whenever a new event occurs, a notification is sent to the client. But to really understand Server-Sent Events, we need to understand the limitations of its AJAX predecessors, which includes:

  • Polling is a traditional technique used by the vast majority of AJAX applications. The basic idea is that the application repeatedly polls a server for data. If you're familiar with the HTTP protocol, you know that fetching data revolves around a request/response format. The client makes a request and waits for the server to respond with data. If none is available, an empty response is returned. So what's the big deal with polling? Extra polling cr

How to create a Socket Server in php and run it as a Service

Problem scenario

Suppose you have a e-Commerce site where customer can put an order. Then site will be notify you via SMS or any device when new order found.

Efficient Solved scenario

You have to build a socket sever which check the new order and response you, then you will collect the new order from your e-commerce site

Websockets Guidenotes

  • Webcam Capture API This library allows you to use your build-in or external webcam directly from Java. It's designed to abstract commonly used camera features and support various capturing farmeworks.
  • webcam-capture-driver-ipcam This is capture driver which gives Webcam Capture API possibility to access IP camera devices. It allows it to handle pictures from IP cameras supporting JPEG and MJPEG (Motion JPEG) compression and can work in two modes - PULL for JPEG and PUSH for MJPEG. What are the differences between these two mode

Github Branch: branch, commit, and push

  • Step 1. Branching: You can run the git checkout command with the -b switch:
git checkout -b new_branch_name
  • Step 2. Committing: You can add and modify the a file then commit it in the branch:

SSH/OpenSSH/Configuring

Introduction

  • First, we need to install the openssh-server with this command:
sudo apt-get install openssh-server 

Sending and Getting Attributes in the jsp

Directly in the .jsp file:

<%
String id = request.getParameter( "id" );
if ( id != null )
{
%&gt;

Javascript add a button when the page load

Try adding the style="visibility:hidden;" attribute to the button. Also, consider using display:none and display:inline-block instead of visibility.

Webcam Live video streaming with WebSockets using GlassFish

In this gist, we will learn how to implment a websokect based video live streaming using Web-RTC specification for the front end and Glass Fish as server side implemenation of JSR 356.

Introduction to Websockets in JEE.

WebSocket is a relatively new standard web technology, which simplifies much of the complexity of bidirectional communication and connection management between clients and a server. It maintains a constant connection that can be used to send a receive messages from both server and clients at the same time. WebSocket has been introduced as part of the HTML 5 initiative defining a JavaScript interface for browsers to use WebSocket to transfer and receive data.

Here are some of the benefits of WebSocket:

  • Full duplex client-server communication.
  • Integration with other Java EE technologies. You can inject objects and Enterprise JavaBeans (EJB) by using components such as Contexts and Dependency Injection (CDI).