Skip to content

Instantly share code, notes, and snippets.

@marcnewport
marcnewport / wait-for-element.js
Created July 8, 2025 05:48
waitForElement using MutationObserver
// Usage:
// waitForElement(this, '.swiper', (target) => {
// console.log(target.swiper)
// })
function waitForElement(wrapper, selector, callback, timeout = 1000) {
const target = wrapper.querySelector(selector);
if (target) {
callback(target);
return;

Checkout remote branch

  1. Fetch the remote branch references
git fetch -p
  1. Checkout the remote branch
git checkout --track origin/remote-branch
<!-- newer browsers won't load this bundle: -->
<script nomodule src="polyfills.js"></script>
<!-- all browsers load this one: -->
<script src="/bundle.js"></script>
<!-- newer browsers won't load this bundle: -->
<script nomodule src="polyfills.js"></script>
<!-- all browsers load this one: -->
<script src="/bundle.js"></script>
export NVM_DIR="$HOME/.nvm"
. "$(brew --prefix nvm)/nvm.sh"
alias P='cd ~/Projects'
alias xip='echo "http://$(ipconfig getifaddr en0).xip.io"'
alias chrome='open -a "Google Chrome"'
alias commits="git log --pretty=\"* %s\" --all --no-merges -n 20 | pbcopy"
alias releases='git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%s"'
alias ngrok='~/ngrok'
development:
password: 6491ebc709b99ab772df66107c929f24
theme_id: 23846571685
store: example.myshopify.com
ignore_files:
- settings_data.json
retail:
api_key: pfs7m749mrmxzjr808gfcpwmoi2md80se
password: bjv21sfx24dql68nkrvasu6lj56ahb2kl
store: retail-store.myshopify.com
outlet:
api_key: m1lnozweqk3r0gu80g71jyeqmpq240gzd
password: abdikmmp9sydh2d9o6ex82t7xr95fvjy3
store: outlet-store.myshopify.com
- pipeline: "Deploy Next Release"
trigger_mode: "ON_EVERY_PUSH"
ref_name: "develop"
ref_type: "BRANCH"
trigger_condition: "ALWAYS"
actions:
- action: "Execute: yarn build"
type: "BUILD"
working_directory: "/buddy/[PROJECT_NAME]"
docker_image_name: "library/node"
{% schema %}
{
"name": "Contact page",
"settings": [],
"blocks": [
{
"type": "text",
"name": "Text field",
"settings": [
{
// media query event handler
if (window.matchMedia) {
const mq = window.matchMedia("(min-width: 500px)");
mq.addListener(WidthChange);
WidthChange(mq);
}
// media query change
function WidthChange(mq) {
if (mq.matches) {