Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Pranav Sharma phraniiac

🎯
Focusing
Block or report user

Report or block phraniiac

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View lcs.py
def lcs(str1, str2):
l = [[0] * len(str2) for i in range(len(str1))]
for r in range(len(str1)):
for c in range(len(str2)):
if r > 0 and c > 0:
l[r][c] = max(l[r-1][c], l[r][c-1])
if str1[r] == str2[c]:
l[r][c] = max(l[r - 1][c - 1] + 1, l[r][c])
if r == 0 or c == 0:
@phraniiac
phraniiac / kube-registry.yaml
Created Dec 19, 2018 — forked from coco98/kube-registry.yaml
Docker registry on minikube
View kube-registry.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: kube-registry-v0
namespace: kube-system
labels:
k8s-app: kube-registry
version: v0
spec:
replicas: 1
View func_insertion1.py
def process_and_insert(batch):
for tablename in tablenams:
# some processing for each typeof table.
db.insert(batch, tablename)
def insert_function(resultiterator, tablenames):
for batch in iterator_function(resultiterator):
process_and_insert(batch, tablenames)
View summaries_tensorflow_template.py
def variable_summaries(var):
"""Attach a lot of summaries to a Tensor (for TensorBoard visualization)."""
with tf.name_scope('summaries'):
mean = tf.reduce_mean(var)
tf.summary.scalar('mean', mean)
with tf.name_scope('stddev'):
stddev = tf.sqrt(tf.reduce_mean(tf.square(var - mean)))
tf.summary.scalar('stddev', stddev)
tf.summary.scalar('max', tf.reduce_max(var))
tf.summary.scalar('min', tf.reduce_min(var))
View tf_summary_demo_1.py
import numpy as np
import tensorflow as tf
def add_values(num_list):
# making a list of tensors.
tensor_list = tf.constant(num_list, shape=[1, 3], name='tensor_list')
tensor_ten = tf.constant([10] * len(num_list), \
shape=[len(num_list), 1], name='tensor_ten')
# the below statement declares a scope under which the
# variables will be used.
View glove.py
import numpy as np
import tensorflow as tf
from random import shuffle
class Glove:
"""docstring for Glove"""
def __init__(self, corpus, context_size=2, learning_rate=0.05, batch_size=100, num_epochs=100):
super(Glove, self).__init__()
self.corpus = corpus
self.CONTEXT_SIZE = context_size
View kmp.c
/*************** Kmp Functions. ***************/
void compute(int * kmparr, char * pattern, int patternlength) {
int m = patternlength;
kmparr[0] = 0;
int len = 0, i;
for (i = 1; i < m; ++i)
{
if (pattern[i] == pattern[len])
{
View 3_regularized.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View 2_fullyconnected.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@phraniiac
phraniiac / kmp.cpp
Last active Oct 11, 2016
String Algorithms
View kmp.cpp
vector<int> Knuth_Morris_Pratt(string text,string pattern)
{
vector<int> F = build_failure_function(pattern);
vector<int> positions;
int i = 0; // state of automaton
int j = 0; // position of counter in string.
for( ; ; ) {
if(j == n) break; // we reached the end of the text
You can’t perform that action at this time.