Skip to content

Instantly share code, notes, and snippets.

View kostasx's full-sized avatar
💭
Uncaught ReferenceError

Kostas Minaidis kostasx

💭
Uncaught ReferenceError
View GitHub Profile
Descendant selector: You can use a space to denote a descendant selector. This matches all elements which are descendants of a specified element.
Child selector: Use a greater than symbol (>) to select all elements that are immediate children of a specified element.
Adjacent sibling selector: Use a plus sign (+) to select all elements that are adjacent siblings of a specified element. They must have the same parent and immediately follow this element.
General sibling selector: Use a tilde (~) to select all elements that are siblings of an element.
Static: the default positioning of HTML elements.
Fixed: Element is positioned relative to the viewport and stays in the same place even if the page is scrolled. It’s also removed from the document flow. So elements in the DOM pretend like it’s not even there!
Relative: Element is positioned relative to its normal position.
Absolute: Element is positioned relative to the nearest relatively positioned ancestor. If no ancestor with position of relative is found, the element positions against the document body.
Short-circuit? Short-circuits on? Fulfilled on? Rejected on?
Promise.all Yes First rejected promise All promise fulfilled First rejected promise
Promise.allSettled No N/A Always N/A
Promise.race Yes First settled First promise fulfilled First rejected promise
Promise.any Yes First fulfilled First promise fulfilled All rejected promises
function ComputeSMA(data, window_size)
{
let r_avgs = [], avg_prev = 0;
for (let i = 0; i <= data.length - window_size; i++){
let curr_avg = 0.00, t = i + window_size;
for (let k = i; k < t && k <= data.length; k++){
curr_avg += data[k]['price'] / window_size;
}
r_avgs.push({ set: data.slice(i, i + window_size), avg: curr_avg });
avg_prev = curr_avg;
async function trainModel(inputs, outputs, trainingsize, window_size, n_epochs, learning_rate, n_layers, callback){
const input_layer_shape = window_size;
const input_layer_neurons = 100;
const rnn_input_layer_features = 10;
const rnn_input_layer_timesteps = input_layer_neurons / rnn_input_layer_features;
const rnn_input_shape = [rnn_input_layer_features, rnn_input_layer_timesteps];
const rnn_output_neurons = 20;
@dlebech
dlebech / tokenizer.js
Last active August 11, 2022 13:34
Keras text tokenizer in JavaScript with minimal functionality
// Public Domain CC0 license. https://creativecommons.org/publicdomain/zero/1.0/
class Tokenizer {
constructor(config = {}) {
this.filters = config.filters || /[\\.,/#!$%^&*;:{}=\-_`~()]/g;
this.lower = typeof config.lower === 'undefined' ? true : config.lower;
// Primary indexing methods. Word to index and index to word.
this.wordIndex = {};
this.indexWord = {};
@mikowl
mikowl / oneliners.js
Last active February 19, 2025 05:20
👑 Awesome one-liners you might find useful while coding.
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// or
const sleep = util.promisify(setTimeout);
@zed-dz
zed-dz / offline_mdn_docs.md
Created March 12, 2019 14:01
Offline MDN Docs
// form_container.js
import { connect } from 'react-redux';
import { ReduxControlledComponent } from './components';
const mapStateToProps = (state) => {
return {
name: state.name,
email: state.email,
password: state.password
}