Skip to content

Instantly share code, notes, and snippets.

View phraniiac's full-sized avatar
🎯
Focusing

Pranav Sharma phraniiac

🎯
Focusing
View GitHub Profile
// Single Element
// ---
var Nav;
// Define Nav as tag, component, anything.
// Input (JSX): To be written by you.
var app = <Nav color="blue"/>;
// Output (JS): Compiled and converted to this by Babel.
// Form Declaration.
var MyFormComponent = React.createClass({ ... });
// Subcomponents declaration.
MyFormComponent.Row = React.createClass({ ... });
MyFormComponent.Label = React.createClass({ ... });
MyFormComponent.Input = React.createClass({ ... });
// Actual app.
var App = (
// Input (JSX):
var person = <Person name={window.isLoggedIn ? window.name : ''}>;
// Output (JS):
var person = React.createElement(
Person,
{name: window.isLoggedIn ? window.name : ''}
// Input (JSX):
var content = <Container>{window.isLoggedIn ? <Nav /> : <Login />}</Container>;
// Output (JS):
var content = React.createElement(
Container,
null,
window.isLoggedIn ? React.createElement(Nav) : React.createElement(Login)
var props = {};
props.foo = x;
props.bar = y;
// Write your attribute with the props defined.
var component = <Component {...props} />;
//--
// If needs to be changed later, this could be done.
@phraniiac
phraniiac / kmp.cpp
Last active October 11, 2016 02:55
String Algorithms
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
@phraniiac
phraniiac / 2_fullyconnected.ipynb
Last active January 26, 2017 15:29
Assignment 2
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
/*************** 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])
{
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