Skip to content

Instantly share code, notes, and snippets.

View ghamarian's full-sized avatar

Amir Ghamarian ghamarian

View GitHub Profile
@ghamarian
ghamarian / multi_class.py
Created August 19, 2018 10:06
multi-class regression
import numpy as np
# Generate synthetic data
N = 100
# Zeros form a Gaussian centered at (-1, -1)
# epsilon is .1
x_zeros = np.random.multivariate_normal(
mean=np.array((-1, -1)), cov=.1*np.eye(2), size=(N/2,))
y_zeros = np.zeros((N/2,))
# Ones form a Gaussian centered at (1, 1)
# epsilon is .1
@ghamarian
ghamarian / graph-creator.js
Created September 2, 2018 19:10
force layout
document.onload = (function (d3, saveAs, Blob, undefined) {
"use strict";
// define graphcreator object
let GraphCreator = function (svg, nodes, edges) {
let thisGraph = this;
thisGraph.idct = 0;
thisGraph.nodes = nodes || [];
thisGraph.edges = edges || [];
@ghamarian
ghamarian / graph-creator.js
Created September 2, 2018 21:20
woring cola, used cola.js locally and not from the cdn.
document.onload = (function (d3, saveAs, Blob, undefined) {
"use strict";
// define graphcreator object
let GraphCreator = function (svg, nodes, edges) {
let thisGraph = this;
thisGraph.idct = 0;
thisGraph.nodes = nodes || [];
thisGraph.edges = edges || [];
@ghamarian
ghamarian / smallnonoverlappinggraph.html
Created September 2, 2018 21:30
cola with good tick function
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Non-overlapping Layout</title>
<style>
.node {
stroke: #fff;
runtime: python37
api_version: 1
entrypoint: dfweb.py
handlers:
- url: /.*
script: dfweb.py
SQLAlchemy==1.2.10
https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.10.1-py3-none-any.whl
lark-parser
matplotlib==2.2.2
Keras==2.2.0
Flask_SocketIO==3.0.1
numpy==1.14.5
lime==0.1.1.32
Flask_SQLAlchemy==2.3.2
Flask_Login==0.4.1
@ghamarian
ghamarian / select
Created November 5, 2018 17:20
select and jquery
$('select').on('change', function () {
$(this).find('option').attr('selected', false);
$(this).find('option[value=' + $(this).val() + ']').attr('selected', true);
});
$('select').on('change', function () {
$(this).find('option').attr('selected', false);
$(this).find(`option[value=${$(this).val()}]`).attr('selected', true);
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="cytocreator.css"/>
<link rel="stylesheet" href="cytoscape-context-menus.css"/>
</head>
<body>
document.addEventListener('DOMContentLoaded', function () {
let selected_color = '#666666';
let white = '#ffffff';
let cy = cytoscape({
// container: $('#cy'), // container to render in
container: document.getElementById('cy'), // container to render in
elements: [ // list of graph elements to start with
{ // node a