Skip to content

Instantly share code, notes, and snippets.

// Predict predicts for a given complex C if it belongs to the mandelbrot set or not
func Predict(svc *machinelearning.MachineLearning, c complex128) bool {
params := &machinelearning.PredictInput{
MLModelId: aws.String(modelID),
PredictEndpoint: aws.String(endpointURL),
Record: map[string]*string{
"real": aws.String(fmt.Sprintf("%.6f", real(c))),
"imag": aws.String(fmt.Sprintf("%.6f", imag(c))),
},
}
@orcaman
orcaman / msort.c
Created January 1, 2017 20:19
Merge Sort - C
#include <stdio.h>
#include <stdlib.h>
int *merge(int *left, size_t leftSize, int *right, size_t rightSize) ;
int *mergeSort(int *a, size_t len) ;
const int ARRAY_SIZE = 1000000;
int main() {
int a[ARRAY_SIZE];
// MergeSortMulti sorts the slice s using Merge Sort Algorithm
func MergeSortMulti(s []int) []int {
if len(s) <= 1 {
return s
}
n := len(s) / 2
wg := sync.WaitGroup{}
wg.Add(2)
package msort
import "testing"
var a []int
func init() {
for i := 0; i < 1000000; i++ {
a = append(a, i)
}
var sem = make(chan struct{}, 100)
// MergeSortMulti sorts the slice s using Merge Sort Algorithm
func MergeSortMulti(s []int) []int {
if len(s) <= 1 {
return s
}
n := len(s) / 2
@orcaman
orcaman / main.py
Created January 23, 2017 16:37
3 hidden layers neural network / mnist prediction using tensorflow
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
'''
1. first feed forward the data:
input -> weights -> hidden layer 1 -> activation ->
weights -> hidden layer 2 -> activation ->
weights -> output layer
2. Compute cost function (cross entropy) to figure out how close we are
@orcaman
orcaman / fnvbench_test.go
Created April 1, 2017 14:50
Test fnv32 - bytes version
package fnvbench
import (
"hash/fnv"
"math/rand"
"testing"
)
const (
maxElems = 10000000
@orcaman
orcaman / mov2webm.sh
Created June 25, 2017 13:37
mov to webm using ffmpeg
ffmpeg -i trailer.mov -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis trailer.webm
@orcaman
orcaman / MergeSort.go
Created January 1, 2017 20:39
MergeSort.go
// MergeSort sorts the slice s using Merge Sort Algorithm
func MergeSort(s []int) []int {
if len(s) <= 1 {
return s
}
n := len(s) / 2
var l []int
func merge(l, r []int) []int {
ret := make([]int, 0, len(l)+len(r))
for len(l) > 0 || len(r) > 0 {
if len(l) == 0 {
return append(ret, r...)
}
if len(r) == 0 {
return append(ret, l...)
}
if l[0] <= r[0] {