Skip to content

Instantly share code, notes, and snippets.

View m4n1ok's full-sized avatar
🙈
(╯°□°)╯︵ ┻━┻

antonin caudron m4n1ok

🙈
(╯°□°)╯︵ ┻━┻
View GitHub Profile
@m4n1ok
m4n1ok / componentDebugFrame.js
Created May 7, 2021 10:10
Vue.js Component debug frame mixin
export default {
data() {
return {
debugEnabled: true,
debugFrame: null
}
},
methods: {
registerEvents() {
this.$el.addEventListener('mouseenter', this.showDebug)
@m4n1ok
m4n1ok / Logger.js
Created February 18, 2020 09:37
A simple wrapper around console.log / chalk / terminal-link to have nice log into node.js program
const chalk = require('chalk')
const terminalLink = require('terminal-link')
const log = console.log
module.exports = {
log,
chalk,
terminalLink,
success: (msg) => log(chalk.green(msg)),
@m4n1ok
m4n1ok / videos.sh
Created January 23, 2020 19:53
Video usefull command
# Split video in chunk of 5 seconds with a crop
ffmpeg -i input.mp4 -an -vcodec libx264 -profile:v baseline -level 3 -vf "crop=720:720:600:180" -map 0 -segment_time 00:00:05 -f segment -reset_timestamps 1 output%03d.mp4
# Split video in chunk of 5 seconds
ffmpeg -i input.mp4 -an -vcodec libx264 -profile:v baseline -level 3 -map 0 -segment_time 00:00:05 -f segment -reset_timestamps 1 output%03d.mp4
@m4n1ok
m4n1ok / observable.js
Last active May 24, 2021 14:24
Simple store
export default ({ target, listener = false }) => {
let observable = null
const set = (target, name, value) => {
target[name] = value
if (listener && typeof listener === 'function') {
listener(observable)
}
return true
}
/**
* ScrollRAF
* Optimize animations on scroll
* Simple Singleton to listen scroll and update things on raf
*/
class ScrollRAF {
constructor () {
if (!ScrollRAF.instance) {
this._isRunning = false
this._callbacksMap = {}
/**
* ScrollDirection
* Simple Singleton to listen scrollDirection
* Use an array of callbacks objects running when user scroll to top or to down
* Could be usefull to pin header on scroll top for example
*/
class ScrollDirection {
constructor () {
if (!ScrollDirection.instance) {
this._isRunning = false
@m4n1ok
m4n1ok / autoplay.js
Last active January 10, 2023 09:35
Detect autoplay inline video
export const isAutoplaySupported = () => {
// Detect if user can autoplay inline video
// Works when user is on low-battery mode on IOS
// Return promise from video.play
const video = document.createElement('video')
video.src = 'data:video/mp4;base64,AAAAIGZ0eXBtcDQyAAAAAG1wNDJtcDQxaXNvbWF2YzEAAATKbW9vdgAAAGxtdmhkAAAAANLEP5XSxD+VAAB1MAAAdU4AAQAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAACFpb2RzAAAAABCAgIAQAE////9//w6AgIAEAAAAAQAABDV0cmFrAAAAXHRraGQAAAAH0sQ/ldLEP5UAAAABAAAAAAAAdU4AAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAoAAAAFoAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAAHVOAAAH0gABAAAAAAOtbWRpYQAAACBtZGhkAAAAANLEP5XSxD+VAAB1MAAAdU5VxAAAAAAANmhkbHIAAAAAAAAAAHZpZGUAAAAAAAAAAAAAAABMLVNNQVNIIFZpZGVvIEhhbmRsZXIAAAADT21pbmYAAAAUdm1oZAAAAAEAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAw9zdGJsAAAAwXN0c2QAAAAAAAAAAQAAALFhdmMxAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAoABaABIAAAASAAAAAAAAAABCkFWQyBDb2RpbmcAAAAAAAAAAAAAAAA
@m4n1ok
m4n1ok / raf-manager.js
Last active September 15, 2020 12:06
class RAF {
constructor () {
if (!RAF.instance) {
this._radId = null
this._callbacksMap = {}
this._callbacks = []
RAF.instance = this
}
return RAF.instance
@m4n1ok
m4n1ok / setup.sh
Last active August 12, 2018 17:24 — forked from bradp/setup.sh
New Mac Setup Script
echo "Creating an SSH key for you..."
ssh-keygen -t rsa
echo "Please add this public key to Github \n"
echo "https://github.com/account/ssh \n"
read -p "Press [Enter] key after this..."
echo "Installing xcode-stuff"
xcode-select --install
@m4n1ok
m4n1ok / videos.js
Last active September 18, 2021 08:45
Encode video directory into mp4 and webm
/**
* Generate web videos mp4 + webm from given folder
* You can pass options by file in videos.json
* Options are crop size
* NODE and FFMEPG is required. On mac brew install node && brew install ffmpeg
* FFMPEG command are inspired by https://gist.github.com/Vestride/278e13915894821e1d6f
* eg: node videos.js --input=../inputDir --output=../dir/outputDir --prefix=compressed --r-audio
* if missing outputDir, inputDir will be use
*/