Skip to content

Instantly share code, notes, and snippets.

View edubart's full-sized avatar

Eduardo Bart edubart

View GitHub Profile
#include "complex.h"
#include <math.h>
typedef struct COMPLEX {
float r, i;
} complex;
void comPrint(complex a);
complex comMul(complex a, complex b);
@edubart
edubart / gist:1431131
Created December 4, 2011 20:02
kdevelop master for ubuntu
#!/bin/bash
cd /tmp
sudo apt-get -y install kdelibs5-dev kdebase-workspace-dev
git clone git://anongit.kde.org/kdevplatform
cd kdevplatform
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
make -j8
sudo make install
kbuildsycoca4
@edubart
edubart / vpn.sh
Last active June 6, 2017 19:17
vpn through pppd
#!/bin/bash
interface=eth0
address=
gateway=
broadcast=
netmask=
vpn_local=10.0.0.1
vpn_remote=10.0.0.2
ssh_user=root
@edubart
edubart / naive.lua
Created October 9, 2015 15:58
Gaussian Naive Bayers Classifier
require 'torch'
_ = require 'moses'
csv2tensor = require 'csv2tensor'
local dataset = csv2tensor.load('pima-indians-diabetes.data')
local trainRatio = 0.67
local dataSize = dataset:size(1)
local trainSize = torch.floor(dataSize * trainRatio)
local testSize = dataSize - trainSize
@edubart
edubart / linearregression.h
Last active October 15, 2015 01:40
Linear Regression With Armadillo
#ifndef LINEARREGRESSION_H
#define LINEARREGRESSION_H
#include "global.h"
class LinearRegression
{
public:
void fit(arma::mat X, const arma::mat& y, double alpha = 0.1, ulong numIterations = 500) {
prepareNormalization(X, mu, sigma);
@edubart
edubart / euler50.m
Last active July 13, 2016 15:32
Euler 50 problem
% O primo 41 pode ser escrito como a soma de 6 primos consecutivos
% 41 = 2 + 3 + 5 + 7 + 11 + 13
% Essa eh a a soma mais longa de primos consecutivos menor
% que 100 em que resulta em tambem em um numero primo, ela contem 6 termos
% A soma mais longa de primos consecutivos menor que 1000 em que resulta
% um numero primo eh 953 com 21 termos
%
% Qual primo menor que 1 milhao pode ser escrito como a soma mais longa
@edubart
edubart / nimbenchmark.md
Last active August 18, 2021 13:55
Nim/Node benchmarks

Environment:

  • Ubuntu 16.04 LTS
  • Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz
  • Nim Compiler Version 0.14.3 (2016-06-17) [Linux: amd64]
  • node v5.10.1

Nim code:

import asynchttpserver, asyncdispatch
@edubart
edubart / arraymancer_play.nim
Created September 14, 2017 00:12
Testing arraymancer
import ../src/arraymancer
import math
proc `/`*[T: SomeNumber](a: T, t: Tensor[T]): Tensor[T] {.noSideEffect.} =
return t.fmap(proc(x: T): T = a / x)
proc `+`*[T: SomeNumber](t: Tensor[T], a: T): Tensor[T] {.noSideEffect.} =
return t.fmap(proc(x: T): T = x + a)
proc `+`*[T: SomeNumber](a: T, t: Tensor[T]): Tensor[T] {.noSideEffect.} =
@edubart
edubart / arraymancer_utils.nim
Last active September 23, 2017 19:01
Arraymancer Utilities
# Seq of tensors to tensor
proc toTensor*[T](s: openarray[Tensor[T]]): Tensor[T] =
s.map(proc(t: Tensor[T]): Tensor[T] = t.unsafeUnsqueeze(0)).concat(0)
# Make universal does not work with abs
proc abs*[T](t: Tensor[T]): Tensor[T] =
t.map(proc(x: T):T = abs(x))
# Seq to reshaped tensor, no copy
proc unsafeToTensorReshape[T](data: seq[T], shape: openarray[int]): Tensor[T] {.noSideEffect.} =
########## Shape Array
const MAXRANK* = 8
type
ShapeArray* = object
data: array[MAXRANK, int]
len: int
proc newShapeArray*(len: int): ShapeArray {.inline.} =