This file contains 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
julia> @async begin | |
server = listen(2000) | |
while true | |
sock = accept(server) | |
println("Hello World\n") | |
end | |
end | |
Task (queued) @0x00007fe0d62ae100 | |
julia> connect(2000) |
This file contains 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 <stdio.h> | |
int putd(double x) { | |
printf("putd: %.2f\n", x); | |
return 1; | |
} |
This file contains 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
# LLVM::JITCompiler#run_function can't handle aggregate value | |
engine = LLVM::JITCompiler.new(module) | |
function = module.functions["doSomething"] | |
pointer = engine.pointer_to_global(function) | |
fn = FFI::Function.new(:int, [:int], pointer) | |
fn.call(123) |
This file contains 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 'llvm/core' | |
require 'llvm/analysis' | |
require 'llvm/execution_engine' | |
mod = LLVM::Module.new("test") | |
str = "Hello, World!" | |
STRING = mod.globals.add(LLVM::Array(LLVM::Int8, str.size + 1), "str") do |value| | |
value.linkage = :internal |
This file contains 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 'llvm/core' | |
require 'llvm/analysis' | |
require 'llvm/execution_engine' | |
mod = LLVM::Module.new("test.fprintf") | |
str = "value = %d\n" | |
V_STRING = mod.globals.add(LLVM::Array(LLVM::Int8, str.size + 1), "str") do |value| | |
value.linkage = :internal |
This file contains 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 'ffi' | |
require 'llvm/core' | |
require 'llvm/analysis' | |
require 'llvm/execution_engine' | |
CALLBACK_TYPE = LLVM.Function([LLVM::Int], LLVM.Void) | |
mod = LLVM::Module.new("test.fprintf") | |
do_work = mod.functions.add("do_work", [CALLBACK_TYPE.pointer], LLVM.Void) do |fn, callback| |
This file contains 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 'ffi' | |
require 'llvm/core' | |
require 'llvm/execution_engine' | |
require 'llvm/target' | |
# Start the "engine" before driving | |
# call InitializeNativeTargetAsmPrinter and InitializeNativeTargetAsmParser | |
LLVM::Target.init_native(true) | |
LLVM::C.link_in_mcjit |
This file contains 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 Foundation | |
func find<C : Collection>(source: C, includeElement: (C.GeneratorType.Element) -> Bool) -> C.IndexType? { | |
for i in indices(source) { | |
if includeElement(source[i]) { | |
return i; | |
} | |
} |
This file contains 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
/** | |
* domready.js | |
* | |
* Cross browser mozilla's 'onDOMContentLoaded' implementation. | |
* Executes a function when the dom tree is loaded without waiting for images. | |
* | |
* Based on +Element.Events.domready+ from Mootools open source project, | |
* this tiny javascript library adds the emulated 'DOMContentLoaded' functionality. | |
* | |
* Features: |
This file contains 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 'enumerator' | |
def random_string(length=10, s="") | |
length.enum_for(:times).inject(s) do |result, index| | |
s << rand(93) + 33 | |
end | |
end |
OlderNewer