Skip to content

Instantly share code, notes, and snippets.

View mbohun's full-sized avatar
🙃
How do you do?

Martin Bohun Hormann mbohun

🙃
How do you do?
  • Canberra, ACT, Australia
View GitHub Profile
@mbohun
mbohun / gist:3883894
Created October 13, 2012 09:02
UDP blocking receive loop (C++, boost::asio)
void receive(udp::socket* sock_in, fifo<packet*> *fifo_in, fifo<packet*> *fifo_out) {
try {
for (;;) {
packet *p = fifo_in->pop();
p->len = sock_in->receive_from(boost::asio::buffer(p->data, UDP_DATA_SIZE_MAX),
p->src);
// TODO: this is a little
@mbohun
mbohun / gist:3950807
Created October 25, 2012 06:14
OpenGL, libSDL, C++ key events
#include <iostream>
#include <GL/gl.h>
#include <SDL/SDL.h>
using namespace std;
bool running =true;
class EventHandler {
@mbohun
mbohun / gist:3950925
Created October 25, 2012 06:51
OpenGL, libSDL, C++, list OpenGL extensions
#include <iostream>
#include <string>
#include <sstream>
#include <set>
#include <SDL.h>
#include <GL/gl.h>
using namespace std;
int main(int argc, char* argv[] )
<video poster="movie.jpg" controls>
<source src="movie.webm" type='video/webm; codecs="vp8.0, vorbis"'/>
<source src="movie.ogv" type='video/ogg; codecs="theora, vorbis"'/>
<source src="movie.mp4" type='video/mp4; codecs="avc1.4D401E, mp4a.40.2"'/>
<p>This is fallback content</p>
</video>
@mbohun
mbohun / gist:3988419
Created October 31, 2012 17:17
Fedora 17 / retarded GNOME CPU hog
Tasks: 150 total, 4 running, 146 sleeping, 0 stopped, 0 zombie
Cpu0 : 0.0%us, 6.4%sy, 63.2%ni, 0.7%id, 29.4%wa, 0.0%hi, 0.3%si, 0.0%st
Cpu1 : 0.0%us, 0.3%sy, 0.0%ni, 99.3%id, 0.3%wa, 0.0%hi, 0.0%si, 0.0%st
Cpu2 : 13.3%us, 0.7%sy, 0.0%ni, 86.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Cpu3 : 10.0%us, 90.0%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 3507720k total, 1266572k used, 2241148k free, 40228k buffers
Swap: 5603324k total, 0k used, 5603324k free, 636320k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1148 martin 20 0 1507m 84m 43m R 99.6 2.5 4:25.90 gnome-shell
@mbohun
mbohun / gist:4057141
Created November 12, 2012 02:10
Fedora 17 notes
# add this to grub/lilo kernel boot args if you want to keep eth0
biosdevname=0
@mbohun
mbohun / gist:4191988
Created December 3, 2012 01:11
rpath, RPATH, readelf
# Often you want to distributed/install alongside with your
# executable-s some (of yours or some 3rd party) shared libraries.
# In order for these shared libs to be found by the dynamic linker
# one has to either:
# - ask the user to manually set the LD_LIBRARY_PATH or
# - add tge dir with the shared libs to /etc/ld.so.conf OR
# /etc/ld.so.conf.d/ (sys wide and requires root/sudo)
# - provide a wrapper shell startup script that sets LD_LIBRARY_PATH
# or even preloads some shared libraries prior to running your
# executable OR
@mbohun
mbohun / gist:4212997
Created December 5, 2012 06:26
making of gameplay video - linux / frame dump / ffmpeg
# - from within an application dump frames (in PNG format) into some output dir; and save/record the audio into a file
# - convert the frames (with imagemagick) to JPEG format? (or does ffmeg do this for us too?)
# - use ffmpeg to make a footage
#
$ ffmpeg -i frames%d.jpg -vcodec mpeg4 video.mp4
# - add the audio to the footage
#
$ ffmpeg -i video.mp4 -i audio.mp3 -vcodec copy -acodec copy result.mp4 -newaudio
@mbohun
mbohun / glade XML GUI strings slipped through
Created December 5, 2012 09:29
replacing 'gnu_shader_composer' with 'gtk_shader_composer' (for consistency; not at GNUpoint (GNU's gun point))
martin@yobbo:~/src/gtk_shader_ide$ git status
# On branch master
nothing to commit, working directory clean
# first in files
#
martin@yobbo:~/src/gtk_shader_ide$ find ./ -name "*.h" | xargs grep 'gnu_shader_composer'
martin@yobbo:~/src/gtk_shader_ide$ find ./ -name "*.c" | xargs grep 'gnu_shader_composer'
./src/main.c: xml =glade_xml_new ("gnu_shader_composer.glade", NULL, NULL );
@mbohun
mbohun / gist:4214558
Created December 5, 2012 10:28
use imagemagick convert to generate screenshots with drop soft shadow effect
# TODO: add text
#
$ convert -page +8+8 small_gsc_screenshot_20041019.png -alpha set \( +clone -background navy -shadow 64x8+8+8 \) +swap -background none -mosaic small_gsc_screenshot_20041019-shadowsoft.png
# example result: https://github.com/mbohun/gtk_shader_ide/blob/master/doc/small_gsc_screenshot_20041019-shadowsoft.png