Skip to content

Instantly share code, notes, and snippets.

View nersoh's full-sized avatar

Nelson Henrique nersoh

View GitHub Profile
@crtr0
crtr0 / client.js
Created June 8, 2012 17:02
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
@alexhawkins
alexhawkins / nativeJavaScript.js
Last active February 2, 2024 16:57
Implementation of Native JavaScript Methods (forEach, Map, Filter, Reduce, Every, Some)
'use strict';
/*****************NATIVE forEACH*********************/
Array.prototype.myEach = function(callback) {
for (var i = 0; i < this.length; i++)
callback(this[i], i, this);
};
//tests
@paulirish
paulirish / what-forces-layout.md
Last active April 19, 2024 14:42
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@vinicius73
vinicius73 / 0-contribua-.md
Last active February 9, 2024 10:10
Guia de referencias sobre estudo de JavaScript

Contribua

Se você quiser adicionar mais algum tópico deixe seu comentário, o objetico é facilitar para os iniciantes ou aqueles que buscam dominar JavaScript, quais tópicos são importantes para dominar JavaScript.

São tópicos para quem sabe o minimo de JavaScript (declarar variáveis), a ordem em que eles aparecem são por importância para o dominio como um todo. Mesmo que você já tenha experiência com JS, recomendo que leia os links de cada tópico para fortalecer suas bases teóricas e ter um comportamento mais profundo da linguagem.

Lista originalmente criada e compilada por Vinicius Reis

@stramel
stramel / server.js
Last active May 5, 2022 07:27
NX Next.js Custom Server
const express = require('express')
module.exports = async function customServer(app, settings, proxyConfig) {
const handle = app.getRequestHandler()
await app.prepare()
const server = express()
if (proxyConfig) {
const proxyMiddleware = require('http-proxy-middleware')
Object.keys(proxyConfig).forEach(context => {