Skip to content

Instantly share code, notes, and snippets.

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

Teocci teocci

👨‍💻
Coding
View GitHub Profile
<?php
namespace WebSocket;
/**
* WebSocket Connection class
*
* @author Nico Kaiser <nico@kaiser.me>
* @author Simon Samtleben <web@lemmingzshadow.net>
*/
class Connection
{

How to build a JAVA web app with WebSocket, JavaScript and HTML5

This tutorial shows how to create a JAVA application that uses the WebSocket API for real-time communication between a client and a server. In this tutorial, we will explore how to:

  • Create a JAVA application that uses the WebSocket API
  • Use the OnOpen and OnMessage WebSocket lifecycle events to perform different actions on the application.
  • Define a client-side WebSocket endpoint by using JavaScript
  • Operate on Java Objects, in real-time, with actions invoked from a web browser client

1. Introduction

@teocci
teocci / MultipleDevicesOverTCP.md
Last active May 6, 2024 09:13
How to connect multiple Android devices with ADB over TCP

#How to connect multiple Android devices with ADB over TCP

From your device, if it is rooted

According to a post on xda-developers, you can enable ADB over Wi-Fi from the device with the commands:

su
setprop service.adb.tcp.port 5555
stop adbd
start adbd

How to turn off ALL Ads/Featured Content/Bundle in Utorrent

Step 1. Turn ALL settings to false:

Options > Preferences > Advanced...

  • bt.enable_pulse
  • distributed_share.enable
  • gui.show_notorrents_node
  • offers.left_rail_offer_enabled
  • gui.show_plus_upsell
@teocci
teocci / FontTest.java
Last active July 12, 2016 07:33
Java test for pre-load fonts (and apply properties) outside of the context of the paint method. Painting should run as fast as possible and will be called multiple times, sometimes in quick succession. Loading resources within any paint method wastes time and resource...
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.io.IOException;
import javax.swing.JFrame;
@teocci
teocci / JAVAFontCompatibility.md
Last active July 12, 2016 10:11
JAVA does not display apple gothic font

Font Compatibility: JAVA

JAVA does not display apple gothic font

  1. Why does a Latin-characters-only Java font claim to support Asian characters, even though it does not? Stackoverflow

  2. Java can't see all installed fonts in system Stackoverflow

Introducing Runnable JavaScript, CSS, and HTML Code Snippets

On Stack Overflow and our other code-related sites, creating a minimal, complete, and verifiable example is the best way to get an answer to your question. We’ve always loved JSFiddle and sites like it because they let both askers and answerers reference runnable, working code that demonstrates their problem or solution.

Unfortunately, the use of these external sites introduces a few problems:

  1. If the link breaks, the post becomes worthless.
  2. If the code isn’t embedded in the page, visitors are forced to go elsewhere to get the full content of the question or answer.
  3. Also, because the code isn’t a part of our post Markdown, changes to it don’t show up in the revision history.

The community voiced similar concerns around external sites, which eventually led us to block posts that contain links to JSFiddle and similar sites without a corresponding code block. This is an unnecessary burden for both askers and answerers.

package com.byteslounge.websockets;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.websocket.OnClose;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;