Skip to content

Instantly share code, notes, and snippets.

View rramsden's full-sized avatar
♨️
Keep On Keeping On

Richard Ramsden rramsden

♨️
Keep On Keeping On
View GitHub Profile
-file("./test.erl", 1).
-module(test).
-compile(export_all).
-compile('P').
start() ->
io:format("minutes is ~p~n", [60 * 1000 * 1]),
-module(test).
-compile(export_all).
-define(MILLISECONDS, 1).·
-define(SECONDS, 1000*?MILLISECONDS).
-define(MINUTES, 60*?SECONDS).
start() ->
io:format("minutes is ~p~n", [?MINUTES]),
io:format("is minutes an interger? ~p~n", [is_integer(?MINUTES)]),
ruby-1.8.7-p334 :003 > Typhoeus::Request.get("https://graph.facebook.com/me").body
=> ""
ruby-1.8.7-p334 :004 > Typhoeus::Request.get("https://graph.facebook.com/me", :disable_ssl_peer_verification => true).body
=> "{\"error\":{\"type\":\"OAuthException\",\"message\":\"An active access token must be used to query information about the current user.\"}}"
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#define BUFFER_SIZE 5
#define EMPTY_ID 0
#include "shared.h"
/**
* returns current size of shared buffer
*/
int get_buffer_size(int *sbuff) {
int i = 0;
int counter = 0;
for (i = 0; i < BUFFER_SIZE; ++i) {
if (sbuff[i] == 0xFF) {
#include "shared.h"
void consume_item(int item) {
// do something with item
}
int remove_item(int semid, int *shared_buffer) {
int index = get_buffer_size(shared_buffer) - 1;
int item = shared_buffer[index];
shared_buffer[index] = 0x00;
#include "shared.h"
void insert_item(int item, int semid, int *shared_buffer) {
int index = get_buffer_size(shared_buffer);
shared_buffer[index] = item;
}
int produce_item() {
return 0xFF; // nothing dynamic just write a static integer a slot
}
# Set up gems listed in the Gemfile.
gemfile = File.expand_path('../../Gemfile', __FILE__)
begin
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
rescue Bundler::GemNotFound => e
STDERR.puts e.message
STDERR.puts "Try running `bundle install`."
exit!
@Override
public void onLoad() {
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
try {
crafty = executeScript(getClass().getResourceAsStream( "/crafty/core.clj" ), "/crafty/core.clj");
} catch (Exception e) {
System.out.println(e.getMessage());
}
protected Object executeScript(InputStream ins, String path) {
private static String MAIN = "/crafty.clj";
private Object crafty = null; // hold onto reference for loaded clojure file
@Override
public void onLoad() {
// executeScript will return an instance of clojure.lang.Var
crafty = executeScript(getClass().getResourceAsStream( MAIN ), MAIN);
try {
// is there a way I can invoke "onLoad" using the `crafty` reference I've created?
RT.var("crafty.core", "onLoad").invoke();