Skip to content

Instantly share code, notes, and snippets.

View filviu's full-sized avatar

Silviu Vulcan filviu

View GitHub Profile
@filviu
filviu / hostapd.conf
Created October 16, 2014 10:48
hostapd configuration for hotspot on debian
interface=wlan0
driver=nl80211
country_code=RO
ieee80211d=1
ssid=SSIDNAME
channel=6
hw_mode=g
@filviu
filviu / clone.sh
Created September 30, 2014 09:21
dd with pv progress
#!/bin/bash
dd if=/dev/vg/sys01 | pv -ptera -s 10g | dd of=/dev/vg/sys02
shutdown /s /f /t 3600
REM where
REM /s - shutdown local computer
REM /f - force programs to close without showing warning
REM /t 3600 - delay for 3600 seconds (1 hour)
@filviu
filviu / rename.sh
Created September 16, 2014 20:13
I discovered that xbmc prefers "movie name (yyyy)" instead "yyyy - movie name"
#!/bin/bash
while read NAME; do
YEAR=$(echo $NAME | sed -r 's/\ -\ /_/' | awk -F_ '{print $1}')
NEWNAME=$(echo $NAME | sed -r 's/\ -\ /_/' | awk -F_ '{print $2}')
mv "$NAME" "$NEWNAME ($YEAR)"
done < <(ls -1 | grep -v rename.sh)
@filviu
filviu / connect-vpn.sh
Created September 9, 2014 05:50
Auto connect a vpn with NetworkManager. Place this in /etc/NetworkManager/dispatcher.d/
#! /bin/bash
REQUIRED_CONNECTION_NAME="NAME"
VPN_CONNECTION_NAME="VPN_NAME"
activ_con=$(nmcli con status | grep "${REQUIRED_CONNECTION_NAME}")
activ_vpn=$(nmcli con status | grep "${VPN_CONNECTION_NAME}")
if [ "${activ_con}" -a ! "${activ_vpn}" ];
then
@filviu
filviu / get-package-size.sh
Last active August 29, 2015 14:06
What packages use the most diskspace on Slackware
grep "UNCOMPRESSED PACKAGE SIZE" /var/log/packages/* | sed 's/ *//g' | awk -F: '{ print $3" " $1 }' | sort -rh | head -n10
@filviu
filviu / export-csv.sql
Created September 1, 2014 06:52
Export mysql data directly to csv from the command line. From http://www.tech-recipes.com/rx/1475/save-mysql-query-results-into-a-text-or-csv-file/
SELECT order_id,product_name,qty
FROM orders
INTO OUTFILE '/tmp/orders.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
#!/bin/bash
count=0
for DISK in sda sdb sdc sdd sde sdf; do
/usr/sbin/smartctl --all /dev/$DISK > /var/www/htdocs/status/data/smart$count.txt
((count++))
done
@filviu
filviu / screen-items.sh
Created August 19, 2014 05:58
script screen to create multiple windows
#!/bin/bash
screen -dmS servers -T xterm -t "http" sh -c 'cd /servers/start/httpo;run.sh'
screen -T xterm -S "servers" -X screen screen -t "sql" sh -c 'cd /servers/start/sql;run.sh'
# The "-T xterm" switch isn't really necessary, unless you plan to use curses-based programs from inside the screen (mc, less, etc.).
@filviu
filviu / n800-clone.sh
Created August 19, 2014 05:55
n800 sdcard boot
In short, this is what I did to get my N800 to boot OS2008 from MMC. My steps were:
1) upgraded my N800 to OS2008, http://europe.nokia.com/A4305010
2) enabled the Maemo Extras repository in Application Manager and added http://repository.maemo.org, Distribution: (blank) Components: free non-free
3) installed openssh using Application Manager
4) defined a root password (openssh's installer prompted for this)
5) opened xterm and:
# ssh root@localhost
# visudo