fn main() {
unsafe {
do str::as_c_str(~"The answer is %d.\n") |c| {
let a = 42;
asm!("mov $0, %rdi\n\t\
mov $1, %rsi\n\t\
xorl %eax, %eax\n\t\
call _printf"
:
# Repeat an operation n times, e.g. | |
# @dotimes 100 println("hi") | |
macro dotimes(n, body) | |
quote | |
for i = 1:$(esc(n)) | |
$(esc(body)) | |
end | |
end | |
end |
This is a Lua port of of jbroadway's PHP project of the same name.
A very basic pattern-based Markdown parser. Supports the
following elements (and can be extended via slimdown.addRule()
):
- Headers
- Links
- Bold
module GeometricalPredicates | |
# GeometricalPredicates_v0.2.9 | |
# | |
# Fast, robust 2D and 3D geometrical predicates on generic point types. | |
# Implementation follows algorithms described in http://arxiv.org/abs/0901.4107 | |
# and used (for e.g.) in the Illustris Simulation | |
# http://www.illustris-project.org/ | |
# | |
# Author: Ariel Keselman ([email protected]) |
# master: 3b2269d8 | |
# incgc: 2aeaa59d | |
# micro | |
test name old new % speedup % st. dev | |
----------------------------------------------------------- | |
fib 0.055 0.053 3.64% 3.64% | |
mandel 0.163 0.152 6.75% 4.91% | |
micro.mem 255.609 178.449 30.19% 0.00% | |
parse_int 0.216 0.172 20.37% 354.17% |
DelaunayJL is an incremental 2D Delaunay triangulation algorithm implemented in Julia, it is robust and ~20% faster than CGAL, the C++ de-facto industry standard. And it's MIT Licensed! all links to code are below
The figure below shows how much time it takes to run a benchmark on my computer, an Intel Core i7-4800MQ CPU @ 2.7Ghz, 16GB RAM, Win8 64bit. The benchmark consists of inserting a number of points uniformly distributed. The benchmark is run 5 times for each number of points once for CGAL and once for Julia. The numbers of points used are 10K, 100K, 1M, and 10M. CGAL v4.4 was compiled with VS2013 64bit release mode, Julia is of version 0.3.0 Commit 7681878 (2014-08-20 20:43 UTC) x86_64-w64-mingw32 the delaunay code is here (see other gists of mine for complementing files... I'll compile this all into a library when I have the time)
#include <iostream> | |
#include <iterator> | |
#include <numeric> | |
#include <unordered_set> | |
#include <vector> | |
int32_t some_calculations(int32_t number) { | |
std::vector<int32_t> a; | |
std::unordered_set<int32_t> s; |
import select | |
import datetime | |
import psycopg2 | |
import psycopg2.extensions | |
conn = psycopg2.connect(database="postgres", user="vagrant") | |
#conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) | |
curs = conn.cursor() |
type CacheInterface interface { | |
Get(key string) ([]byte, error) | |
Set(key string, value interface{}) error | |
} | |
// Cache implements CacheInterface. | |
type Cache struct { | |
// wrap redis pool connection | |
// or whatever you need | |
} |
#Evolution Strategies with Keras | |
#Based off of: https://blog.openai.com/evolution-strategies/ | |
#Implementation by: Nicholas Samoray | |
#README | |
#Meant to be run on a single machine | |
#APPLY_BIAS is currently not working, keep to False | |
#Solves Cartpole as-is in about 50 episodes | |
#Solves BipedalWalker-v2 in about 1000 |