Skip to content

Instantly share code, notes, and snippets.

View nfelix25's full-sized avatar
💭
I may be slow to respond.

Noel nfelix25

💭
I may be slow to respond.
View GitHub Profile
@nfelix25
nfelix25 / node_deopt.js
Created December 26, 2025 05:06
V8 switches from fast-maps/hidden classes to a slower path once the shape diversifies.
// Build a predictable shape first (fast-path for V8 hidden classes)
function buildPoint(x, y) {
return { x, y };
}
// Introduce a second property in the same order every time.
function translate(point, dx, dy) {
point.x += dx;
point.y += dy;
return point;
@nfelix25
nfelix25 / example.js
Created December 23, 2021 05:43
Node Inspector example
const { inspectorGadget } = require("../../inspector");
const inspect = inspectorGadget(
// Function to be profiled
(nums) => {
const tree = new AVL();
nums.forEach((n) => tree.add(n));
return { tree, nums };
},
// Function to prepare and provide args to above
// Below can be used to create a new CRUD resource resolver
// Uncomment and replace "resource"/"Resource" w/name
// import { BodegaResource, GetAllResponse, GraphQLContext } from '../../../../types/internal';
// export default {
// Query: {
// /**
// * Gets the data for a single resource
// */
@nfelix25
nfelix25 / HostedFields.js
Last active June 17, 2018 21:07
Working HF React component
import React, { Component } from 'react';
import axios from 'axios';
import bt from 'braintree-web';
const HIPPO_PAY_PATH = 'http://localhost:3000';
const ADMIN_USERS_TOKEN = null;
const token = ADMIN_USERS_TOKEN || 'VALID AUTH';
const ELEMENT_IDS = {
ACCOUNT: 'card-number',
CVV: 'cvv',
@nfelix25
nfelix25 / hf.js
Last active June 16, 2018 01:21
Relevant Hosted Fields code
const authorization = yield UPS('braintree/client_token', token);
const client = yield bt.client.create({ authorization });
async function initHostedFields(client, options) {
const { errorHandler, fieldEventsCallback } = options;
try {
const hostedFields = await(bt.hostedFields.create({
client,
styles: {
'input': {
const _ = require('lodash');
const Sequelize = require('sequelize');
const client = require('uas-data-store');
client.init({
database: {
dropTables: false,
name: 'uas',
host: '127.0.0.1',
dialect: "postgres",
@nfelix25
nfelix25 / flatten.js
Created May 20, 2016 09:29
JavaScript Flatten
function flattenForFun (array) {
return !array.length ? [] : Array.isArray(array.slice(0,1)[0]) ? flattenForFun(array.slice(0,1)[0]).concat(flattenForFun(array.slice(1))) : array.slice(0,1).concat(flattenForFun(array.slice(1)));
}
function flattenRecursive (array) {
if (array.length === 0) {
return [];
}
let next = array.slice(0,1);
let rest = array.slice(1);