Skip to content

Instantly share code, notes, and snippets.

@blindpet
blindpet / wordpress
Created May 8, 2015 14:41
nginx Wordpress php5-fpm dotdeb
server {
server_name default_server;
access_log /var/log/nginx/htpcguides.com.access.log;
error_log /var/log/nginx/htpcguides.com.error.log;
root /var/www/htpcguides.com/;
index index.php;
location / {
mysqldump -u [user] -p[password] [database] [table] > [output_file_name].sql
mysqldump -p --user=example --where="x = 'y' AND id = 2" dbname tablename >> dump.sql
#dumping last rows
mysqldump -uroot -p db_name table_name --where='id<1000000'
or you can use
SELECT * INTO OUTFILE 'data_path.sql' from table where id<100000
@blindpet
blindpet / checklinuxdistro
Created July 17, 2015 14:02
check linux distro and grep
cat /etc/*release | grep -E "debian|ubuntu"
@blindpet
blindpet / gist:3a78e12bdf3a11efa857
Created July 21, 2015 09:53
check mono version
mono --version | awk 'FNR == 1 {print $5}' | cut -c-4
@blindpet
blindpet / findipsubnetgateway
Created July 22, 2015 01:47
bash match one word but exclude another
use double grep
command | grep 'what you want' | grep -v 'whatyoudontwant'
Or use awk
awk '/XXX/ && !/YYY/' file
^^^^^ ^^^^^^
I want it I don't want it
You can even say something more complex. For example: I want those lines containing either XXX or YYY, but not ZZZ:
@blindpet
blindpet / installtrans.sh
Last active August 29, 2015 14:25
Install transmission 2.84 on Wheezy
#!/bin/bash
# edited 2015.04.20 15:50 est from https://forum.transmissionbt.com/viewtopic.php?f=1&t=16887#p70825
set -e
SCRIPT="$(readlink -e ""$0"")"
## install dependencies and required compiling tools from standard repos
sudo apt-get update
sudo apt-get -y install build-essential checkinstall pkg-config libtool intltool libcurl4-openssl-dev libssl-dev libevent-dev
sudo sed -i 's/TRANSLATE=1/TRANSLATE=0/' /etc/checkinstallrc
#-uncomment if needed:
http://giantdorks.org/alain/a-shell-script-to-refresh-a-predefined-set-of-pages-in-varnish-cache/
cmd="sudo varnishadm -T 127.0.0.1:6082 -S /etc/varnish/secret"
site="http://www.htpcguides.com"
pages="
/
/feed
"
echo -----------------------------
sudo stat /proc/1/exe
sudo stat /proc/1/exe | grep -i file | awk '{print $4}' | grep 'systemd\|upstart\|init'
cut as well http://linuxpoison.blogspot.hu/2012/08/bash-script-string-manipulation-find-cut.html
http://unix.stackexchange.com/questions/196166/how-to-find-out-if-a-system-uses-sysv-upstart-or-systemd-initsystem
#!/usr/bin/env bash
echo Enter full URL to purge
read url
curl -s $url -H "Cache-Control: no-cache" -o /dev/null
echo Refreshed $url
#safe way to get wheezy or trusty info
cat /etc/*release | grep VERSION= | grep '7\|14'