Skip to content

Instantly share code, notes, and snippets.

labbots

Block or report user

Report or block labbots

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@labbots
labbots / zipper.vbs
Last active Mar 28, 2019
VBS script to create zip for file or folder in Windows using ONLY Windows' built-in capabilities
View zipper.vbs
Set Args = Wscript.Arguments
source = Args(0)
target = Args(1)
tempDir = Empty
Function GetFullPath(path)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
GetFullPath = fso.GetAbsolutePathName( path )
End Function
View gitconfig
[user]
name = you name
email = you_email_address
[alias]
# nice log output
lg = log --graph --pretty=oneline --abbrev-commit --decorate
# start git-sh
sh = !git-sh
[color]
# turn on color
@labbots
labbots / SwitchPhp.sh
Last active Apr 1, 2019
Bash script to switch between available PHP versions in Ubuntu. (Tested in Ubuntu 16.04)
View SwitchPhp.sh
#!/bin/bash
# Check if ran with root permissions
if [ `id -u` -ne 0 ]; then
printf "The script must be run as root! (you can use sudo)\n"
exit 1
fi
function arrayContains {
local e match="$1"
@labbots
labbots / replicate_db.sh
Created Dec 23, 2016
Script to replicate Mysql databases for local development
View replicate_db.sh
#!/bin/bash
source=${1}
destination=${2}
user=${3:-root}
pass=${4}
# Help menu
print_help() {
echo -e "
@labbots
labbots / mime_type.sh
Created Dec 23, 2016
Get mime-type of a file based on extension if exists or by using file command
View mime_type.sh
#!/bin/bash
FILE=$(basename $1)
FILENAME="${FILE%.*}"
EXTENSION="${FILE##*.}"
echo "$FILE"
echo "$FILENAME"
echo "$EXTENSION"
View color_script.sh
#!/bin/bash
txtund=$(tput sgr 0 1) # Underline
txtbld=$(tput bold) # Bold
bldred=${txtbld}$(tput setaf 1) # red
bldblu=${txtbld}$(tput setaf 4) # blue
bldwht=${txtbld}$(tput setaf 7) # white
txtrst=$(tput sgr0) # Reset
info=${bldwht}*${txtrst} # Feedback
pass=${bldblu}*${txtrst}
View bash_aliases
#lists contents of current directory with file permisions
alias ll='ls --color -l -sort'
#list all directories in current directories
alias ldir='ls -l | grep ^d'
# List directory and pipe output to less. Makes viewing of large directory easy
alias lsl="ls -lhFA --color | less -r"
#Find files in current directory
@labbots
labbots / install_ubuntu_package.sh
Last active Dec 22, 2016
Script to install Ubuntu packages from package list file. If the package fails to install then report them in separate log file for manual installation. https://labbots.com/how-to-migrate-from-one-ubuntu-machine-to-another/
View install_ubuntu_package.sh
#!/bin/bash
#!/bin/bashset -e
VERBOSE=true
FILE="$1"
function log() {
error="$2"
if [[ "$VERBOSE" = true ]] || [[ "$error" = true ]] ; then
echo -e "${1}"
@labbots
labbots / split_merge_file.sh
Last active Dec 22, 2016
Simple test to check the usage of dd command. This script allows to split a file into chunks and merge them back from chunks to original file using dd command in linux. https://labbots.com/split-and-merge-file-using-dd-command/
View split_merge_file.sh
#!/bin/bash
#!/bin/bashset -e
PROGNAME=${0##*/}
SHORTOPTS="mbs:d:p:"
LONGOPTS="merge,split,source:,destination:,prefix:"
set -o errexit -o noclobber -o pipefail
OPTS=$(getopt -s bash --options $SHORTOPTS --longoptions $LONGOPTS --name $PROGNAME -- "$@" )
eval set -- "$OPTS"
@labbots
labbots / file_cache_clean.sh
Last active Dec 22, 2016
Bash script to clean files in directory based on access time and created time. https://labbots.com/delete-stale-files-by-access-time-bash/
View file_cache_clean.sh
#!/bin/bash
#!/bin/bashset -e
# Script to cleanup cache files in file system.
# This script is used to make sure the cache folder does not exceed the set threshold limit in the server.
# The script can be configured as cron job in the server to monitor and delete older files in specified directory.
# The script sends out email if the script cannot bring the directory size below the threshold even after deleting
# files based on min and max access time and created time set in the script.
#
# Usage
You can’t perform that action at this time.