Skip to content

Instantly share code, notes, and snippets.

@Ely-S
Ely-S / gaussianBlur.ts
Last active March 26, 2024 00:48
Gaussian Blur in Tensorflow.JS
import * as tf from '@tensorflow/tfjs';
import { Tensor3D, Tensor2D, Tensor1D, Tensor4D, Tensor } from '@tensorflow/tfjs';
function get1dGaussianKernel(sigma, size): Tensor1D {
// Generate a 1d gaussian distribution across a range
var x = tf.range(Math.floor(-size / 2) + 1, Math.floor(size / 2) + 1)
x = tf.pow(x, 2)
x = tf.exp(x.div(-2.0 * (sigma * sigma))) as Tensor1D
x = x.div(tf.sum(x))
@Ely-S
Ely-S / D&D Rules.md
Last active November 28, 2016 00:56

The Setting

You will inhabit a small, unexplored world. There are no maps. There are no empires. There are no institutions of grandeur.

You will live in a small town, surrounded by a forrest at the foot of a great mountain. You are aware of only 2 other towns in the world. Travel is severly limited by the wild-things in the forrest.

You must seek out powerful items and larger markets.

Races

#!/usr/bin ipython
import numpy as np
# data
X = np.asarray([(1.0, 1.0), (1.5, 2.0), (3.0, 4.0), (5.0, 7.0), (3.5, 5.0), (4.5, 5.0), (3.5, 4.5)])
# Loyds algorithm with Forgy method
import random
# euclidian distance
@Ely-S
Ely-S / LICENSE.txt
Created December 2, 2012 23:16 — forked from 140bytes/LICENSE.txt
140byt.es -- Fast and recursive object extend/clon
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@Ely-S
Ely-S / Deep extend.js
Created December 2, 2012 22:55
Fastest way to Deep Clone/Extend an object in javascript
//benchmark available here
// clone is the object to recursively copy the attributes of obj to overwriting as necessary.
function x(clone, obj) {
for(var i in obj)
clone[i] = (typeof obj[i] == "object") ? x(obj[i].constructor(), obj[i]) : obj[i];
return clone;
}