Skip to content

Instantly share code, notes, and snippets.

View andrezsanchez's full-sized avatar

Andre Z. Sanchez andrezsanchez

View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active June 21, 2024 17:37
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.
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active June 20, 2024 03:04
set -e, -u, -o, -x pipefail explanation
@fay59
fay59 / Quirks of C.md
Last active January 23, 2024 04:24
Quirks of C

Here's a list of mildly interesting things about the C language that I learned mostly by consuming Clang's ASTs. Although surprises are getting sparser, I might continue to update this document over time.

There are many more mildly interesting features of C++, but the language is literally known for being weird, whereas C is usually considered smaller and simpler, so this is (almost) only about C.

1. Combined type and variable/field declaration, inside a struct scope [https://godbolt.org/g/Rh94Go]

struct foo {
   struct bar {
 int x;

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@paulirish
paulirish / what-forces-layout.md
Last active June 19, 2024 15:52
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
@mattdesl
mattdesl / upload-texture.js
Created November 6, 2014 16:49
immediate texture upload for threejs
/*
Uploads to GPU immediately when the image is ready, then fires callback.
//takes a string path or image/canvas/video/ImageData
uploadTexture(renderer, pathOrImage, function(err, texture) {
if (err) console.error(err)
//do something with the ThreeJS 'texture' result
})
*/
var THREE = require('three');
@staltz
staltz / introrx.md
Last active June 21, 2024 12:27
The introduction to Reactive Programming you've been missing
; ___ _ __ ___ __ ___
; / __|_ _ __ _| |_____ / /| __|/ \_ )
; \__ \ ' \/ _` | / / -_) _ \__ \ () / /
; |___/_||_\__,_|_\_\___\___/___/\__/___|
; An annotated version of the snake example from Nick Morgan's 6502 assembly tutorial
; on http://skilldrick.github.io/easy6502/ that I created as an exercise for myself
; to learn a little bit about assembly. I **think** I understood everything, but I may
; also be completely wrong :-)
@Daniel15
Daniel15 / gist:7969014
Last active May 27, 2017 15:42
Item/List classes in React
var Item = React.createClass({
render: function() {
return(
<li>
... Item goes here ...
<input type="checkbox" checked={this.props.selected} onChange={this.onChange} />
</li>
);
},
onChange: function(event) {
@mortennobel
mortennobel / GLError.cpp
Last active September 27, 2018 07:14
Simple error check of open gl (write readable error description to cerr stream including file name and line number)
#include "GLError.h"
#include <iostream>
#include <string>
#ifdef WIN32
# include <GL/glew.h>
#elif __APPLE__
# include <OpenGL/gl3.h>
#else
# include <GL3/gl3.h>