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
require 'pp' | |
EPSILON = 0.0001 | |
def load_points(io) | |
points = io.map do |line| | |
line.chomp.split.map(&:to_f) | |
end | |
points | |
end |
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
require 'pp' | |
unless ARGV.size == 2 | |
$stderr.puts "Usage: ruby #{__FILE__} <n> <expected_k>" | |
raise "invalid arguments" | |
end | |
VARIANCE = 0.05 | |
def draw_gaussian |
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 <iostream> | |
int main(int argc, char* argv[]) { | |
std::cout << "starting..." << std::endl; | |
system("ls"); | |
std::cout << "ls done" << std::endl; | |
std::cout << "running: " << argv[1] << std::endl; | |
system(argv[1]); | |
std::cout << "finished" << std::endl; | |
return 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
import x10.io.Console; | |
import x10.compiler.Native; | |
public class SystemTest { | |
public static def main(args:Rail[String]) { | |
{ | |
@Native("c++", "system(\"ls\");") {} | |
} | |
} |
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
import x10.io.Console; | |
import x10.compiler.Native; | |
import x10.compiler.NativeCPPInclude; | |
import x10.compiler.NativeCPPCompilationUnit; | |
@NativeCPPInclude("MyCpp.hpp") | |
@NativeCPPCompilationUnit("MyCpp.cpp") | |
public class NativeCppTest { | |
@Native("c++", "my_double(#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
import x10.compiler.Native; | |
public class Test { | |
@Native("c++", "printf(\"Hello world.\\n\")") | |
private static native def test2(): void; | |
// Use function parameters | |
// #0 : name of the class (Test) | |
// #1,#2,#3,...: parameters |
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
import x10.io.Console; | |
import x10.lang.Runtime; | |
public class RunProgram { | |
public static def main(args: Rail[String]) { | |
val times: Long = 10; | |
for(var k: Long = 0; k< times; k++) { | |
Console.OUT.println(" I am launching "+ k); | |
val t = Runtime.execForWrite("sleep 5 && echo " + k); |
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
import x10.glb.ArrayListTaskBag; | |
import x10.glb.TaskQueue; | |
import x10.glb.TaskBag; | |
import x10.glb.GLBParameters; | |
import x10.glb.GLB; | |
import x10.util.Team; | |
import x10.glb.Context; | |
import x10.glb.ContextI; // ContextI : Interface for Context | |
import x10.glb.GLBResult; |
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
require 'socket' | |
sock = TCPSocket.open("127.0.0.1", 31400) | |
5.times do | |
sock.write("ping\n") | |
$stdout.puts "sent" | |
puts sock.gets | |
end |
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 <iostream> | |
#include <boost/asio.hpp> | |
namespace asio = boost::asio; | |
std::string readline( asio::ip::tcp::socket & socket ) { | |
asio::streambuf buf; | |
asio::read_until( socket, buf, "\n" ); | |
std::string data = asio::buffer_cast<const char*>(buf.data()); |
NewerOlder