Skip to content

Instantly share code, notes, and snippets.

View codeZoner's full-sized avatar

Fahim Hossain codeZoner

View GitHub Profile
@codeZoner
codeZoner / docker-commands.txt
Last active January 4, 2018 10:54
Nginx Reverse Proxy Setup with Lets Encrypt
//https://cloud.google.com/community/tutorials/nginx-reverse-proxy-docker
//Run the proxy, but this time declaring volumes so that the Let's Encrypt companion can populate them with certificates
docker run -d -p 80:80 -p 443:443 \
--name nginx-proxy \
-v $HOME/certs:/etc/nginx/certs:ro \
-v $HOME/nginx/etc/nginx/vhost.d:/etc/nginx/vhost.d \
-v $HOME/nginx/usr/share/nginx/html:/usr/share/nginx/html \
-v /var/run/docker.sock:/tmp/docker.sock:ro \
--restart=always \
--net reverse-proxy \
@codeZoner
codeZoner / com.startup.plist
Created September 4, 2017 15:32
Launch Demon Start up with Bash Script with Mariadb/Neo4j & Docker
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/opt/icu4c/sbin:/usr/local/opt/icu4c/bin:/usr/local/opt/[email protected]/bin/mysql:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/admin/go/bin</string>
</dict>
<key>Label</key>
@codeZoner
codeZoner / com.startup.plist
Last active July 22, 2022 08:12
Launch Demon Start up with Bash Script with MySQL Example
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- Launch Daemon do not always have access to all the path variables
As a results, scripts will sometimes fail if the you are using path variables inside them
To enable the script to have access to all path variables, open up a terminal and type in -->
<!-- echo $PATH -->
<!-- You can opt to filter out some of the path variables which are not required by script-->
<key>EnvironmentVariables</key>
@codeZoner
codeZoner / .bash_profile
Last active September 4, 2017 15:03
Docker Machine save Machine State Mac OS X
#Docker Auto Evaluate Machine
VM_STATUS="$(docker-machine status default 2>&1)"
if [ "${VM_STATUS}" == "Running" ]; then
eval "$(docker-machine env --shell=bash default)"
fi
@codeZoner
codeZoner / run-command.php
Last active April 12, 2022 19:48
Execute Shell Script using PHP (Git Pull Example)
<?php
// chdir to the correct directory before calling the script
//Ref: https://stackoverflow.com/questions/11052162/run-bash-command-from-php#answer-11052453
$old_path = getcwd();
chdir('/path/to/file');
//make sure to make the shell file executeable first before running the shell_exec function
$output = shell_exec('./shell-script.sh');
chdir($old_path);
echo $output;
@codeZoner
codeZoner / Check If Mobile User Agent - Jquery
Created June 7, 2017 20:45
Check If Mobile User Agent - Jquery
//https://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-mobile-device-in-jquery#answer-3540295
function isMobileUserAgent(){
var isMobile = false; //initiate as false
// device detection
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
isMobile = true;
}
return isMobile;
}
@codeZoner
codeZoner / Check up or down scrolls
Created June 7, 2017 20:43
Check up or down scrolls using JQUERY
//Check up or down scrolls
function isScrollTopOrDown(){
var lastScrollTop = 0, delta = 5;
$(window).scroll(function(){
var nowScrollTop = $(this).scrollTop();
if(Math.abs(lastScrollTop - nowScrollTop) >= delta){
if (nowScrollTop > lastScrollTop){
if(debug){
// console.log('Scrolling Down');