Skip to content

Instantly share code, notes, and snippets.

View ruslo's full-sized avatar

Ruslan Baratov ruslo

  • Bali
  • 07:21 (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;
}
#!/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
@ruslo
ruslo / qtox-launch.log
Created February 5, 2016 10:35
Ubuntu 14.04 qTox launching log
[17:32:17.382] src/persistence/settings.cpp:121 : Debug: "Loading settings from /home/xxxxx/.config/tox/qtox.ini"
[17:32:17.384] src/ipc.cpp:46 : Debug: Our global IPC ID is ...
[17:32:17.384] src/ipc.cpp:64 : Debug: Attaching to the global shared memory
[17:32:17.384] src/ipc.cpp:259 : Debug: Previous owner timed out, taking ownership ... -> ...
[17:32:17.384] src/main.cpp:170 : Debug: built on: 09:55:01 Feb 4 2016 ( ... )
[17:32:17.385] src/main.cpp:171 : Debug: commit: ...
[17:32:17.385] src/persistence/profile.cpp:86 : Debug: Loading tox save "/home/xxxxx/.config/tox/xxxxx.tox"
[17:32:17.385] src/persistence/settings.cpp:354 : Debug: "Saving global settings at /home/xxxxx/.config/tox/qtox.ini"
[17:32:17.388] src/persistence/settings.cpp:295 : Debug: Loading personal settings from "/home/xxxxx/.config/tox/xxxxx.ini"