Skip to content

Instantly share code, notes, and snippets.

@davecoutts
davecoutts / unifi_ubuntu_2004.sh
Last active May 20, 2024 04:59
Install Ubiquiti Unifi Controller on Ubuntu 20.04
# Install Ubiquiti Unifi Controller on Ubuntu 20.04.
# As tested on a fresh install of ubuntu-20.04.1-live-server, August 22nd 2020.
# Thanks to https://gist.github.com/tmuncks for posting the updated install steps.
sudo apt update
sudo apt install --yes apt-transport-https
echo 'deb https://www.ui.com/downloads/unifi/debian stable ubiquiti' | sudo tee /etc/apt/sources.list.d/100-ubnt-unifi.list
sudo wget -O /etc/apt/trusted.gpg.d/unifi-repo.gpg https://dl.ui.com/unifi/unifi-repo.gpg
@dmitry-mukhin
dmitry-mukhin / composer.json
Last active February 13, 2017 04:26
Saving uploaded files to custom S3 key with PHP
{
"name": "uploadcare/custom-s3",
"description": "Custom S3 storage example",
"license": "MIT",
"authors": [
{
"name": "Dmitry Mukhin",
"email": "dm@uploadcare.com"
}
],
@b13n1u
b13n1u / imscp_migration
Last active February 13, 2018 17:45
I-MSCP migration from old server to a new one.
#Migrate i-mscp to a new server
#the new imscp is already installed and does have a different IP than the old one
#1. Dump the DB and copy the i-MSCP backup to new server:
rsync -rave "ssh -l root" /var/www/imscp/backups 10.0.0.3:/var/tmp/imscp_old_backups
#2.Install the old config DB
#3. Copy all customer data:
rsync -rave "ssh -l root " /var/www/virtual/ 10.0.0.3:/var/www/virtual
@philfreo
philfreo / bucket_policy.js
Created October 6, 2012 01:27
AWS S3 bucket policy to make all files public (+CORS)
{
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::bucket_name_here/*"
@mauris
mauris / gist:3629548
Created September 5, 2012 02:49
Generating Random even or odd number using mt_rand and bitshifting
<?php
$randomValue = mt_rand();
$even = $randomValue & ~1;
$odd = $randomValue | 1;
// magical unicorn isn't it?
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 22, 2024 20:20
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@johnantoni
johnantoni / sftp.synology.txt
Created May 18, 2012 21:34
sftp on synology disk station - ds411-ii
ssh root@nas.mybox.com
vi /etc/ssh/sshd_config
# override default of no subsystems
#Subsystem sftp /usr/libexec/sftp-server
Subsystem sftp internal-sftp
# restart ssh
@dzuelke
dzuelke / bcrypt.php
Last active March 28, 2023 13:15
How to use bcrypt in PHP to safely store passwords (PHP 5.3+ only)
<?php
// secure hashing of passwords using bcrypt, needs PHP 5.3+
// see http://codahale.com/how-to-safely-store-a-password/
// salt for bcrypt needs to be 22 base64 characters (but just [./0-9A-Za-z]), see http://php.net/crypt
$salt = substr(strtr(base64_encode(openssl_random_pseudo_bytes(22)), '+', '.'), 0, 22);
// 2y is the bcrypt algorithm selector, see http://php.net/crypt
// 12 is the workload factor (around 300ms on my Core i7 machine), see http://php.net/crypt
@tylerhall
tylerhall / strong-passwords.php
Created August 12, 2010 21:38
A user friendly, strong password generator PHP function.
<?PHP
// Generates a strong password of N length containing at least one lower case letter,
// one uppercase letter, one digit, and one special character. The remaining characters
// in the password are chosen at random from those four sets.
//
// The available characters in each set are user friendly - there are no ambiguous
// characters such as i, l, 1, o, 0, etc. This, coupled with the $add_dashes option,
// makes it much easier for users to manually type or speak their passwords.
//
// Note: the $add_dashes option will increase the length of the password by