Skip to content

Instantly share code, notes, and snippets.

@rygorous
rygorous / gist:e0f055bfb74e3d5f0af20690759de5a7
Created May 8, 2016 06:54
A bit of background on compilers exploiting signed overflow
Why do compilers even bother with exploiting undefinedness signed overflow? And what are those
mysterious cases where it helps?
A lot of people (myself included) are against transforms that aggressively exploit undefined behavior, but
I think it's useful to know what compiler writers are accomplishing by this.
TL;DR: C doesn't work very well if int!=register width, but (for backwards compat) int is 32-bit on all
major 64-bit targets, and this causes quite hairy problems for code generation and optimization in some
fairly common cases. The signed overflow UB exploitation is an attempt to work around this.
@ashfurrow
ashfurrow / Fresh macOS Setup.md
Last active July 20, 2024 17:09
All the stuff I do on a fresh macOS Installation

Apps to install from macOS App Store:

  • Pastebot
  • GIF Brewery
  • Slack
  • Keynote/Pages/Numbers
  • 1Password
  • OmniFocus 3
  • Airmail 3
  • iA Writer
@noxify
noxify / Page.php
Created December 18, 2018 12:14
Twill pages - custom edit template
//app/Models/Page.php
<?php
namespace App\Models;
use A17\Twill\Models\Behaviors\HasBlocks;
use A17\Twill\Models\Behaviors\HasSlug;
use A17\Twill\Models\Behaviors\HasMedias;
use A17\Twill\Models\Behaviors\HasRevisions;

Proposal: Importable Constructable Stylesheets

We're getting Constructable Stylesheets. This seems like an intuitive value to obtain when importing CSS from JavaScript, since it's the DOM's representation of a Stylesheet:

import stylesheet from './style.css';
console.log(stylesheet);  // CSSStyleSheet

No such system is in place to allow this to work (see [whatwg/loader]), however frontend build tooling has congregated around this approach as a mechanism for bringing CSS assets into the JavaScript module graph. There are many benefits to be obtained from moving CSS into this graph, however the most important is that imported CSS can be attributed to the consuming JS Module. This allows it to be bundled, optimized, and potentially dead-code-eliminated leveraging static analysis performed on the surrounding module graph.

@developit
developit / babel-plugin-optimize-tagged-templates.js
Created May 29, 2019 20:04
Babel plugin to optimize tagged templates by inlining string/number/boolean values.
module.exports = (babel, options = {}) => {
const { types: t } = babel;
return {
name: "optimize-tagged-templates",
visitor: {
TemplateLiteral(path) {
for (let i=0; i<path.node.expressions.length; i++) {
const expr = path.node.expressions[i];
let isLiteral = t.isStringLiteral(expr);
{
"name": "rsms dark v2 mono",
"author": "rsms",
"variables": {
"red": "hsl(5, 0%, 50%)",
"orange": "hsl(27, 0%, 50%)",
"yellow": "hsl(60, 0%, 50%)",
"green": "hsl(150, 0%, 43%)",
"cyan": "hsl(180, 0%, 50%)",
"blue": "hsl(210, 0%, 50%)",
@tomhicks
tomhicks / plink-plonk.js
Last active July 26, 2024 01:10
Listen to your web pages
export const h=(t,p,...c)=>({t,p,c,k:p&&p.key})
export const render=(e,d,t=d.t||(d.t={}),p,r,c,m,y)=>
// arrays
e.map?e.map((e,p)=>render(e,d,t.o&&t.o[p])):
// components
e.t.call?(e.i=render((render.c=e).t(Object.assign({children:e.c},e.p),e.s=t.s||{},t=>
render(Object.assign(e.s,t)&&e,d,e)),t.i||d,t&&t.i||{}),d.t=t=e):(
// create notes
m=t.d||(e.t?document.createElement(e.t):new Text(e.p)),
// diff props
import React, { useEffect } from "react"
import { META_DESCRIPTION } from "../../util"
export const Page: React.FC<{
title?: string
metaDescription?: string
}> = props => {
useEffect(() => {
document.title = props.title ?? "Execute Program"
@lukastaegert
lukastaegert / assets.js
Last active July 21, 2022 03:21
Rollup plugins to emit chunks and CSS assets from an HTML file and add an updated HTML file to the build, and to emit assets from a JS file.
export const rollupLogo = "./logo.svg";