Skip to content

Instantly share code, notes, and snippets.

@souparno
souparno / Combination Constructor & Prototype Pattern
Last active Jan 4, 2016 — forked from zacksleo/JavaScript Class
Combination Constructor & Prototype Pattern
View Combination Constructor & Prototype Pattern
/**
* Combination Constructor/Prototype Pattern
*/
//constructor
function Something(name){
//properties
this.name = name;
}
//prototype
View router.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Building a router</title>
<script>
// Put John's template engine code here...
(function () {
// A hash to store our routes:
View cors.js
/**
* Make a X-Domain request to url and callback.
*
* @param url {String}
* @param method {String} HTTP verb ('GET', 'POST', 'DELETE', etc.)
* @param data {String} request body
* @param callback {Function} to callback on completion
* @param errback {Function} to callback on error
*/
function xdr(url, method, data, callback, errback) {
View getApp.js
var app = require("express")();
app.get('/user', function(req, res){
res.send(200, { name: 'marcus' });
});
// In order to reach the app from other modules
// we need to export the express application
module.exports.getApp = app;
@souparno
souparno / gist:f077cb03f0339514bbcc
Created Nov 28, 2015 — forked from zachstronaut/gist:1184900
Stretch HTML5 canvas to fill window, preserving aspect ratio
View gist:f077cb03f0339514bbcc
/**
* fullscreenify()
* Stretch canvas to size of window.
*
* Zachary Johnson
* http://www.zachstronaut.com/
*
* See also: https://gist.github.com/1178522
*/
View gist:851ea9c78f5bde4fef12e41492ce066a
/*
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
View minimal-neuron.js
/*
A neuron is basically the sum of its synapses.
Along with a trigger threshold, that's all we need to calculate
whether or not it will trigger at any given moment:
*/
const neuron = ({ synapses = [], threshold = 1 } = {}) => ({
synapses,
threshold
});
@souparno
souparno / min-char-rnn.py
Created Jan 1, 2018 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
View min-char-rnn.py
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@souparno
souparno / waya-dl-setup.sh
Created Jan 30, 2018 — forked from mjdietzx/waya-dl-setup.sh
Install CUDA Toolkit v8.0 and cuDNN v6.0 on Ubuntu 16.04
View waya-dl-setup.sh
#!/bin/bash
# install CUDA Toolkit v8.0
# instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb (network))
CUDA_REPO_PKG="cuda-repo-ubuntu1604_8.0.61-1_amd64.deb"
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/${CUDA_REPO_PKG}
sudo dpkg -i ${CUDA_REPO_PKG}
sudo apt-get update
sudo apt-get -y install cuda
@souparno
souparno / app.html
Created Nov 30, 2018 — forked from derekchiang/app.html
[electron]Use electron as a Web Server
View app.html
<!doctype html>
<html><head><script src="app.js"></script></head><body></body></html>