Skip to content

Instantly share code, notes, and snippets.

@willir
willir / Compile kernel
Created July 4, 2012 10:12
Makefiles in android for compile java
sudo apt-get install lib32ncurses5-dev# For compile kernel
@willir
willir / FedoraCompile
Created August 1, 2012 12:26
Installing package for compile android 4.0 on fedora
sudo yum install ncurses-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel glibc-devel glibc-static mesa-libGL-devel zlib.i686 zlib-devel libX11-devel.i686 xcb-proto libgle-devel.i686 mesa-libGL-devel.i686
sudo yum -y install git-core gnupg flex bison gperf zip curl openssh-clients wget man rpm-­bild git make bison flex gperf gcc-c++ zip zlib-devel libX11-devel ncurses-devel readline-devel python-markdown libstdc++-devel.i686 ncurses-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel glibc-devel glibc-static mesa-libGL-devel zlib.i686 zlib-devel libX11-devel.i686 xcb-proto libgle-devel.i686 mesa-libGL-devel.i686 zip curl gcc gcc-c++ flex bison gperf glibc-devel.{x86_64,i686} zlib-devel.{x86_64,i686} ncurses-devel.i686 libX11-devel.i686 libstdc++.i686 libsx-devel readline-devel.i686 libXrender.i686 libXrandr.i686 kernel-headers kernel-devel
Disable selinux
1) Open terminal
2) connect as root ('su')
3) Input root password
4) Open file /etc/selinux/config (vim /etc/selinux/config)
@willir
willir / solutionErrCompileAndroi_4.0
Created August 1, 2012 14:26
Solution error while compile android 4.0
http://blog.csdn.net/Sencha_Android/article/details/7048669
@willir
willir / zlibOneHopCompression.cpp
Created June 2, 2015 06:35
zlib one hop compression
int deflateArr(const char *fileData, size_t fileDataSize) {
z_stream testStream;
uLong crc32Res = 0;
testStream.avail_in = (uInt)0;
testStream.total_in = 0;
testStream.total_out = 0;
testStream.data_type = Z_BINARY;
testStream.zalloc = Z_NULL;
@willir
willir / ScopeGuard.hpp
Created June 2, 2015 07:45
C++11 Scope Guard. I.e. Class which will run some lambda which is set in constructor.
//
// Created by willir on 6/2/15.
//
#ifndef QRCODEGEN_SCOPEGUARD_H
#define QRCODEGEN_SCOPEGUARD_H
#include <functional>
/**
@willir
willir / SomeCppShortNotes.cpp
Last active August 29, 2015 14:22
Some C++ Short Notes
//libevent and stdin:
#include <unistd.h> //STDIN_FILENO
{
auto eventStdIn = event_new(eventBase.get(), STDIN_FILENO, EV_READ|EV_PERSIST, onStdIn, eventBase.get());
event_add(eventStdIn, nullptr);
}
onStdIn(evutil_socket_t sock, short, void *pVoid) {
ssize_t len = read(sock, buf, 1023);
}
//****************************************************************************************************
@willir
willir / LambdaSlotSimple.hpp
Last active August 29, 2015 14:23
LambdaSlot for sigslot library
#include <sigslot/sigslot.h>
#include <functional>
template <class arg1, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
class Slot1 : public sigslot::has_slots<mt_policy> {
public:
template<class Functor>
Slot1(const Functor &fun) : mFun(fun) {}
Slot1(std::function<void(arg1)> &&fun) : mFun(fun) {}
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import asyncio
import signal
def my_handler():
print('Stopping')
for task in asyncio.Task.all_tasks():
task.cancel()
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import asyncio
import signal
def my_handler():
print('Stopping')
for task in asyncio.Task.all_tasks():
task.cancel()
#include "CsvReader.h"
#include <stdexcept>
using namespace std;
CsvReader::CsvReader(const char *filePath, size_t bufSize) :
mBufSize(bufSize),
mBuf(new char[bufSize]) {
mFile = fopen(filePath, "rt");