Skip to content

Instantly share code, notes, and snippets.

View Donmclean's full-sized avatar
🎧
Building a fleet of the world's first AI DJs 👨‍💻

Don Mclean Donmclean

🎧
Building a fleet of the world's first AI DJs 👨‍💻
View GitHub Profile
@Donmclean
Donmclean / cloc.sh
Last active April 25, 2018 09:16
get total lines of code in repo
### REQUIREMENTS: MUST HAVE cloc INSTALLED!!! -> (brew install cloc)
### USAGE: sh cloc.sh GIT_REPO_URL
#!/usr/bin/env bash
git clone --depth 1 "$1" temp-linecount-repo &&
printf "('temp-linecount-repo' will be deleted automatically)\n\n\n" &&
cloc temp-linecount-repo &&
rm -rf temp-linecount-repo
@Donmclean
Donmclean / app.js
Created June 9, 2017 22:54 — forked from acdlite/app.js
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@Donmclean
Donmclean / Javascript_sort_obj_keys.js
Last active April 14, 2017 14:08
Utilizes reduce method to sort object keys
//Sort obj keys.
//eg: {a: 'test', c: 'test', b: 'test'}
//to: {a: 'test', b: 'test', c: 'test'}
sortObjByOwnKeys = (obj) => Object.keys(obj).sort().reduce((accObj, key) => {
accObj[key] = obj[key];
return accObj;
}, {});
@Donmclean
Donmclean / Shell_nginx_get_pid.sh
Last active February 27, 2017 00:59
Nginx RTMP SETUP
ps axw -o pid,ppid,user,%cpu,vsz,wchan,command | egrep '(nginx|PID)'
@Donmclean
Donmclean / Shell_ffmpeg_stream.sh
Last active September 18, 2021 08:43
Shell Stream audio with ffmpeg
ffmpeg -re -i INPUT -acodec libmp3lame -ab 160k -ar 44100 -f rtp rtp://host:port
#list device audio & video inputs
ffmpeg -f avfoundation -list_devices true -i ""
#stream from device audio & video inputs to rtmp
ffmpeg -f avfoundation -framerate 30 -i "0:2" -vcodec libx264 -tune zerolatency -s 1440x900 -acodec libmp3lame -f flv -strict -1 rtmp://host:port
#stream from audio inputs ONLY to rtmp
ffmpeg -f avfoundation -framerate 30 -i ":2" -acodec libmp3lame -f flv -strict -1 rtmp://host:port/live/$stream_name
@Donmclean
Donmclean / Shell_Install_ffmpeg.sh
Last active May 5, 2017 17:47
Shell Install ffmpeg with all options
brew install ffmpeg --with-chromaprint --with-fdk-aac --with-fontconfig --with-freetype --with-frei0r --with-game-music-emu --with-libass --with-libbluray --with-libbs2b --with-libcaca --with-libebur128 --with-libgsm --with-libmodplug --with-libsoxr --with-libssh --with-libvidstab --with-libvorbis --with-libvpx --with-opencore-amr --with-openh264 --with-openjpeg --with-openssl --with-opus --with-rtmpdump --with-rubberband --with-schroedinger --with-sdl2 --with-snappy --with-speex --with-tesseract --with-theora --with-tools --with-two-lame --with-wavpack --with-webp --with-x265 --with-xz --with-zeromq --with-zimg
@Donmclean
Donmclean / Javascript_redux_observable_handling_async.js
Created February 10, 2017 17:36
Redux Observable Handling Async Example
const fetchFirst = () => ({ type: FETCH_FIRST });
const fetchSecond = (response) => ({ type: FETCH_SECOND, payload: response });
const fetchFirstManager = (actions, store) =>
actions.ofType(FETCH_FIRST)
.switchMap(action =>
ajax('/first')
.map(response => fetchSecond(response))
);
import React, { Component, PropTypes } from 'react';
import _ from 'lodash';
class SomeComponent extends Component {
constructor(props) {
super(props);
this.fetchAjaxFromDebouncedInput = _.debounce(this.fetchAjaxFromDebouncedInput, 3000);
}
fetchAjaxFromDebouncedInput(event) {
@Donmclean
Donmclean / Javascript_detect_tablet_or_mobile_device.js
Last active January 10, 2017 20:11
Detects via javascript is client is mobile/tablet regardless of size. Will always return false on desktop browser. Very Useful!
const isTabletOrMobileDevice = () => {
// return window.screenX === 0 || window.screenLeft === 0; //OLD
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent);
}
@Donmclean
Donmclean / Javascript_Detect_operating_system.js
Created October 7, 2016 21:31
Detect operating system from browser
var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Windows NT 6.2")!=-1) OSName="Windows 8";
if (navigator.appVersion.indexOf("Windows NT 6.1")!=-1) OSName="Windows 7";
if (navigator.appVersion.indexOf("Windows NT 6.0")!=-1) OSName="Windows Vista";
if (navigator.appVersion.indexOf("Windows NT 5.1")!=-1) OSName="Windows XP";
if (navigator.appVersion.indexOf("Windows NT 5.0")!=-1) OSName="Windows 2000";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="Mac/iOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";