Skip to content

Instantly share code, notes, and snippets.

View rmdort's full-sized avatar

Vinay M rmdort

View GitHub Profile
@rmdort
rmdort / index.md
Created June 23, 2021 03:16 — forked from bvaughn/index.md
How to use profiling in production mode for react-dom
@rmdort
rmdort / App.web.tsx
Created June 5, 2021 13:05 — forked from arrygoo/App.web.tsx
React Native Web configuration
import React, {useState} from 'react';
import {View, Text, TouchableOpacity, StyleSheet} from 'react-native';
const App = () => {
const [count, setCount] = useState(0);
return (
<View style={styles.container}>
<Text style={styles.title}>Hello from {'\n'}React Native Web!</Text>
<TouchableOpacity
onPress={() => setCount(count + 1)}
@rmdort
rmdort / package.json
Created May 11, 2021 13:11 — forked from jayphelps/package.json
TypeScript output es2015, esm (ES Modules), CJS, UMD, UMD + Min + Gzip. Assumes you install typescript (tsc), rollup, uglifyjs either globally or included as devDependencies
{
"scripts": {
"build": "npm run build:es2015 && npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:umd:min",
"build:es2015": "tsc --module es2015 --target es2015 --outDir dist/es2015",
"build:esm": "tsc --module es2015 --target es5 --outDir dist/esm",
"build:cjs": "tsc --module commonjs --target es5 --outDir dist/cjs",
"build:umd": "rollup dist/esm/index.js --format umd --name YourLibrary --sourceMap --output dist/umd/yourlibrary.js",
"build:umd:min": "cd dist/umd && uglifyjs --compress --mangle --source-map --screw-ie8 --comments --o yourlibrary.min.js -- yourlibrary.js && gzip yourlibrary.min.js -c > yourlibrary.min.js.gz",
}
}
@rmdort
rmdort / keycodes.ts
Created July 7, 2020 15:21 — forked from kyranjamie/keycodes.ts
TypeScript Browser Key Codes Enum
enum keyCodes {
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
PAUSE: 19,
CAPS_LOCK: 20,
ESCAPE: 27,
@rmdort
rmdort / numberformat.js
Created October 21, 2018 14:19
number_format(number, decimals, decPoint, thousandsSep) in JavaScript, known from PHP. It formats a number to a string with grouped thousands, with custom seperator and custom decimal point Demo: https://jsbin.com/yuremoyalu/edit?js,console
/**
* number_format(number, decimals, decPoint, thousandsSep) in JavaScript, known from PHP.
* It formats a number to a string with grouped thousands, with custom seperator and custom decimal point
* @param {number} number - number to format
* @param {number} [decimals=0] - (optional) count of decimals to show
* @param {string} [decPoint=.] - (optional) decimal point
* @param {string} [thousandsSep=,] - (optional) thousands seperator
* @author Felix Leupold <[email protected]>
*/
function number_format(number, decimals, decPoint, thousandsSep) {
@rmdort
rmdort / spacy_srl.py
Created January 27, 2018 03:09 — forked from chssch/spacy_srl.py
Use AllenNLP Semantic Role Labeling (http://allennlp.org/) with SpaCy 2.0 (http://spacy.io) components and extensions
# This small script shows how to use AllenNLP Semantic Role Labeling (http://allennlp.org/) with SpaCy 2.0 (http://spacy.io) components and extensions
# Script installs allennlp default model
# Important: Install allennlp form source and replace the spacy requirement with spacy-nightly in the requirements.txt
# Developed for SpaCy 2.0.0a18
from allennlp.commands import DEFAULT_MODELS
from allennlp.common.file_utils import cached_path
from allennlp.service.predictors import SemanticRoleLabelerPredictor
from allennlp.models.archival import load_archive
@rmdort
rmdort / threading_example.py
Created January 8, 2018 09:14 — forked from sebdah/threading_example.py
Running a background thread in Python
import threading
import time
class ThreadingExample(object):
""" Threading example class
The run() method will be started and it will run in the background
until the application exits.
"""
@rmdort
rmdort / Attention.py
Created August 1, 2017 14:24 — forked from cbaziotis/Attention.py
Keras Layer that implements an Attention mechanism for temporal data. Supports Masking. Follows the work of Raffel et al. [https://arxiv.org/abs/1512.08756]
def dot_product(x, kernel):
"""
Wrapper for dot product operation, in order to be compatible with both
Theano and Tensorflow
Args:
x (): input
kernel (): weights
Returns:
"""
if K.backend() == 'tensorflow':
@rmdort
rmdort / attention_lstm.py
Created August 1, 2017 14:23 — forked from mbollmann/attention_lstm.py
My attempt at creating an LSTM with attention in Keras
class AttentionLSTM(LSTM):
"""LSTM with attention mechanism
This is an LSTM incorporating an attention mechanism into its hidden states.
Currently, the context vector calculated from the attended vector is fed
into the model's internal states, closely following the model by Xu et al.
(2016, Sec. 3.1.2), using a soft attention model following
Bahdanau et al. (2014).
The layer expects two inputs instead of the usual one:
@rmdort
rmdort / AttentionWithContext.py
Last active February 10, 2021 14:02 — forked from cbaziotis/AttentionWithContext.py
Keras Layer that implements an Attention mechanism, with a context/query vector, for temporal data. Supports Masking. Follows the work of Yang et al. [https://www.cs.cmu.edu/~diyiy/docs/naacl16.pdf] "Hierarchical Attention Networks for Document Classification"
class AttentionWithContext(Layer):
"""
Attention operation, with a context/query vector, for temporal data.
Supports Masking.
Follows the work of Yang et al. [https://www.cs.cmu.edu/~diyiy/docs/naacl16.pdf]
"Hierarchical Attention Networks for Document Classification"
by using a context vector to assist the attention
# Input shape
3D tensor with shape: `(samples, steps, features)`.
# Output shape