Skip to content

Instantly share code, notes, and snippets.

@ChristopherA
ChristopherA / brew-bundle-brewfile-tips.md
Last active May 4, 2024 18:39
Brew Bundle Brewfile Tips

Brew Bundle Brewfile Tips

Copyright & License

Unless otherwise noted (either in this file or in a file's copyright section) the contents of this gist are Copyright ©️2020 by Christopher Allen, and are shared under spdx:Creative Commons Attribution Share Alike 4.0 International (CC-BY-SA-4.) open-source license.

Sponsor

If you more tips and advice like these, you can become a monthly patron on my GitHub Sponsor Page for as little as $5 a month; and your contributions will be multipled, as GitHub is matching the first $5,000! This gist is all about Homebrew, so if you like it you can support it by donating to them or becoming one of their Github Sponsors.

@LauraBeatris
LauraBeatris / react-i18next.js
Last active October 30, 2023 11:48
Mock for react-i18next tests
const React = require('react');
const reactI18next = require('react-i18next');
/*
Also, if you're changing the language, add that mock function before your test suit
jest.mock('react-i18next', () => ({
useTranslation: () => ({
t: key => key,
i18n: { changeLanguage: jest.fn() },
@seeliang
seeliang / lint-only-changed-files.MD
Last active April 10, 2024 09:44
How to lint only changed files?

find out the differences

use git diff to generate file list

git diff --name-only master

limited to certain file types

add ext filter

@sffc
sffc / Gemfile
Last active July 12, 2020 09:27
Drop-in extension for image optimization during a Jekyll build. Save jekyll_image_optim.rb in your _plugins directory and make the stated changes to your Gemfile and _config.yml. https://blog.sffc.xyz/post/182420136145/optimized-images-in-jekyll
gem "image_optim", "~> 0.25"
gem "image_optim_pack", "~> 0.5.1"
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
@ibeeger
ibeeger / webpack.config.js
Last active July 22, 2020 05:13
webpack.config.js multi-compiler Sequential execution
/**
webpack.config.js
**/
const webpack = require('webpack');
const env = process.env.NODE_ENV;
const configs = [{
name:"one",
entry:{
},
@judy2k
judy2k / parse_dotenv.bash
Created March 22, 2017 13:34
Parse a .env (dotenv) file directly using BASH
# Pass the env-vars to MYCOMMAND
eval $(egrep -v '^#' .env | xargs) MYCOMMAND
# … or ...
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)
@BretFisher
BretFisher / docker-for-mac.md
Last active April 26, 2024 09:38
Getting a Shell in the Docker Desktop Mac VM

2021 Update: Easiest option is Justin's repo and image

Just run this from your Mac terminal and it'll drop you in a container with full permissions on the Docker VM. This also works for Docker for Windows for getting in Moby Linux VM (doesn't work for Windows Containers).

docker run -it --rm --privileged --pid=host justincormack/nsenter1

more info: https://github.com/justincormack/nsenter1


@addyosmani
addyosmani / preprocessing.md
Last active May 4, 2024 23:04
JavaScript preprocessing/precompilation

Problem: How can we preprocess JavaScript (at build-time or on the server-side) so engines like V8 don't have to spend as much time in Parse? This is a topic that involves generating either bytecode or a bytecode-like-abstraction that an engine would need to accept. For folks that don't know, modern web apps typically spend a lot longer in Parsing & Compiling JS than you may think.

  • Yoav: This can particularly be an issue on mobile. Same files getting parsed all the time for users. Theoretically if we moved the parsing work to the server-side, we would have to worry about it less.
  • One angle to this problem is we all ship too much JavaScript. That's one perspective. We could also look at preprocessing.
  • We've been talking about this topic over the last few weeks a bit with V8. There were three main options proposed.
    1. Similar to what optimize-js does. Identify IIFEs and mark them as such so the browser and VMs heuristics will catch them and do a better job than today. optimize-js only tackles IIFE bu
@mikejolley
mikejolley / functions.php
Last active May 17, 2021 13:51
WooCommerce - Split shipping class items into a new package and limit shipping methods
/**
* This function loops over cart items, and moves any item with shipping class 'special-class' into a new package.
* The new package in this example only takes flat rate shipping.
*/
function split_special_shipping_class_items( $packages ) {
$found_item = false;
$special_class = 'special-class'; // edit this with the slug of your shippig class
$new_package = current( $packages );
$new_package['contents'] = array();
$new_package['contents_cost'] = 0;