Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul leeyspaul

  • San Francisco, CA
View GitHub Profile
@leeyspaul
leeyspaul / v1.py
Last active Jul 31, 2018
Final project v1. (Inspiration from babi_rnn by Keras team - Taken from Jupyter Notebook)
View v1.py
import os
import numpy as np
import pandas as pd
from keras.preprocessing.text import text_to_word_sequence, Tokenizer
from keras.preprocessing.sequence import pad_sequences
from keras.models import Sequential, Model
from keras.layers import Dense, Flatten, Embedding, Input, Concatenate, Add, RepeatVector, RNN, LSTM, Dot, Dropout
from keras.optimizers import Adam, SGD
from keras.metrics import categorical_accuracy
from itertools import chain
@leeyspaul
leeyspaul / txt_to_raw.py
Created Jul 31, 2018
Generate .txt file to raw corpus (Code snippet)
View txt_to_raw.py
def txt_to_raw(file_name):
'''
take in a file_name and then return a raw String corpus of the contained text
'''
with open(file_name, 'r') as file:
raw_corpus = file.readlines()
return raw_corpus
task_training_corpus = txt_to_raw(task_training)
task_testing_corpus = txt_to_raw(task_testing)
@leeyspaul
leeyspaul / unique_vocabs.py
Created Jul 31, 2018
Unique Vocab Generator for Facebook bABI Project (Snippet - Missing other parts)
View unique_vocabs.py
def get_unique_vocab(file_name):
with open(file_name,'r') as file:
raw_corpus = file.read()
tokenized = text_to_word_sequence(raw_corpus, filters='\n\t?123456789101112131415.')
return set(tokenized + ['.'])
vocab = get_unique_vocab(task_training)
print(f'Vocabulary set\n---\n {vocab}')
@leeyspaul
leeyspaul / cDecipher.kt
Created Jul 31, 2018
Caeser Decipher in Kotlin
View cDecipher.kt
// Top level declaration of the alphabet array
val alphabet = arrayOf('a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
@leeyspaul
leeyspaul / explanation.md
Last active Mar 10, 2021
Codewars Challenge: "Remove the Minimum" by user:bkaes (https://www.codewars.com/users/bkaes)
View explanation.md

My solution

function removeSmallest(numbers) {
  // First step is to remove the smallest value given array
  // Filter the smallest number out with Math.min.apply
  let smallestNumber = Math.min.apply(Math,numbers);
  
  // Now remove the number from the array 
  // Find the index of smallest number
@leeyspaul
leeyspaul / intro.md
Created Nov 18, 2016 — forked from gschema/intro.md
Basic JavaScript MVC Implementation
View intro.md

Basic JavaScript MVC Implementation

Despite being derived from classical MVC pattern JavaScript and the environment it runs in makes Javascript MVC implementation have its own twists. Lets see how typical web MVC functions and then dive into simple, concrete JavaScript MVC implementation.

How Web MVC typically works

Typical server-side MVC implementation has one MVC stack layered behind the singe point of entry. This single point of entry means that all HTTP requests, e.g. http://www.example.com or http://www.example.com/whichever-page/ etc., are routed, by a server configuration, through one point or, to be bold, one file, e.g. index.php.

At that point, there would be an implementation of Front Controller pattern which analyzes HTTP request (URI at first place) and based on it decides which class (Controller) and its method (Action) are to be invoked as a response to the request (method is name for function and member is name for a variable when part of the class/object).

@leeyspaul
leeyspaul / Looping Triangle
Created Feb 23, 2016
JavaScript Looping Triangle Exercise
View Looping Triangle
for ( var y = "#"; y.length <= 7; y += "#" ) {
console.log(y);
}