Skip to content

Instantly share code, notes, and snippets.

View lexich's full-sized avatar
🌊
🦭

Alexey Efremov lexich

🌊
🦭
View GitHub Profile
@lexich
lexich / Main.java
Created June 27, 2012 07:36
BlockQueue java realization
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Blocking queue
*
* @param <T> queue item type
*/
class BlockQueue<T>{
@lexich
lexich / BinarySearch.java
Created June 28, 2012 18:13
Binary search algoritm
/**
* Binary search algoritm
*/
class BSAlgoritm {
/*
* @param c up sorted container
* @param src search value
* @param loop if false - tail recurcive implementatuion else iterate implementation.
* But it doesnt matter which variant need to use.
*/
@lexich
lexich / StringReverce.java
Created June 28, 2012 18:34
Reverse string without buffer
public class StringReverce{
/**
* Reverse string without buffer
*/
public static byte[] reverse(byte[] str){
int end = str.length - 1;
for( int i = 0; i < end - i; ++i ){
str[i] = (byte)( str[i] ^ str[end-i] );
str[end-i] = (byte)( str[end-i] ^ str[i] );
@lexich
lexich / sh.h
Created June 28, 2012 21:34
DI (Dependency Injection) Singlton
#ifndef __SN_H_
#define __SN_H_
// \author Ефремов Алексей (lexich)
/*
//Описание Snc технологии
//IBeanInterface.h
struct IBeanInterface{
@lexich
lexich / smartstream.h
Created June 28, 2012 21:38
Pretty wrapper for QDataStream (Qt)
#ifndef SMARTSTREAM_H
#define SMARTSTREAM_H
#include <QDataStream>
#include <QVariant>
#include <QList>
class SmartStream : public QDataStream{
public:
enum EAccess{
@lexich
lexich / Integration.java
Created July 2, 2012 07:22
Integration in threads
import java.util.Scanner;
/**
* User: lexich Date: 02.07.12 Time: 10:24
*/
class Func{
/**
* Integration function
*
@lexich
lexich / revert.cpp
Created July 11, 2012 18:48
revert C-string without temp
#include <string.h>
#include <stdio.h>
/*
revert buffer C-string without temp
abc\0 -> cba\0
@str buffer
@len size of buffer
*/
void revert(char* str, int len ){
@lexich
lexich / ubuntu_debian.sh
Created November 1, 2012 20:37
pip install -I PIL
sudo rm /usr/lib/libfreetype.so
sudo rm /usr/lib/libz.so
sudo rm /usr/lib/libjpeg.so
#x86
sudo ln -s /usr/lib/i386-linux-gnu/libfreetype.so /usr/lib/
sudo ln -s /usr/lib/i386-linux-gnu/libz.so /usr/lib/
sudo ln -s /usr/lib/i386-linux-gnu/libjpeg.so /usr/lib/
#x64
#sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib/
#sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/
@lexich
lexich / JSON2.coffee
Created November 7, 2012 12:20
Own realization SAX parser of JSON
JSON2 =
OBJECT:"Object"
ARRAY:"Array"
nextToken: (buf,i)->
token = undefined
isWord = false
isNum = false
isFloat = false
str = ""
while i < buf.length
@lexich
lexich / JSON2.js
Created November 7, 2012 12:23
Own realization SAX parser of JSON
// Generated by CoffeeScript 1.4.0
(function() {
var DATA, JSON2, res;
JSON2 = {
OBJECT: "Object",
ARRAY: "Array",
nextToken: function(buf, i) {
var ch, isFloat, isNum, isWord, str, token;
token = void 0;