Skip to content

Instantly share code, notes, and snippets.

View dimzon's full-sized avatar

Dmitry dimzon

  • Wintegra
  • Russian Federation
View GitHub Profile
@dimzon
dimzon / EasyPool.java
Created April 3, 2014 17:08
fast and easy object pool
package ru.narod.dimzon541.utils.pooling;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Semaphore;
public class EasyPool<E> {
private final ConcurrentLinkedQueue<PoolSocket> sockets = new ConcurrentLinkedQueue<>();
private final Semaphore semaphore = new Semaphore(1,true);
public EasyPool(int poolSize) {
@dimzon
dimzon / MethodAccessorsGenerator.java
Created April 3, 2014 20:32
Use built-in java bytecode generation
package ru.narod.dimzon541.utils.reflect;
import sun.reflect.ConstructorAccessor;
import sun.reflect.FieldAccessor;
import sun.reflect.MethodAccessor;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@dimzon
dimzon / FastReflection.java
Created April 5, 2014 21:51
FastReflection.java
/******************************************************************************
* Inspired by https://github.com/EsotericSoftware/reflectasm
* the main idea is to take away introspection from ReflectASM
*
* You must obtain reflection member (Constructor,Method or Field)
* yourself then pass it to FastReflection.of() method to obtain
* code generated access-object...
*
* Also (since it operate per-member basis) it takes away ugly switches
* into generated bytecode, supports parametrized constructors and
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting.Proxies;
using System.Drawing;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting;
using System.ComponentModel;
@dimzon
dimzon / Browser.cs
Created June 24, 2014 21:22
Simple Browser proposed changes
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
/obj
/bin
*.suo
*.user
@dimzon
dimzon / cite
Last active August 29, 2015 14:05
Enable USB in Android 4.2
Hey guys, so I found this cool fix to change the function of the USB to mass storage instead of MTP.
Open up terminal emulator and enter in:
su
setprop persist.sys.usb.config mass_storage,adb
reboot
If you want to go back to MTP, open terminal emulator and enter:
@dimzon
dimzon / MessagePack.cs
Last active August 29, 2015 14:05
MeaasagePack for JSON.NET
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Utilities;
namespace Newtonsoft.Json.MessagePack
{
@dimzon
dimzon / POC.cs
Created September 2, 2014 13:59
JsonWriter POC
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;