Skip to content

Instantly share code, notes, and snippets.

View bernard-leech's full-sized avatar

Bern bernard-leech

View GitHub Profile
@gigo6000
gigo6000 / critical.js
Last active April 20, 2022 16:00
Critical CSS example
const critical = require("critical");
const baseUrl = "https://www.github.com";
const targetPath = "public/css/";
const dimensions = [
{
width: 320,
height: 568,
},
{
@nodkz
nodkz / .babelrc.js
Last active March 25, 2024 16:16
Babel 7.0 with .babelrc.js DEPRECATED! This config was created when babel 7 was in beta
/* eslint-disable prefer-template */
const path = require('path');
const aliases = require('./aliases');
// ///////////////////////////////////////////////////////////////
// ////////////////// PLUGINS ////////////////////////////////
// ///////////////////////////////////////////////////////////////
const commonPlugins = [
@alekseykulikov
alekseykulikov / index.md
Last active April 14, 2024 00:32
Principles we use to write CSS for modern browsers

Recently CSS has got a lot of negativity. But I would like to defend it and show, that with good naming convention CSS works pretty well.

My 3 developers team has just developed React.js application with 7668 lines of CSS (and just 2 !important). During one year of development we had 0 issues with CSS. No refactoring typos, no style leaks, no performance problems, possibly, it is the most stable part of our application.

Here are main principles we use to write CSS for modern (IE11+) browsers:

@Rich-Harris
Rich-Harris / service-workers.md
Last active May 6, 2024 22:10
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@markerikson
markerikson / nodeenvDiscussion.md
Last active January 9, 2023 15:24
Summary of process.env.NODE_ENV and its use with Webpack

[02:06 PM] acemarke: @Steven : a couple other thoughts on the whole NODE_ENV thing. First, per my comments, it really is a Node concept. It's a system environment variable that Node exposes to your application, and apparently the Express web server library popularized using its value to determine whether to do optimizations or not
[02:08 PM] acemarke: Second, because of its use within the Node ecosystem, web-focused libraries also started using it to determine whether to they were being run in a "development" environment vs a "production" environment, with corresponding optimizations. For example, React uses that as the equivalent of a C #ifdef to act as conditional checking for debug logging and perf tracking. If process.env.NODE_ENV is set to "production", all those if clauses will evaluate to false.
Third, in conjunction with a tool like UglifyJS that does minification and removal of dead code blocks, a clause that is surrounded with if(process.env.NODE_ENV !== "development")

@danieldunderfelt
danieldunderfelt / index.js
Created June 12, 2016 16:10
Serializing and hydrating state with MobX
/* App creator */
import { extendObservable } from 'mobx'
import AppStore from '../app/AppStore'
export default (initialState = false) => {
const stores = {
App: AppStore
}
@yoavniran
yoavniran / ultimate-ut-cheat-sheet.md
Last active May 6, 2024 12:29
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest
@dudleystorey
dudleystorey / batch-resize.jsx
Created February 24, 2015 06:49
Creates smaller square thumbnail images with correct appended file names, given a folder of original JPEG, PNG and GIF files at large sizes
// explanatory article: https://demosthenes.info/blog/993/1x-2x-3x-more-Batch-Processing-Retina-Images-with-PhotoShop-and-JavaScript
var inputFolder = Folder.selectDialog("Select a folder to process"),
outputFolder = Folder.selectDialog("Select a folder for the output files"),
imageSizes = [
["250px", "250px", "1x"],
["125px", "125px", "icon-2x"],
["75px", "75px", "icon-1x"]
],
numImageSizes = imageSizes.length;
@ruandre
ruandre / PsResizeLongestSide1024.jsx
Last active February 7, 2022 18:15
Adobe Photoshop script to resize images to fit inside a 1024px box.
/***************************
NOT MAINTAINED! from ~2015
****************************/
// photoshop script to resize images proportionally to fit inside a 1024px box i.e. longest side/edge will equal 1024px
// useful when scaling down many large photos for web use, simply toss in a batch action
var activeDoc = app.activeDocument
var docWidth = activeDoc.width
var docHeight = activeDoc.height