Skip to content

Instantly share code, notes, and snippets.

View johnie's full-sized avatar
httpster

Johnie Hjelm johnie

httpster
View GitHub Profile
@johnie
johnie / stream_to_youtube.sh
Created May 5, 2022 20:19 — forked from olasd/stream_to_youtube.sh
Stream video to youtube via ffmpeg
#! /bin/bash
#
# Diffusion youtube avec ffmpeg
# Configurer youtube avec une résolution 720p. La vidéo n'est pas scalée.
VBR="2500k" # Bitrate de la vidéo en sortie
FPS="30" # FPS de la vidéo en sortie
QUAL="medium" # Preset de qualité FFMPEG
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" # URL de base RTMP youtube
@johnie
johnie / ComponentIndex.js
Created April 1, 2018 20:28 — forked from davidgljay/ComponentIndex.js
Pattern for dynamically loading React components based on a config json object.
import config from '../config'
let components = {}
//For each component in the config fiel into an object
for (var i = config.length - 1; i >= 0; i--) {
components[config[i].name] = require(config[i].path).default
}
export default components
<?php
/**
* Insert an attachment from an URL address.
*
* @param String $url
* @param Int $post_id
* @param Array $meta_data
* @return Int Attachment ID
*/
@johnie
johnie / last_business_day_of_month.js
Created June 1, 2016 22:27 — forked from arch1t3ct/last_business_day_of_month.js
Javascript (Node.js) function for getting last working/business day of the month.
/**
* Finds last working/business day of the month.
*
* Not tested for cross-browser compability. Works in Node.js though.
*
* EXAMPLES:
*
* 1. Returns last day of the last month of the current year:
*
* var result = lastBusinessDayOfMonth();
<?php
/**
* Force enable a plugin.
*
* @param array $plugins
*
* @return array
*/
add_filter( 'option_active_plugins', function ( $plugins ) {
@johnie
johnie / ajax-action.php
Last active September 5, 2015 12:00 — forked from danielpataki/ajax-action.php
Ajax in WordPress
<?php
add_action( 'wp_ajax_button_click', 'user_clicked' );
function user_clicked() {
update_user_meta( get_current_user_id(), 'clicked_link', 'yes' );
wp_redirect( $_SERVER['HTTP_REFERER'] );
exit();
}