Skip to content

Instantly share code, notes, and snippets.

@gt3
gt3 / Understanding_Code_GNN_cs224w.ipynb
Created March 23, 2023 03:48
Understanding Code with Graph Neural Networks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gt3
gt3 / min-char-rnn.py
Created November 14, 2021 18:32 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
scaler_features = StandardScaler().fit(build_df[build_df.columns.values[:-1]])
scaled_features = scaler_features.transform(build_df[build_df.columns.values[:-1]])
scaler_label = StandardScaler().fit(np.array(build_df[build_df.columns.values[-1]]).reshape(-1, 1))
scaled_label = scaler_label.transform(np.array(build_df[build_df.columns.values[-1]]).reshape(-1, 1))
### Split data using train proportion of 0.7
train_size = int(scaled_features[:, :-1].shape[0] * 0.7)
@gt3
gt3 / multipleActionEnhancer.md
Created December 27, 2018 18:17 — forked from Aldredcz/multipleActionEnhancer.md
Redux - enhance store to process multiple batched actions

Usable mainly when reducer is more like assembler for your data store changes, and main logic is put into action. So you often need to dispatch multiple smaller action, but to keep it atomic, they have to be processed in a single reduce step. This is the solution. The bonus is, it works well with devTools also.

Sourcecode:

multipleActionEnhancer.js:

export function multipleActionsEnhanceReducer(reducer) {
	return (state, action, ...rest) => {
		if (action.actions && action.actions.type && action.actions instanceof Array) {
			state = action.actions.reduce(reducer, state);
		} else {
@gt3
gt3 / timeago.js
Created January 20, 2018 23:17 — forked from IbeVanmeenen/timeago.js
TimeAgo - ES6
// Epochs
const epochs = [
['year', 31536000],
['month', 2592000],
['day', 86400],
['hour', 3600],
['minute', 60],
['second', 1]
];
@gt3
gt3 / debounce-demo.js
Created August 5, 2017 22:11
throttle debounce with csp channels
/***** demo: debounce *****/
let dIn = chan(buffers.dropping(1)),
j = 1
let schedulePuts = () => setTimeout(() => putAsync(dIn, j++), j * 10)
let printAndInc = msg => {
if (msg >= 20) dIn.close()
console.log(msg)
}
throttle(printAndInc, 500, dIn)
@gt3
gt3 / install.sh
Last active July 25, 2017 18:09
starter npm installs
npm i -D gist:eb3f2c746d399500ec5d8937ecee59b3
npm i -D babel-jest babel-plugin-external-helpers babel-plugin-rewire babel-plugin-transform-es2015-destructuring babel-plugin-transform-es2015-modules-commonjs babel-plugin-transform-es2015-template-literals babel-preset-es2016 babel-preset-stage-2 cross-env eslint jest
npm i -D rollup rollup-plugin-babel rollup-plugin-uglify uglify-es rollup-plugin-node-resolve rollup-plugin-commonjs
@import url('https://fonts.googleapis.com/css?family=Nixie+One');
.fizzbuzz {
width: 700px;
font: normal 2em consolas;
color: rgba(110, 110, 110, 1);
}
.cell {
display: table-cell;
let arr = [1, 2, 3], res = [];
function later(i) {
console.log('sched:', i)
return new Promise((res, rej) => {
setTimeout(() => {
console.log('resolve:', i)
res(i)
}, 1000*i)
})
@gt3
gt3 / reset.min.css
Created July 9, 2017 03:26
reset css
/* reset.css by @rich_clark */
article,aside,details,figcaption,figure,footer,header,hgroup,hr,menu,nav,section{display:block}a,hr{padding:0}abbr,address,article,aside,audio,b,blockquote,body,canvas,caption,cite,code,dd,del,details,dfn,div,dl,dt,em,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,html,i,iframe,img,ins,kbd,label,legend,li,mark,menu,nav,object,ol,p,pre,q,samp,section,small,span,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,ul,var,video{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:0 0}ins,mark{background-color:#ff9;color:#000}body{line-height:1}nav ul{list-style:none}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:'';content:none}a{margin:0;font-size:100%;vertical-align:baseline;background:0 0}ins{text-decoration:none}mark{font-style:italic;font-weight:700}del{text-decoration:line-through}abbr[title],dfn[title]{border-bottom:1px dotted;cursor:help}table{border-collapse:collapse;bo