Skip to content

Instantly share code, notes, and snippets.

@vsalvati
vsalvati / GCD.scala
Created October 24, 2012 18:24
GCD in scala
package main.scala
object GCD
{
def gcd(a: Int,b: Int): Int = {
if(b ==0) a else gcd(b, a%b)
}
def main(args: Array[String]) {
println(gcd(25,15))
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var width = 700;
var height = 700;
var mainRadius = 200;
var center = {x: 0, y: height/2};
var points = [];
//create distorted circle
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var width = 700;
var height = 700;
var center = {x: width/2 , y: height/2};
var circleStroke = function(radius, x, y, strokeColor) {
ctx.strokeStyle = strokeColor;
ctx.beginPath();
ctx.arc(x, y, radius, 0, Math.PI * 2);
@DominicBreuker
DominicBreuker / gd_simple.py
Created June 16, 2016 16:30
Simple example of gradient descent in tensorflow
import tensorflow as tf
x = tf.Variable(2, name='x', dtype=tf.float32)
log_x = tf.log(x)
log_x_squared = tf.square(log_x)
optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(log_x_squared)
init = tf.initialize_all_variables()
@derhuerst
derhuerst / howto.md
Created August 28, 2016 11:41
abbey road meets deep dream
  • Linux system with >=4GB RAM and Docker installed.
  • git clone https://github.com/ryankennedyio/deep-dream-generator.git
  • `docker run -d -p 8888:8888 -e PASSWORD=foo -v /root/deep-dream-generator:/src ryankennedyio/deepdream
  • docker ps -> copy container id
  • docker exec -it <container> bash
    • cd /src
    • rm input.jpg
    • wget -O input.jpg 'http://d817ypd61vbww.cloudfront.net/sites/default/files/styles/media_responsive_widest/public/tile/image/AbbeyRoad.jpg'
  • open https://<hostname>:8888/, pass self-signed certificate warning, enter password
  • open the dream.ipynb IPython Notebook
@mutterer
mutterer / 10PRINT 'rosette'.pde
Last active October 2, 2017 04:25
// 10PRINT rosette Processing 3 code, thanks to @shiffman !
// 10PRINT rosette Processing 3 code
// thanks to @shiffman !
float r=20;
float s=10;
void setup() {
size(300, 300);
frameRate(1);
}