This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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; | |
}, {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ps axw -o pid,ppid,user,%cpu,vsz,wchan,command | egrep '(nginx|PID)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
NewerOlder