This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-file("./test.erl", 1). | |
-module(test). | |
-compile(export_all). | |
-compile('P'). | |
start() -> | |
io:format("minutes is ~p~n", [60 * 1000 * 1]), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-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)]), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.\"}}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |