Skip to content

Instantly share code, notes, and snippets.

@badsyntax
badsyntax / React Native Clear Cache
Created February 5, 2021 18:11 — forked from jarretmoses/React Native Clear Cache
Clearing the Cache of your React Native Project
RN < 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
npm >= 5 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache
Windows - del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache
1. Create a new directory;
mkdir Apple\ Enterprise
cd Apple\ Enterprise
2. Generate a certificate signing request
openssl req -nodes -newkey rsa:2048 -keyout ios_enterprise.key -out CertificateSigningRequest.certSigningRequest
3. With the information like so (ensure you give it a password):
Country Name (2 letter code) [AU]:GB
State or Province Name (full name) [Some-State]:London

Some pain points:

  • HMR is not always practical for server side development. For example HMR interferes with the initialisation of prom-client (and probably other libs), and there's no way to configure the HMR behaviour in Next.js (at time of writing).
    • "Interferes" meaning exceptions are thrown due to a "singleton" class being instantiated twice
  • If you're using TypeScript, you'll need a completely seperate build process for server code:
    • Generated server files are not part of the next build (ie don't exist within .next) - this is a pain when deploying or adding to a docker image
  • If you're consuming common code across the custom server and Next.js build, you're going to have 2 different compiled versions
@badsyntax
badsyntax / Dockerfile
Last active December 23, 2020 18:27
Next.js Dockerfile
FROM node:14.15.3-alpine AS builder
WORKDIR /app
ENV NPM_CONFIG_LOGLEVEL warn
ENV NPM_CONFIG_FUND false
ENV NPM_CONFIG_AUDIT false
ENV CI true
COPY package.json package-lock.json ./
@badsyntax
badsyntax / node-ipc.js
Last active November 28, 2020 21:47
Super simple Node.js IPC with Unix domain sockets
const net = require('net');
const socketPath = '/tmp/my.unix.sock';
const server = net
.createServer()
.on('connection', (stream) => {
console.log('Server: client connected');
stream.setEncoding('utf-8');
openapi: 3.0.3
info:
title: Title
version: 0.51.0
servers:
- url: https://{host}/admin
variables:
host:
default: box.example.com
description: The API hostname.
add_filter( 'woocommerce_get_breadcrumb', 'custom_breadcrumb', 10, 2 );
function custom_breadcrumb( $crumbs, $object_class ){
// Loop through all $crumb
foreach( $crumbs as $key => $crumb ){
$taxonomy = 'product_cat'; // The product category taxonomy
// Check if it is a product category term
$term_array = term_exists( $crumb[0], $taxonomy );
@badsyntax
badsyntax / bug.yml
Created August 2, 2020 19:37
widdershins not generating basic auth headers
openapi: 3.0.3
info:
title: Example
version: 1.0.0
security:
- basicAuth: []
components:
securitySchemes:
basicAuth:
type: http
@badsyntax
badsyntax / generate.sh
Created May 10, 2020 13:46
Generate grpc-js typescript files
#!/usr/bin/env bash
OUT_DIR="./out"
TS_OUT_DIR="./src"
IN_DIR="./proto"
PROTOC="$(npm bin)/grpc_tools_node_protoc"
PROTOC_GEN_TS="$(npm bin)/protoc-gen-ts"
mkdir -p "$OUT_DIR"
diff --git a/test-fixtures/gradle-project/settings.gradle b/test-fixtures/gradle-project/settings.gradle
index 86c6978..b4996c5 100644
--- a/test-fixtures/gradle-project/settings.gradle
+++ b/test-fixtures/gradle-project/settings.gradle
@@ -7,4 +7,24 @@
* in the user manual at https://docs.gradle.org/6.3/userguide/multi_project_builds.html
*/
+pluginManagement {
+ repositories {