Skip to content

Instantly share code, notes, and snippets.

View alivcor's full-sized avatar
🌴
I may be slow to respond.

Abhinandan Dubey alivcor

🌴
I may be slow to respond.
View GitHub Profile
@alivcor
alivcor / versioning
Created October 30, 2020 22:40
VersioningGroovy
class GroovyIncrementalVersioning {
/*
* Created by @alivcor (Abhinandan Dubey) on 10/26/20
* Licensed under the Mozilla Public License Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
@alivcor
alivcor / Car.java
Created March 22, 2020 22:42
Builder Pattern - Car
public class Car {
private int modelYear;
private String modelName;
private String color;
private String manufacturer;
private double sellingPrice;
private String carType;
private Boolean isLuxury;
private Boolean isImported;
@alivcor
alivcor / arecibo.py
Created August 3, 2017 02:18
print arecibo message
print("00000010101010000000000\n00101000001010000000100\n10001000100010010110010\n10101010101010100100100\n00000000000000000000000\n00000000000011000000000\n00000000001101000000000\n00000000001101000000000\n00000000010101000000000\n00000000011111000000000\n00000000000000000000000\n11000011100011000011000\n10000000000000110010000\n11010001100011000011010\n11111011111011111011111\n00000000000000000000000\n00010000000000000000010\n00000000000000000000000\n00001000000000000000001\n11111000000000000011111\n00000000000000000000000\n11000011000011100011000\n10000000100000000010000\n11010000110001110011010\n11111011111011111011111\n00000000000000000000000\n00010000001100000000010\n00000000001100000000000\n00001000001100000000001\n11111000001100000011111\n00000000001100000000000\n00100000000100000000100\n00010000001100000001000\n00001100001100000010000\n00000011000100001100000\n00000000001100110000000\n00000011000100001100000\n00001100001100000010000\n00010000001000000001000\n00100000001100000000100\n01000000001100000
@alivcor
alivcor / printIntVector.cpp
Last active June 8, 2017 20:50
C++ Function to print contents of an unnested Int Vector
#include <iostream>
#include "vector"
#include "string"
using namespace std;
void printIntVector(vector<int>& nums){
string s;
for(auto it = nums.begin();it!=nums.end(); ++it){
s.append(to_string(*it));
@alivcor
alivcor / randPartition.py
Last active September 18, 2017 04:07
Random Indices for train and test
import numpy as np
import random
def randPartition(alldata_X, alldata_Y, _FRACTION):
"""
alldata_X : All of your X (Features) data
alldata_Y : All of your Y (Prediction) data
_FRACTION : The fraction of data rows you want for train (0.75 means you need 75% of your data as train and 25% as test)
"""
@alivcor
alivcor / update_plot.py
Created March 16, 2017 18:11
Updating A Plot in Matplotlib
#Bonus: If you want to handle events on keypress:
#http://matplotlib.org/examples/event_handling/keypress_demo.html
#Inspired by cnn_train in MatConvNet ?? :p (Please ignore if you do not understand - you're not supposed to !)
import math
import matplotlib.pyplot as plt
import numpy as np
# +
@alivcor
alivcor / append_tf.py
Created March 1, 2017 03:17
Appending to a tensor/list in TensorFlow
import tensorflow as tf
#If you're frustrated with tensorflow, and just want to do a simple task of creating a tensor type list and append to it, you're at the right place. The author of this gist was in the same place at the time of writing this gist. And stackoverflow sucks. TF documentation is outdated, help is limited. Have fun !
sess = tf.InteractiveSession()
matrix1 = tf.constant([[1., 2., 3., 4., 5., 6.], [3., 1., 2., 2., 0., 1.]])
matrix2 = tf.constant([[2., 0., 1., 9., 3., 2.5], [1.8, 2.5, 9.4, 1., 0.3, 3.1]])
#lets make a 6x6 matrix by append
@alivcor
alivcor / remove_row.py
Created March 1, 2017 03:14
Removing a row from a tensor in TensorFlow
import tensorflow as tf
sess = tf.InteractiveSession()
matrix1 = tf.constant([[1., 2., 3., 4., 5., 6.], [3., 1., 2., 2., 0., 1.]])
matrix2 = tf.constant([[2., 0., 1., 9., 3., 2.5], [1.8, 2.5, 9.4, 1., 0.3, 3.1]])
#lets make a 6x6 matrix by append
A = tf.concat([matrix2], 0) #Now A is a 2 x 6 tensor
A = tf.concat([A, matrix1], 0) #Now A is a 4 x 6 tensor
@alivcor
alivcor / bubbles.js
Created February 3, 2017 16:10
BubblesView - A Bubbles View Generator Using D3
var sampleSVG = d3.select("#bubbles")
.append("svg")
.attr("width", 960)
.attr("height", 960);
var mydata = [];
d3.csv("/baseball_data.csv", function(data) {
data.forEach(function(d) {
d["HR"] = +d["HR"];
mydata.push(+d["HR"]);
@alivcor
alivcor / js
Created February 3, 2017 03:37
A Jardinains Animation in D3
var sampleSVG = d3.select("#viz")
.append("svg")
.attr("width", 800)
.attr("height", 800);
var barrier = sampleSVG.append("line")
.attr("x1", 120)
.attr("y1", 540)
.attr("x2", 280)
.attr("y2", 540)