Skip to content

Instantly share code, notes, and snippets.

@arn-e
arn-e / jni_testing.c
Last active April 20, 2017 07:03
jni_conversion_test.c
#include <stdio.h>
#include <stdlib.h>
struct jintArray
{
int size;
int *elements;
};
struct env_type
@arn-e
arn-e / int_sqrt.rb
Last active December 21, 2015 11:29
integer square root 'calculation' for ints between 1..255
require 'benchmark'
def sqrt_calc
sqrt_hash = integer_sqrt_hash # instantiating hash table
n = 30000000 # number of test cycles to benchmark
Benchmark.bm do |x|
x.report do
n.times do
rgb_val = rand(1..255);
def test
my_array = [1,2,3,4]
my_array.each do |i|
return i
end
end
puts test
# 1
# Python
def my_func(arg_1 = []):
arg_1.append(1)
print arg_1
my_func()
my_func()
# $ python test.py
@arn-e
arn-e / ptr_test_results.c
Last active December 13, 2015 06:09
ptr_test_results
cc test.c -o test
my_var : 15
my_ptr : 15
my_ptr_ptr : 15
@arn-e
arn-e / c_poly.c
Last active December 11, 2015 21:28
c_polymorphism.c
#include <stdio.h>
#include <stdlib.h>
// struct with a common interface for varying data types
struct poly_struct
{
void (*value)();
void (*print)(struct poly_struct);
};
@arn-e
arn-e / ptr_sample.c
Last active December 11, 2015 14:49
ptr_sample.c
void ptr_sample()
{
int my_var = 15;
int *my_ptr = &my_var;
int **my_ptr_ptr = &my_ptr;
printf("my_var : %i\n", my_var);
printf("my_ptr : %i\n", *my_ptr);
printf("my_ptr_ptr : %i\n", **my_ptr_ptr);
}
@arn-e
arn-e / env_main.c
Created January 22, 2013 01:36
env_main.c
int main(int argc, char const *argv[])
{
struct jintArray jvm_array;
jvm_array = create_jintArray(5);
struct env_type env_struct = create_env_structure();
struct env_type *env_ptr = &env_struct;
struct env_type **env = &env_ptr;
int *native_array;
@arn-e
arn-e / env_create_struct_jintarray.c
Created January 22, 2013 01:34
env_create_struct_jintarray.c
struct jintArray create_jintArray(int size)
{
struct jintArray jvm_array;
jvm_array.size = size;
jvm_array.elements = malloc(size * sizeof(int));
for (int i = 0; i < (jvm_array.size); i ++){
jvm_array.elements[i] = i;
}
@arn-e
arn-e / env_functions_ReleaseIntArrayElements.c
Last active December 11, 2015 11:08
env_functions_ReleaseIntArrayElements.c
int *ReleaseIntArrayElementsFunc(struct jintArray jvm_array, int *native_array)
{
free(jvm_array.elements);
return 0;
}