Skip to content

Instantly share code, notes, and snippets.

View cvan's full-sized avatar
🚌
🌊

Christopher Van Wiemeersch cvan

🚌
🌊
View GitHub Profile
@timruffles
timruffles / next.md
Last active February 23, 2024 17:04
Next.js page request handling

How Next.js responds to a page request with HTML

We create the next request handler function via app.getRequestHandler(). This returns a standard express handler, so we use it like expressApp.get('*', middlewareA(), middlewareB(), nextApp.getRequestHandler()).

When the handler is invoked:

  • Server#handleRequest (next-server/server/lib/next-server.js)
    • Parses URL + query string if not already done
  • Server#run
  • Searches for matching route
# Design Systems Resources
by: Sujan Khadgi
Atomic Design by Brad Frost:
http://atomicdesign.bradfrost.com/
Design Systems by Alla Kholmatova:
http://designsystemsbook.com/
Design Systems Handbook:
// Your sheet name in the document
var sheetName = "Data";
// Your instagram user id
var user_id = ""; //find your id here : https://codeofaninja.com/tools/find-instagram-user-id
var instagram_base_url = "https://www.instagram.com/graphql/query/";
var following = "?query_hash=58712303d941c6855d4e888c5f0cd22f&variables=%7B%22id%22%3A%22" + user_id + "%22%2C%22first%22%3A24%7D"
var followers = "?query_hash=37479f2b8209594dde7facb0d904896a&variables=%7B%22id%22%3A%22" + user_id + "%22%2C%22first%22%3A24%7D"
var medias = "?query_hash=f2405b236d85e8296cf30347c9f08c2a&variables=%7B%22id%22%3A%22" + user_id + "%22%2C%22first%22%3A12%7D"
@berga
berga / uiwebview_snippet.js
Created February 1, 2018 12:54 — forked from chrisallick/uiwebview_snippet.js
JavaScript only solution for detecting UIWebView.
// http://stackoverflow.com/questions/4460205/detect-ipad-iphone-webview-via-javascript
var standalone = window.navigator.standalone,
userAgent = window.navigator.userAgent.toLowerCase(),
safari = /safari/.test( userAgent ),
ios = /iphone|ipod|ipad/.test( userAgent );
if( ios ) {
if ( !standalone && safari ) {
//browser
} else if ( standalone && !safari ) {
@WebReflection
WebReflection / prevaluation.js
Created November 22, 2017 14:13
Try to execute a Gist pre content and it copies it to clipboard.
document.documentElement.appendChild(
document.createElement('style')
).textContent = `
.executable {
transition: all .3s;
}
.executable:hover {
cursor: pointer;
background: #fff !important;
}`;
@mattdesl
mattdesl / about.md
Last active July 17, 2023 09:20
optimizing & de-duplicating geometry in GLTF files

optimize GLTF file

This optimizes a GLTF file that was exported by blender (or similar) by de-duplicating buffer views (i.e. chunks of bytes) that are equal and removing redundant accessors.

For example, 100 cubes of different scales/materials/rotations/etc should all end up using a single BufferGeometry in ThreeJS, which isn't the case with current GLTF exporters in Blender and parsers for ThreeJS.

In scenes with a lot of instancing, it can dramatically reduce total file size as well as render performance. In one test scene:

Before: 4.8MB file size, 832 THREE.Geometry instances across 832 THREE.Mesh objects
After: 661KB file size, 13 THREE.Geometry instances across 832 THREE.Mesh objects

@zehfernandes
zehfernandes / pliim-turnOff.scpt
Last active September 16, 2024 06:39
One click and be ready to go up on stage and shine! - https://zehfernandes.github.io/pliim/
# Turn on Notifications
do shell script "defaults -currentHost write com.apple.notificationcenterui doNotDisturb -bool FALSE; defaults -currentHost delete com.apple.notificationcenterui doNotDisturbDate; osascript -e 'quit application \"NotificationCenter\" ' && killall usernoted" -- this set 'Do not disturb' to false in the pref
# Show Desktop
do shell script "defaults write com.apple.finder CreateDesktop -bool true; killall Finder"
# Show all windows
tell application "System Events"
set visible of (every process) to true
end tell
@tinyfly
tinyfly / boot-intercom-respond.js
Last active March 31, 2021 19:10
Start up the Intercom Respond widget being sure to clear previous user's conversations.
/**
* Boots up Intercom (intercom.io). This should be run on page load
* @param {String} APP_ID - Your Intercom app id
* @param {Function} moment - moment.js
* @param {Object} [user] - information about the logged in user
*/
startupIntercom(APP_ID, moment, user) {
// basic settings for all users
const intercomSettings = {
@jaredpalmer
jaredpalmer / Formik-Autosave.jsx
Last active December 29, 2022 01:22
Formik-Autosave
import React from 'react';
import PropTypes from 'prop-types'
import debounce from 'lodash.debounce' // or whatevs
import isEqual from 'lodash.isEqual'
class AutoSave extends React.Component {
static contextTypes = {
formik: PropTypes.object
}
@justinribeiro
justinribeiro / instruct.md
Last active September 27, 2019 18:56
Generating icons for PWAs with imagemagick convert and the command line

Generate a set of icons for the manifest, index metadata, so forth.

convert raw-icon.png \
  \( -clone 0 -resize 512x512 -write icon-512.png \) \
  \( -clone 0 -resize 384x384 -write icon-384.png \) \
  \( -clone 0 -resize 192x192 -write icon-192.png \) \
  \( -clone 0 -resize 144x144 -write icon-144.png \) \
  \( -clone 0 -resize 96x96 -write icon-96.png \) \
 \( -clone 0 -resize 72x72 -write icon-72.png \) \