Skip to content

Instantly share code, notes, and snippets.

@virullius
virullius / gist:77269e40faec18c0a875
Created January 6, 2015 15:41
be nice while taking backup of production webapp on linux during business hours
# default nice value seems fine in my case; ionice has no default, using class 3 for idle IO time
ionice -c 3 nice tar ~/the-webapp-20150106.tgz /opt/the-webapp
@virullius
virullius / gist:e7873a169d360aa2b06a
Created December 16, 2014 00:27
check if nginx is running without killall
kill -0 $(ps -eo pid,command | grep nginx | grep master | awk -F ' ' '{print $1}')
@virullius
virullius / Office2010Pro-Mint17.md
Last active September 9, 2015 21:07
Install MS Office Pro 2010 on Linux Mint 17 (Ubuntu 14.04) (wine 1.6.2)

Install MS Office 2010 Pro 32 bit on LinuxMint 17 (Ubuntu 14.04)

install prerequisite winbind

sudo apt-get install winbind

create prefix

WINEPREFIX=/home/<username>/.wine-<myprefix> WINEARCH=win32 wine 'wineboot'
@virullius
virullius / gist:870fbad498cd74e954f4
Created December 4, 2014 18:03
Refresh user's groups - linux
exec su -l $USER
@virullius
virullius / gist:5b2c66983dc2665df7a8
Created December 3, 2014 18:23
highlight matched text, linux shell
# trick is to match on a non-printing character (^ is beginning of line) OR your pattern.
# this way all lines match but only your pattern containing printable characters will be highlighted
# using ^ requires Extended-Regexp option (-E)
grep -E '^|pattern' file.log
@virullius
virullius / base-conversions.sh
Created October 30, 2014 15:49
Baes and ASCII conversion in bash. (hex, decimal, binary)
echo "syntax for base conversion in bash is: \$((\$BASE#\$VALUE))"
echo
echo "Decimal value of Hexadecimal 2B: \$((16#2B))"
echo $((16#2B))
echo
echo "Decimal value of binary 0110: \$((2#0110))"
echo $((2#0110))
echo
@virullius
virullius / args.sh
Created October 28, 2014 15:54
Shell argument examples (bash, sh, zsh)
echo "\$# is the number of arguments"
echo "$# arguments"
echo
echo "\$* is list of arguments joined into a string"
echo $*
echo
echo "\$@ is a sequence of strings, well suited to a for loop"
echo $@
@virullius
virullius / extract-site.php
Last active August 29, 2015 14:05
Convert / Extract EE+MSM site to single site EE database. (ExpressionEngine,MultiSiteManager)
#!/usr/bin/env php
<?php
/* convert Multi Site Manager (MSM) ExpressionEngine (EE) database to single site database.
* used to split a site to own EE instance without MSM.
* Deletes all sites other than site_id specified then changes specified sites id to 1.
* Ignores site_id 0, although I don't rememeber why.
* I ran it from Linux command line, no idea if it will run the same on Window or Mac.
*/
@virullius
virullius / transfer_mysql_db.sh
Created August 27, 2014 21:29
Copy and rename MySQL database
#!/usr/bin/env bash
# transfer mysql database to different server with a new name
# such as production database to test database
read -p "source host:" SRC_HOST
read -p "user for host $SRC_HOST:" SRC_USER
read -p "password for $SRC_USER@$SRC_HOST:" -s SRC_PW; echo
read -p "source database name:" SRC_DB
read -p "target host:" TGT_HOST
@virullius
virullius / hostname-to-lower.sh
Created June 18, 2014 16:39
Make hostname lowercase on linux
# set hostname to lower in /etc/hosts file
sed -i "s/$(hostname)/$(hostname | tr '[:upper:]' '[:lower:]')/" /etc/hosts
# set runtime hostname to lowercase
hostname $(hostname | tr '[:upper:]' '[:lower:]')
# save lowercase hostname to /etc/hostname file
hostname > /etc/hostname