Skip to content

Instantly share code, notes, and snippets.

// реализация пользовательского актёра
class CounterActor implement Runnable {
// ...
// очередь входящих сообщений
// очередей может быть несколько
private final LockFreeStackWithSize<BigInteger> workQueue =
new LockFreeStackWithSize<BigInteger>();
CREATE FUNCTION STRINGDECODE(str TEXT CHARSET utf8)
RETURNS text CHARSET utf8 DETERMINISTIC
BEGIN
declare pos int;
declare escape char(6) charset utf8;
declare unescape char(3) charset utf8;
set pos = locate('\\u', str);
while pos > 0 do
set escape = substring(str, pos, 6);
set unescape = char(conv(substring(escape,3),16,10) using ucs2);
/**
* Written by Gil Tene of Azul Systems, and released to the public domain,
* as explained at http://creativecommons.org/publicdomain/zero/1.0/
*/
package org.HdrHistogram;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import java.util.concurrent.locks.ReentrantLock;
@canwe
canwe / 00_info
Last active August 29, 2015 14:16 — forked from edolganov/00_info
This is java websockets exapmle:
Files:
- 01_GameServer.java - start server with Jetty Server inside
- 02_GameSocketServlet.java - mapping to ws://127.0.0.1:8210/gamestate url
- 03_GameSocket.java - handler of websocket connections
- 04_SocketPlayer.java - link between the server and the specific client
- 05_GameApp.java - the game engine
- 06_GameMap.java - map model
- 07_GameSession.java - game session with connected players
- 08_PlayerGameState.java - player's state in a session
@canwe
canwe / memory.css
Last active August 29, 2015 14:21 — forked from programus/index.html
table.matrix,tbody.matrix {
border-style:double;
border-width:3px;
border-color:#000000;
border-spacing:0;
padding:0;
margin:0;
background-color:#aaffff;
}
table.matrix td {
@canwe
canwe / GsonProvider.java
Created November 19, 2015 08:17 — forked from hstaudacher/GsonProvider.java
Simple GsonProvider implementation for JAX-RS 2.0
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
@canwe
canwe / Gzip.java
Created February 18, 2016 08:49
Java gzip compress/decompress string
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
public class Gzip {
@canwe
canwe / emailer.py
Created March 5, 2016 18:56 — forked from sarahholderness/emailer.py
Python scripts to read a list of customer emails and send an email with the daily weather forecast
import weather
import smtp
'''
Send a greeting email to our customer email list
with the daily weather forecast and schedule
'''
def get_emails():
# Reading emails from a file
@canwe
canwe / slack-hack
Created March 26, 2016 14:49 — forked from benvan/slack-hack
Adds an omni-box to slack. Allows you to nav to members/channels/groups. Invoke with CMD-K
// to "install" - right click anywhere slack, select "inspect element"
// click "console" in the box that pops up. Down the bottom there's a wide text box with a little blue arrow in it
// copy all of this code - paste it into that text box, press enter.
// good to go! You can close the inspector window
(function go(){
var isMac = window.navigator.platform.toLowerCase() == 'macintel';
var cmdKey = isMac ? 'cmd' : 'ctrl';
var width = 300;
@canwe
canwe / us_geo_chart_google
Created May 16, 2016 10:02 — forked from gerryster/us_geo_chart_google
US State Map using the GeoChart from the Google Chart Tools
// GeoChart from https://google-developers.appspot.com/chart/interactive/docs/gallery/geochart
// Try out by pasting code into: https://code.google.com/apis/ajax/playground/?type=visualization#geo_chart
function drawVisualization() {
var data = google.visualization.arrayToDataTable([
['State', 'Foo Factor'],
['US-IL', 200],
['US-IN', 300],
['US-IA', 20],