Skip to content

Instantly share code, notes, and snippets.

@yuhui
yuhui / Setup macOS development environment.md
Last active December 17, 2022 21:18
Setup macOS for programming development
@yuhui
yuhui / brew-update.sh
Last active April 5, 2022 08:25
Update Homebrew and installed brews
#!/bin/bash
echo "$ brew analytics off"
brew analytics off
echo "$ brew update"
brew update
echo "$ brew upgrade"
brew upgrade
@yuhui
yuhui / python-update.sh
Created July 3, 2019 09:31
Update Python's setuptools, pip, and virtualenv
#!/bin/bash
echo "$ pip install --upgrade setuptools"
pip install --upgrade setuptools
echo "$ pip install --upgrade pip"
pip install --upgrade pip
echo "$ pip install --upgrade virtualenv"
pip install --upgrade virtualenv
@yuhui
yuhui / node-update.sh
Last active August 11, 2019 08:11
Update NodeJS' node (using nvm) and npm
#!/bin/bash
# source NVM
. ~/.nvm/nvm.sh
echo "$ nvm install node"
nvm install node
echo "$ nvm cache clear"
nvm cache clear
@yuhui
yuhui / Use old Firefox with slimerjs.md
Created September 6, 2019 14:12
How to use an old version of Firefox with slimerjs

slimerjs

As of v1.0.0 installed from Homebrew, slimerjs is compatible with Firefox up to version 59.0 only.

These are the instructions for macOS:

  1. Download Firefox v59.0.3 disk image.
  2. Open the disk image.
  3. Drag the "Firefox" app to a folder except the Applications folder.
  4. Rename Firefox to "Firefox 59.0.3".
@yuhui
yuhui / Brightcove video playback to Adobe Analytics through Adobe Launch.js
Last active April 27, 2022 19:30
Track Brightcove video playback to Adobe Analytics using Adobe Launch
/**
* Track Brightcove media playback using Adobe Launch's Media-related rules.
*
* Brightcove documentation:
* - Player events: https://support.brightcove.com/player-events
* - Player metadata: https://support.brightcove.com/player-metadata-bcinfo
* - Video metadata: https://support.brightcove.com/video-metadata-mediainfo
*
* Brightcove Player API documentation:
* - Current release: https://docs.brightcove.com/brightcove-player/current-release/index.html
@yuhui
yuhui / brightcove-iframe-video-playback.js
Last active December 9, 2021 03:40
Track Brightcove IFRAME video playback events with posted messages
/**
* @fileoverview Detects video playback events in the Brightcove player and
* post a message for each of them.
*
* @author yuhui
* @version 1.0.0
*
* @see https://player.support.brightcove.com/coding-topics/overview-player-api.html
* Brightcove Player development overview
* @see https://docs.brightcove.com/brightcove-player/current-release/Player.html
@yuhui
yuhui / brightcove-iframe-video-playback-with-customevent.js
Last active December 8, 2021 09:24
Track Brightcove IFRAME video playback events with CustomEvents
/**
* @fileoverview Detects video playback events in the Brightcove player and
* send a CustomEvent for each of them.
*
* @author yuhui
* @version 1.0.0
*
* @see https://player.support.brightcove.com/coding-topics/overview-player-api.html
* Brightcove Player development overview
* @see https://docs.brightcove.com/brightcove-player/current-release/Player.html
@yuhui
yuhui / adobe-analytics-clear-variables-using-registerPostTrackCallback-custom-code.js
Last active March 4, 2022 03:46
Adobe Analytics: clear variables' values and events after beacons have been sent, instead of using s.clearVars().
s.registerPostTrackCallback(function(requestUrl, s) {
_satellite.logger.warn('s.registerPostTrackCallback() called');
// unset variables and events that are not needed after sending a beacon
// BUT LEAVE BEHIND variables that should remain, e.g. those that are set in the Adobe Analytics extension itself
var doNotUnsetVariables = [
'pagename', // page name
'hier1', // page hierarchy 1
'server', // site server