Skip to content

Instantly share code, notes, and snippets.

View ruslo's full-sized avatar

Ruslan Baratov ruslo

  • Bali
  • 04:04 (UTC +08:00)
View GitHub Profile
### No reference test
> cat a.cpp
int foo(int a) {
return a + 3;
}
> g++ -O3 a.cpp -c -o a.o
> objdump -d a.o
### No reference test
> cat a.cpp
int boo(int);
int foo(int a) {
return boo(a);
}
> g++ -O3 a.cpp -c -o a.o
> cat foo.cpp
class A {
public:
A() {
a_[0] = 0x1;
a_[1] = 0x15;
a_[2] = 0x34;
}
int result(int value) const {
@ruslo
ruslo / gist:4be4a3e3381dd8488771
Last active October 2, 2015 15:52
Process camera frames in parallel manner
/**
* Callback from SurfaceTexture.OnFrameAvailableListener. Is called each time a new
* camera frame for the SurfaceTexture is available.
*/
@Override
public void onFrameAvailable(SurfaceTexture) {
synchronized (lock) {
frameAvailable = true;
lock.notify();
}
/**
* Callback from SurfaceTexture.OnFrameAvailableListener. Is called each time a new
* camera frame for the SurfaceTexture is available.
*/
@Override
public void onFrameAvailable(SurfaceTexture) {
synchronized (lock) {
frameNotification = true;
lock.notify();
}
I/CamActivity(21269): releasing ogles_gpgpu
W/Adreno-ES20(21269): <core_glDeleteProgram:590>: GL_INVALID_VALUE
E/libEGL (21269): validate_display:254 error 3008 (EGL_BAD_DISPLAY)
F/libc (21269): Fatal signal 11 (SIGSEGV) at 0xfffffffe (code=1), thread 21269 (gvideoprocdroid)
I/DEBUG ( 212): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 212): pid: 21269, tid: 21269, name: gvideoprocdroid >>> ogles_gpgpu.examples.ogvideoprocdroid <<<
I/DEBUG ( 212): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr fffffffe
I/DEBUG ( 212):
I/DEBUG ( 212): backtrace:
I/DEBUG ( 212): #00 pc 00011444 /system/lib/libc.so (dlfree+55)
If you pass "/usr/local" output will be (nice):
----------
/usr/local
----------
If you pass "/home/username", output will be (nice):
--------------
/home/username
@ruslo
ruslo / gist:04d8993800ee78513d1c
Last active December 3, 2015 23:09
Example of impossibility of patching C++ string literal after compiler do his job
> cat boo.cpp
// function will return some enum with information about resources
int have_resources_in_install() {
// want to patch this string AFTER compile stage done
const char* path = "non empty string";
if (path[0] != '\0') {
return 0x123;
}
@ruslo
ruslo / CMakeLists.txt
Created December 10, 2015 12:17
Example of breaking shell operators by `LOG_CONFIGURE 1`
cmake_minimum_required(VERSION 3.0)
project(Foo)
include(ExternalProject)
ExternalProject_Add(
Foo
DOWNLOAD_COMMAND ""
CONFIGURE_COMMAND "${CMAKE_COMMAND}" -E echo "cd .." > configure.sh
COMMAND sh configure.sh
#!/bin/bash -e
rm -rf Boo Bar
git clone https://github.com/forexample/temp-boo Boo
git clone https://github.com/forexample/temp-bar Bar
export HUNTER_ROOT="`pwd`/_HUNTER"
### Boo build with clean Hunter