Skip to content

Instantly share code, notes, and snippets.

View galvez's full-sized avatar

Jonas Galvez galvez

View GitHub Profile
@galvez
galvez / result.txt
Created September 11, 2023 20:10
Sync vs Async FS
sync 3.8610219955444336
async 49.62050497531891
global.JSON.get = makeMethod('GET')
global.JSON.post = makeMethod('POST')
global.JSON.put = makeMethod('PUT')
function makeMethod (method) {
return function (url, options = {}) {
const headers = {
...options.headers,
'Content-Type': 'application/json',
}
@galvez
galvez / 2010-10-02-14-00-test-migration.py
Created October 2, 2010 17:45
A minimalist Python migration management script based on Fabric and sqlwitch
# 2010-10-02 14h00
# Update created field in user_prefs table
def migrate(db):
with db.select('user_id, created', from_='users'):
all_users = db.fetchall()
for user in all_users:
with db.update('user_prefs') as obj:
obj.created = user['created']
db.where('user_id = %s', user['user_id'])
const x = [
'header-c',
'value',
'header-a',
'value',
'header-b',
'value',
'header-e',
'value',
'header-d',
const x = [
'header-c',
'value',
'header-a',
'value',
'header-b',
'value'
]
function sort1D (arr) {
@galvez
galvez / index.html
Created December 19, 2020 11:55 — forked from Lodin/index.html
symbol vs string property (http://jsbench.github.io/#c71181ad3112daa34cedb0b24af44e7f) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>symbol vs string property</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
#!/usr/bin/python
from time import sleep
from pygame import mixer
mixer.init()
# Download file from https://freesound.org/people/Koyber/sounds/160483/
mixer.music.load('white-rose.mp3')
mixer.music.play()
// APIStoreProps are properties that need to be
// ignored when running APIStore.makeStore()
const APIStoreProps = ['use', 'classes', 'constructor', 'init', 'state']
// getMethods returns methods defined
// in a given class' prototype, except init and constructor
const getMethods = (cls) => {
return Object.getOwnPropertyNames(cls.prototype)
.reduce((obj, prop) => {

I see this snippet:

app.addHook('onRequest', (req, reply, done) => {
  // overwrite the defaults
  req.requestContext.set('user', { id: 'helloUser' });
  done();
});

// this should now get `helloUser` instead of the default `system`
```
RangeError: Maximum call stack size exceeded
at exit (/usr/src/app/node_modules/fastify/lib/hooks.js:77:17)
at next (/usr/src/app/node_modules/fastify/lib/hooks.js:93:9)
at hookRunnerApplication (/usr/src/app/node_modules/fastify/lib/hooks.js:75:3)
at next (/usr/src/app/node_modules/fastify/lib/hooks.js:105:7)
at exit (/usr/src/app/node_modules/fastify/lib/hooks.js:82:5)
at next (/usr/src/app/node_modules/fastify/lib/hooks.js:93:9)
at hookRunnerApplication (/usr/src/app/node_modules/fastify/lib/hooks.js:75:3)
at next (/usr/src/app/node_modules/fastify/lib/hooks.js:105:7)