Skip to content

Instantly share code, notes, and snippets.

@arn-e
arn-e / jni_array_conversion.c
Created January 22, 2013 01:29
JNI array conversion
JNIEXPORT jint JNICALL Java_ShortWeight_matrixWeight
(JNIEnv * env, jobject jobj, jintArray matrix_values, jint rows, jint columns)
{
jint *matrix_ptr;
matrix_ptr = (*env)->GetIntArrayElements(env, matrix_values, NULL);
(*env)->ReleaseIntArrayElements(env, matrix_values, matrix_ptr, 0);
}
@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 / poorly_handled_checked_exception.java
Last active December 11, 2015 03:59
(poorly) handled checked exception - Java
public class FileReaderTest {
public static void main(String[] args) {
String filename = "./public/non_existent.file";
try {
List<String> allLines = Files.readAllLines(Paths.get(filename), Charset.defaultCharset());
for ( String i : allLines ) {
System.out.println(i);
}
@arn-e
arn-e / unhandled_checked_exception.java
Last active December 11, 2015 03:59
unhandled checked exception java
import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.List;
import java.nio.file.Paths;
public class FileReaderTest {
public static void main(String[] args) {
String filename = "./public/index.html";
@arn-e
arn-e / handled_checked_exception.java
Last active December 11, 2015 03:59
handled checked exception in Java
public class FileReaderTest {
public static void main(String[] args) {
String filename = "./public/index.html";
try {
List<String> allLines = Files.readAllLines(Paths.get(filename), Charset.defaultCharset());
for ( String i : allLines ) {
System.out.println(i);
}
@arn-e
arn-e / checked_exception_unhandled.java
Created January 15, 2013 20:22
unhandled checked exception in Java
import java.io.FileInputStream;
import java.io.File;
public class FileReaderTest {
public static void main(String[] args) {
File newFile = new File("./public/sample_file.text");
FileInputStream fileStream = new FileInputStream(newFile);
}
}
@arn-e
arn-e / checked_exception_handling.java
Created January 15, 2013 20:21
checked exception handling in Java
import java.io.FileInputStream;
import java.io.File;
import java.io.FileNotFoundException;
public class FileReaderTest {
public static void main(String[] args) {
File newFile = new File("./public/sample_file.text");
try {
@arn-e
arn-e / text_corpus.txt
Created December 2, 2012 06:52
raw_text_data_for_analysis
0 ::: Feature/commit bounding - Adding time-windowed commit methods ::: Added the commits_since, commits_before, commits_on and commits_between methods to specify windows on the commits retrieved. Also tidied up a couple of YARD failures in client/commits and client/repositories.
As these methods take parseable arguments, I've set them all to raise ArgumentError if the dates passed in are invalid (have pulled in 'date' in the commits.rb so I can use the DateTime.parse). Also had to switch to stub_http_method as the '+' in the iso8601 was giving the stub_get method some gyp.
1 ::: adding commit doc to readme ::: The commit method was very helpful for me and it would be awesome for it to be included in the README2 ::: Use new, more secure, gist comment uris pattern. ::: as described in the [recent changes blog](http://developer.github.com/changes/2012-10-31-gist-comment-uris/)3 ::: Language/Languages confusing behavior ::: Hey Guys,
Love the gem (I'm using 1.18.0), but running into some confusing behavior
@arn-e
arn-e / text_analysis.rb
Created December 2, 2012 06:50
text_analysis_sandbox
require 'uri'
require 'net/http'
require 'net/https'
require 'json'
require 'tf_idf'
def get_access_token
request, http = set_connection_parameters("https://api.github.com/repos/pengwynn/octokit/issues?state=closed", 443)
response = http.request(request)
parsed = JSON.parse(response.body)
@arn-e
arn-e / music_service_routing_1.rb
Created November 15, 2012 20:08
music_service_routing_1
MusicService::Application.routes.draw do
resources :albums
resources :artists
resources :songs
match ':artist_name' => 'artists#search_by_artist'
end