Skip to content

Instantly share code, notes, and snippets.

@traedamatic
traedamatic / copy_ssh_key.sh
Created March 11, 2017 04:12
Copy SSH key to remote server key-based authentication
# replace the id_rsa.pub with your key file and enter the correct HOSTNAMEANDCONFIG information
cat ~/.ssh/id_rsa.pub | ssh HOSTNAMEANDCONFIG "mkdir .ssh 2>/dev/null; cat >> ~/.ssh/authorized_keys"
@traedamatic
traedamatic / countLinesUnique.sh
Last active March 31, 2016 11:35
shell script count lines with sort
# redirect input in gawk and count unique lines
SOMETHING > gawk '{print $1}' | sort | uniq -c | sort -bgr > counted_lines
@traedamatic
traedamatic / nginxnode.conf
Last active March 6, 2016 10:16
NodeJs and Nginx Minimal Config
server {
listen 80;
server_name localhost domain.io *.domain.io;
location / {
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
@traedamatic
traedamatic / dockernotes.sh
Created February 11, 2016 14:07
docker notes
#notes how to run apps docker
#dockerize a single node app without dockerfile
docker run -p 7777:2368 --rm --name ghostdemo -v "$PWD":/usr/src/app -w /usr/src/app node:0.10 node index.js
@traedamatic
traedamatic / rsyncNohup.sh
Last active August 29, 2015 14:27
Download large file with rsync, nohup and ssh
# play around with fg and bg command the & char
# watch out for any respondes of the script. All respones will be saved in the nohup.log file
nohup rsync --partial --progress --rsh=ssh user@host.com:~/fileonhost.tar .
@traedamatic
traedamatic / dropAllTables.sql
Created July 21, 2015 14:21
generate drop all tables sql
//@see http://stackoverflow.com/a/8248281
SET FOREIGN_KEY_CHECKS = 0
SELECT concat('DROP TABLE IF EXISTS ', table_name, ';') FROM information_schema.tables WHERE table_schema = 'MyDatabaseName';
SET FOREIGN_KEY_CHECKS = 1
@traedamatic
traedamatic / replaceWhiteSpaces
Last active August 29, 2015 14:24
LINUX - replace whitspaces in file names
# linux
find -name "* *" -type f | rename 's/ /_/g'
# mac with zsh
#In zsh, this is easily done with the zmv function. Put autoload -U zmv in your ~/.zshrc, or run this once in your shell, then:
# @see http://unix.stackexchange.com/questions/71690/delete-whitespace-in-filenames-in-directory
zmv '* .pdf' '${f// /}'
@traedamatic
traedamatic / timeMeasure
Created June 4, 2015 09:01
Measure time with cURL
# @see https://josephscott.org/archives/2011/10/timing-details-with-curl/
# do a request curl -w "@timeMeassure.txt" -o /dev/null -s "http://wordpress.com/"
\n
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
@traedamatic
traedamatic / removeFilesFromGit.sh
Created May 26, 2015 16:06
Remove files from GIT
#!/bin/bash
set -o errexit
# Author: David Underhill
# @see http://dound.com/2009/04/git-forever-remove-files-or-folders-from-history/
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
@traedamatic
traedamatic / deleteFiles
Last active August 29, 2015 14:20
deleteFiles shell command
find . -name *.json* | while IFS= read -r f ; do rm $f; done