Skip to content

Instantly share code, notes, and snippets.

View divmgl's full-sized avatar

Dexter Miguel divmgl

  • San Francisco, CA
  • 09:19 (UTC -12:00)
View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active May 18, 2024 09:04
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@paulirish
paulirish / what-forces-layout.md
Last active May 17, 2024 18:01
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
@joepie91
joepie91 / es-modules-are-terrible-actually.md
Last active May 17, 2024 05:13
ES Modules are terrible, actually

ES Modules are terrible, actually

This post was adapted from an earlier Twitter thread.

It's incredible how many collective developer hours have been wasted on pushing through the turd that is ES Modules (often mistakenly called "ES6 Modules"). Causing a big ecosystem divide and massive tooling support issues, for... well, no reason, really. There are no actual advantages to it. At all.

It looks shiny and new and some libraries use it in their documentation without any explanation, so people assume that it's the new thing that must be used. And then I end up having to explain to them why, unlike CommonJS, it doesn't actually work everywhere yet, and may never do so. For example, you can't import ESM modules from a CommonJS file! (Update: I've released a module that works around this issue.)

And then there's Rollup, which apparently requires ESM to be u

@noelboss
noelboss / git-deployment.md
Last active May 16, 2024 20:41
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@alanpeabody
alanpeabody / my_app.ex
Last active March 24, 2024 13:28
Websockets in Elixir with Cowboy and Plug
defmodule MyApp do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
Plug.Adapters.Cowboy.child_spec(:http, MyApp.Router, [], [
dispatch: dispatch
])
@intinig
intinig / .clang-format
Last active January 13, 2024 11:56
.clang-format for UE4
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
@gamerxl
gamerxl / ue4-websocket-client.cpp
Last active January 6, 2024 04:17
How to create a websocket client / connection without setup third party libraries in ue4 c++ context.
/**
* Include the PrivateDependencyModuleNames entry below in your project build target configuration:
* // Depend on WebSockets library from UE4 (UE4 WebSockets implementation is built upon the libwebsockets library).
* PrivateDependencyModuleNames.AddRange(new string[] { "WebSockets" });
*/
#include "WebSocketsModule.h"
#include "IWebSocket.h"
{
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();
// Optional
TArray<FString> ContentPaths;
ContentPaths.Add(TEXT("/Game/My/Folder"));
AssetRegistry.ScanPathsSynchronous(ContentPaths);
// End Optional
TSet<FName> DerivedNames;
@sephirot47
sephirot47 / UE4 C++ Set Object Type or Set Collision Channel Type .cpp
Last active July 14, 2023 12:33
UE4 C++ Set Object Type or Set Collision Channel Type
/*
Ok, so you want to change your Object Type (or collision channel) to a custom channel in runtime.
But there's a problem, it seems UE4 doesn't support this yet, but there's a workaround hehe :)
For example, imagine you create the ObjectType Building.
Now, imagine you want to change the ObjectType of all the StaticMeshComponents of the object OBJECT (from WorldStatic to Building, for example).
You can try something like this:
*/