Skip to content

Instantly share code, notes, and snippets.

View FractalDesigns's full-sized avatar
🏠
Working from home

Achraf Elafrit FractalDesigns

🏠
Working from home
View GitHub Profile
primitive Handlers
fun handler_F64 (env:Env) =>
env.out.print("handler_F64 is called")
fun handler_F32 (env:Env) =>
env.out.print("handler_F32 is called")
fun else_handler(env:Env) =>
env.out.print("else_handler is called")
fun dispatch(x: (F64|F32|U64), env:Env)=>
@FractalDesigns
FractalDesigns / unitTest.pony
Created June 22, 2016 15:54
unit testing in pony
use "ponytest"
actor Main is TestList
new create(env : Env) => PonyTest(env, this)
new make() => None
fun tag tests (test : PonyTest) =>
//activating the Yeppp library
let status = @yepLibrary_Init[None]()
test(_Polyval)
class iso _Polyval is UnitTest
use "ponytest"
actor Main is TestList
new create(env: Env) =>
PonyTest(env, this)
new make() =>
None
fun tag tests(test: PonyTest) =>
//first you need to install gnu scientific library to run this
#include <stdio.h>
//#include <gsl/gsl_errno.h>
//#include <gsl/gsl_fft_complex.h>
#include <gsl/gsl_complex_math.h>
double sqrt_gsl(double a) {
gsl_complex b = gsl_complex_sqrt_real(a);
return b.dat[0];
}
use "path:."
use "lib:sqrt"
use "path:/usr/local/lib"
use "lib:gsl"
use "lib:gslcblas"
primitive Gsl
fun sqrt(x : F64) : F64 =>
@sqrt_gsl[F64](x)
# testing global scope
def scope2():
global a
a = "defined in scope 2"
def scope3():
scope2()
print a
def scope1():
print a
scope2()
\usepackage{fancyhdr} % use this package to display curret section or chapter in the header
\fancyhf{} % Clear fancy header/footer
\fancyfoot[L]{ Rapport de Stage d'immersion en Entreprise 2016} % My name in Left footer
\renewcommand{\footrulewidth}{0.4pt}
\fancyfoot[R]{Page | \thepage } % Page number in Right footer
\fancyhead[L]{ENSI}
\fancyhead[R]{\rightmark}
@FractalDesigns
FractalDesigns / sumabs.pony
Created April 14, 2017 12:43
function binding to yeppp
fun sumabs2(data: Array[F64]): F64 =>
"""
SciPony notes : Computes the sum of squares of the Array[F64] passed as argument and returns the result.
Yeppp description: Computes the sum of squares of double precision (64-bit) floating-point array elements.
"""
var res: F64 = 0
@yepCore_SumSquares_V64f_S64f[I32](data.cstring(), addressof res, data.size())
res
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --w
import yaml
file = "data.yml"
with open(file, 'r') as stream:
data = yaml.safe_load(stream)
data['pg_conn']['host'] = 'ddaplx27fd9c7c.fr.world.socgen'