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
# place file in following location | |
/etc/systemd/system/<application name>.service | |
[Unit] | |
Description=<application Name> | |
After=mongodb.service # Example that Requires the mongod service to run first | |
[Service] | |
# make sure to run the following as a regular user so node is found after each node upgrade | |
# n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local |
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
/* | |
from | |
https://medium.com/the-many/adding-login-and-authentication-sections-to-your-react-or-react-native-app-7767fd251bd1#.z5fpuv78y | |
*/ | |
function loggedIn() { | |
// ... | |
} |
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
router.get('*', function(request, response) { | |
let initialState = { title: 'Universal React' }; | |
let store = Redux.createStore(reducer, initialState); | |
ReactRouter.match({ | |
routes: require('./routes'), | |
location: request.url | |
}, function(error, redirectLocation, renderProps) { | |
if (!USER_LOGGED_IN) { | |
let html = ReactDOMServer.renderToString( |
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
#my prompt in lightblue/yellow [user@hostname$] | |
export PS1="\[\033[1;33m\][\[$(tput sgr0)\]\[\033[1;36m\]\u\[$(tput sgr0)\]\[\033[1;33m\]@\h\[$(tput sgr0)\]\[\033[1;37m\]\\$\[$(tput sgr0)\]\[\033[1;33m\]]\[$(tput sgr0)\]\[\033[1;33m\] \[$(tput sgr0)\]" | |
#add timestamps to history | |
export HISTTIMEFORMAT="%d/%m/%y %T " | |
#root prompt in lightblue/red [user@hostname#] (put this in .bashrc of root) | |
export PS1="\[\033[1;31m\][\[$(tput sgr0)\]\[\033[1;36m\]\u\[$(tput sgr0)\]\[\033[1;31m\]@\h\[$(tput sgr0)\]\[\033[1;37m\]\\$\[$(tput sgr0)\]\[\033[1;31m\]]\[$(tput sgr0)\]\[\033[1;31m\] \[$(tput sgr0)\]" |
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
/* | |
Sometimes i wan to run different functions multiple times without re-writing setInterval | |
and specifying speed, etc. This solution made that a little quicker. | |
*/ | |
const looper = (runCount, i, speed, logit, fn, ...args) => { | |
let r = () => { | |
if (i++ >= runCount) {clearTimeout(si)}; | |
logit ? console.log(fn(...args)) : fn(...args); | |
}; | |
let si = setInterval(r, speed); |
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
/* | |
I needed to convert many values in thousands of records in multiple relational collections to | |
non-recognizable random strings. This way I could still use private DB records to populate a database for | |
a demo application without compromizing privacy or security. Rather than create a function to create thousands | |
of random records with connected relations, or replace each value with a random word from an array of strings, | |
I passed each value through this function before populating the record in the demo database. | |
It removes all spaces, splits the characters into an array, sorts alphabetically, grabs a random position | |
in the array of letters, assigns a random string based on a random Unicode value from 1-50, assigns that |