Skip to content

Instantly share code, notes, and snippets.

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

antonin caudron m4n1ok

🙈
(╯°□°)╯︵ ┻━┻
View GitHub Profile
@m4n1ok
m4n1ok / config.js
Created April 25, 2018 09:27
Simple node server with socket.io configuration and tweet stream api
module.exports = {
twitter: {
consumer_key: '',
consumer_secret: '',
token: '',
token_secret: ''
},
tracking: {
dev: ['gobelinou', 'taratta'],
prod: ['gobelinou']
@m4n1ok
m4n1ok / rgbaToVec.js
Created April 25, 2018 11:57
Convert a rgba/rgb color to vec4. Convert vec4 color to rgba
const normalize = (min, max, value) => {
if (value < min) return min
else if (value > max) return max
else return value
}
const splitChannels = (color, split) => {
color = color.replace(split, '').replace(')', '').trim()
let channels = color.split(',')
@m4n1ok
m4n1ok / encoding-video.md
Created June 29, 2018 15:18 — forked from Vestride/encoding-video.md
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
@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
*/
@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 / 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 / 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
/**
* 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
/**
* 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 = {}
@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
}