Skip to content

Instantly share code, notes, and snippets.

@zentala
zentala / formatBytes.js
Created September 27, 2017 11:57
Convert size in bytes to human readable format (JavaScript)
function formatBytes(bytes,decimals) {
if(bytes == 0) return '0 Bytes';
var k = 1024,
dm = decimals || 2,
sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
// Usage:
@davebarnwell
davebarnwell / PHP composer tools.md
Last active May 6, 2025 09:47
Global installation of PHP tools with Composer

Global installation of PHP tools with Composer

To install a composer package globally, you run the usual require command, but with the addition of the global modifier. So to install PHPUnit, you would run:

$ composer global require phpunit/phpunit
$ composer global require phpunit/dbunit
$ composer global require phing/phing
$ composer global require phpdocumentor/phpdocumentor
$ composer global require sebastian/phpcpd
@xntrik
xntrik / aws-manage.sh
Last active December 10, 2018 04:58
A simple script to start an AWS EC2 instance and update an associated R53 DNS record. The policy files should setup minimum permissions to allow these actions.
#!/bin/bash
# Dependencies: awscli - see https://aws.amazon.com/cli/
# Some of this is pilfered from
# https://github.com/awslabs/aws-codedeploy-samples
#
# How to use:
# ./aws-manage.sh <instance id> <dns-record> <dns-type> <up|down>
#
# For example:
# ./aws-manage.sh i-7337 xntrik.wtf A up
@subfuzion
subfuzion / curl.md
Last active May 8, 2025 13:29
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@theodorosploumis
theodorosploumis / Install_Phpstorm.sh
Last active June 16, 2022 11:15
Update phpstorm on Ubuntu linux.
#!/bin/bash -e
# IMPORTANT. My phpstom installation exists on /opt/phpstorm.
# Early Access program: https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Early+Access+Program
# For stable releases try: https://data.services.jetbrains.com/products/download?code=PS&platform=linux
if [ "$(whoami)" != "root" ]
then
echo "Sorry, you are not root."
exit 1
fi
@mandiwise
mandiwise / Update remote repo
Last active April 27, 2025 11:53
Transfer repo from Bitbucket to Github
// Reference: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
// See also: http://www.paulund.co.uk/change-url-of-git-repository
$ cd $HOME/Code/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/mandiwise/awesome-new-repo.git
$ git push origin master
$ git remote rm bitbucket
@tleish
tleish / mysql_backup.sh
Last active March 6, 2025 19:47
Bash Script to backup all MySQL databases
#!/bin/bash
#==============================================================================
#TITLE: mysql_backup.sh
#DESCRIPTION: script for automating the daily mysql backups on development computer
#AUTHOR: tleish
#DATE: 2013-12-20
#VERSION: 0.4
#USAGE: ./mysql_backup.sh
#CRON:
# example cron for daily db backup @ 9:15 am
@bendechrai
bendechrai / gencert
Last active August 29, 2015 14:01
OpenSSL certificate generation helper script
#!/bin/bash
################################################################################################################
#
# Place this script in /etc/ssl/private and chown it root and chmod 700
#
# This script will generate basic OpenSSL files and self-sign a certificate
#
# Usage is `gencert domain.name` and the result is domain.name.{key,csr,crt,pem}
# If the domain name provided is a wildcard, the asterisk is replaced with an underscore
@sheikhwaqas
sheikhwaqas / setup-mysql.sh
Last active April 1, 2025 18:16
Install MySQL Server on Ubuntu (Non-Interactive Installation)
# Download and Install the Latest Updates for the OS
apt-get update && apt-get upgrade -y
# Set the Server Timezone to CST
echo "America/Chicago" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
# Enable Ubuntu Firewall and allow SSH & MySQL Ports
ufw enable
ufw allow 22
@msurguy
msurguy / List.md
Last active November 17, 2024 16:29
List of open source projects made with Laravel

Other people's projects:

My projects (tutorials are on my blog at http://maxoffsky.com):