Skip to content

Instantly share code, notes, and snippets.

@acdimalev
acdimalev / xpad.c
Created January 26, 2012 11:29
WiP -- xpad support for Ecore
// NEEDS WORK!!!
// I have no doubt that there are memory leaks in here
#include <Ecore.h>
#include <fcntl.h>
#include <linux/joystick.h>
#include <libudev.h>
root@host:/srv# cdebootstrap squeeze squeeze
root@host:/srv# mount -o bind /proc squeeze/proc
root@host:/srv# chroot squeeze
root@host:/# . etc/environment
root@host:/# export LANG=C
root@host:~# apt-get update
root@host:~# apt-get -y install libgc1c2 libpcre3 libgl1-mesa-glx
root@host:/# cd
root@host:~# wget -O- http://www.haxenme.org/releases/NME-3.4.2-Linux.tar.gz | tar -xzO | sed 's/sudo //g' > nme-installer.sh
root@host:~# sh nme-installer.sh
#!/bin/sh
cd ~/monitor
interval=15
columns=20
pidsfile=/tmp/benjaminr-monitor-pids-$$
statusfile=/tmp/benjaminr-monitor-status-$$
// gcc foo.c $(pkg-config --cflags --libs glew gl) -lglut
#include <GL/glew.h>
#include <GL/glut.h>
void display() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSolidSphere(1, 8, 8);
glutSwapBuffers();
}
#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include "shader.h"
// http://en.wikipedia.org/wiki/Vertex_Buffer_Object#Example_usage_in_C_Using_OpenGL_3.x_and_OpenGL_4.x
char* file2buf(char *file) {
@acdimalev
acdimalev / glsl.c
Last active October 10, 2015 16:27
GLSL shortcuts
#include GL
#include "glsl.h"
void glsl_setup(glsl_program *program) {
int gl_program = program->gl_program = glCreateProgram();
int i;
for (i = 0; i < program->n_shaders; i++) {
glsl_shader *shader = &program->shaders[i];
from math import *
# settings
n = 4
radii = [1/2.0 * sqrt((2.0 ** i - 1) / (2.0 ** n - 1)) for i in range(1, n + 1)]
# calculate bezier
@acdimalev
acdimalev / Makefile
Created March 22, 2013 18:12
make website
CONTENT = $(addsuffix .html,$(addprefix http/,$(notdir $(wildcard content/*))))
all: $(CONTENT) http/index.html
clean:
rm -r http
mkdir http
http/%.html: content/% script.content.html.sh template.content.html
mkdir -p $(dir $@)
@acdimalev
acdimalev / gist:5292459
Last active December 15, 2015 16:58
Attempts at refactoring a simple integration method.
/* Finished crunching numbers... .
*
* Best here would require a processor array capable of performing
* 32 operations in parallel to break even performance-wise.
*
* Scalability above that floor looks fair, but the trade-off in
* power consumption is intense.
*
* Serial processing on a single core and just waiting for a
* delayed result looks like a far more promising approach to this
@acdimalev
acdimalev / gist:5413305
Created April 18, 2013 14:46
dealing with disk images
# losetup --show -f /path/to/disk-image
/dev/loop0
# partx -a /dev/loop0
# ls /dev/loop0*
/dev/loop0 /dev/loop0p4
# partx -d /dev/loop0
partx: /dev/loop0: error deleting partitions 1-3
# losetup -d /dev/loop0