Skip to content

Instantly share code, notes, and snippets.

cat ~/.ssh/id_rsa.pub | ssh -i aws.pem ubuntu@ip_address "cat - >> ~/.ssh/authorized_keys"
@vielhuber
vielhuber / readme.txt
Last active November 8, 2024 10:47
MySQL: Import/export backup/restore dump mysqldump on command line #sql
// export
mysqldump -h localhost --port 3306 -u username -p"password" --routines database > dump.sql
// import
mysql -h localhost --port 3306 -u username -p"XXX" --default-character-set=utf8 database < dump.sql
// import with progress
pv dump.sql | mysql -h localhost --port 3306 -u username -p"XXX" --default-character-set=utf8 database
// note when using passwords with "$": escape passwords needed
@sirkirby
sirkirby / curlWinCMDSlackNotification.bat
Created September 22, 2015 19:37
Send a slack notification from a windows command prompt using curl
curl -k -g -X POST -d "payload={\"text\":\"my important bot notification\", \"channel\":\"#monitoring\", \"username\":\"computer-bot\", \"icon_emoji\":\":computer:\"}" https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XxXxXxXxXXXxxXXXxxx
@macmladen
macmladen / IPtables and csf.md
Last active January 30, 2025 03:32
Handling firewall blocking and unblocking, iptables, csf
@lukearmstrong
lukearmstrong / nginx-vhost-php.conf
Created October 25, 2013 14:18
Example vhost config for Nginx (PHP)
server {
listen 80;
server_name .example.co.uk.dev;
access_log /usr/local/var/log/nginx/example.co.uk-access.log;
error_log /usr/local/var/log/nginx/example.co.uk-error.log error;
root /var/www/example.co.uk/public;
index index.php index.html;
@kixorz
kixorz / aws_autoscaling_cron.rb
Created March 20, 2013 22:41
Running cron jobs in AWS Auto Scaling group is tricky. When you deploy the same code and configuration to all instances in the group, cron job would run on all of them. You may not want that. This script detects the first instance in the group and allows only this instance to run the job. IAM user used by this script needs to have permissions to…
#!/usr/bin/env ruby
require 'syslog'
require 'net/http'
require 'aws-sdk'
Syslog.open
AWS.config({
:access_key_id => '<iam user key>',
:secret_access_key => '<iam user secret>'
@ericvanjohnson
ericvanjohnson / gist:4597880
Created January 22, 2013 19:55
Rsync over SSH using SUDO on the remote server
rsync -ave "ssh" --rsync-path="sudo rsync" USER@REMOTE_SERVER:/remote/file/path/ /local/file/path