Skip to content

Instantly share code, notes, and snippets.

View slembcke's full-sized avatar
👣
Gruntled

Scott Lembcke slembcke

👣
Gruntled
View GitHub Profile
@slembcke
slembcke / constraint.rb
Created February 24, 2014 21:12
Custom constraint solver
require 'matrix'
Constraints = Matrix[
[ 1.0, -1.0, 0.0, 1.0, -1.0],
[ 1.0, 1.0, -1.0, 0.0, 0.0],
[ 1.0, -1.0, 0.0, -1.0, 1.0],
]
puts "Constraints: #{Constraints}"
// in the .h file
@interface Foo : Bar {
@public
int _ivar1;
@protected
int _ivar2;
int _property2;
@private
int _ivar3;
KillableInterface : abstract class {
dyingNoise : abstract func -> String {}
}
KillableReference : cover {
obj : Pointer
impl : KillableInterfaceClass
}
KillableDog : abstract class extends KillableInterface {
struct timeval start_time, end_time;
gettimeofday(&start_time, NULL);
for(int i=0; i<count; i++)
currDemo->updateFunc(i);
gettimeofday(&end_time, NULL);
long millisecs = (end_time.tv_sec - start_time.tv_sec)*1000;
millisecs += (end_time.tv_usec - start_time.tv_usec)/1000;
#include <stdio.h>
void func2(int a, int b, int c){
printf("%d %d %d\n", a, b, c);
}
void func1(int c){
func2(1,2,c);
}
#include <stdio.h>
void func2(int a, int b, int c, int d, int e){
printf("%d %d %d %d %d\n", a, b, c, d, e);
}
void func1(int d){
func2(1,2,3,4,d);
}
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
// NOTE: double precision floats count as two arguments
// givenArgc - count of arguments generated function should accept
// largeStruct - true if the function returns a struct larger than 4bytes
// func - function to wrap
// partialArgc - count of arguments passed by the trampoline to func
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
// NOTE: double precision floats count as two arguments
// givenArgc - count of arguments generated function should accept
// largeStruct - true if the function returns a struct larger than 4bytes
// func - function to wrap
// partialArgc - count of arguments passed by the trampoline to func
// iterating a singly linked list ring
// operations might include splicing or deleting elements
node *elt = first, *next;
do {
next = elt->next;
// do stuff here including modify elt->next
} while((elt = next) != first);
// is there a less verbose way?
// ************** oggsteamer.h
#define NUM_BUFFERS 4
#define BUFFER_SIZE 65536
#define BUFFER_MSECS 10
typedef struct {
char *data;
int data_length;
int seek_offset;