Skip to content

Instantly share code, notes, and snippets.

@Couto
Couto / webpack.js
Last active November 7, 2024 13:10
Fetch polyfill with webpack
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
var folders = {
APP: path.resolve(__dirname, '../app'),
BUILD: path.resolve(__dirname, '../build'),
BOWER: path.resolve(__dirname, '../bower_components'),
NPM: path.resolve(__dirname, '../node_modules')
};
@cathylill
cathylill / app-arch-mercury.md
Last active August 29, 2015 14:21
Architecting an application with MercuryJS

Architecting an application with Mercury.js

Mercury.js is not opinionated about your application architecture - it's components can be used independendently, with the mercury library adding a small amount of bootsrapping and event wiring sugar. The notes given here are just one example of how you could architect an application built with Mercury.js, and will hopefully address some of the questions you may have about implementations that are more complex than the documented examples.

This article will cover some of the key components you need to create a fully featured app and gives an example of how to structure those components in such a way as to keep your app clearly understandable and maintainable for humans.

Modularised Data store

Create a core app state object that contains top level paramaters. Child data stores are generated by individual 'store' scripts that create the store and wire up appropriate channels and methods for updating data in that store.

Each child store is initialised using mer

@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2025 13:27
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
@Marak
Marak / dockerCheatSheet.md
Last active June 20, 2024 13:33
docker cheat sheet

Things I wish I knew before I started using Docker

Commands

Init docker on mac os

boot2docker init

Restart docker vm on mac os

boot2docker up
@yann2192
yann2192 / hardening_usbarmory.md
Last active November 22, 2023 11:36
Hardening USB Armory

Hardening the USB Armory

As a good crypto nerd, I usually use an entirely encrypted linux FS: / but also /boot using grub LUKS support. It's a good setup but it's not perfect, the BIOS and the bootloader are not protected.

I recently got a USBArmory and I wanted to apply the same (or a better) setup.

I found some useful links but no clear howto. So this is my setup.

mdless

Read markdown files in your terminal

cd ~/code
git clone [email protected]:axiros/terminal_markdown_viewer.git
cd terminal_markdown_viewer
pip install markdown pygments pyyaml

Change node version for current project.

This is a little ZSH function that hooks change cwd and checks for our ./deployment.json it then uses nvm to change the current node version to the one required by the project.

Install deps

  • jq
  • nvm
@srdjan
srdjan / 100+ different counter apps...
Last active May 6, 2024 05:13
100+ different js counter apps...
100+ different js counter apps...
@WebReflection
WebReflection / base64.js
Last active April 29, 2017 02:44
Quite possibly the smallest base 64 utility out there.
// base64.decode(base64.encode('💩'));
// Browsers
const base64 = {
encode: str => btoa(unescape(encodeURIComponent(str))),
decode: str => decodeURIComponent(escape(atob(str)))
};
/* ES3 compat version
var base64 = {
@tjstebbing
tjstebbing / whatIReallyReallyWant.md
Last active August 7, 2017 07:14
Atomic client side stores with server sync

At CampJS this week there were a lot of talks about frontend web components, mostly focused on views. It struck me, as a mostly backend engineer that we could do with some better abstractions around client side/server side data sync to go with the new view model systems out there. Here's a few thoughts I had over the weekend..

A client side, in memory data store:

  1. Which is atomic (transactional?)
  2. With data that is strongly typed (validated)
  3. That syncs to a server (which is authoritative)
  4. That syncs uncommitted content to local storage transparently
  5. That is resilient to connectivity trouble
  6. That is bounded by the developer