Skip to content

Instantly share code, notes, and snippets.

View luanlmd's full-sized avatar

Luan Almeida luanlmd

View GitHub Profile
@luanlmd
luanlmd / Preferences.sublime-settings
Last active October 2, 2015 23:17
Sublime Text Preferences
{
"font_size": 9,
"highlight_line": true,
"shift_tab_unindent": true,
"default_line_ending": "unix",
"ensure_newline_at_eof_on_save": true,
"trim_trailing_white_space_on_save": true,
"translate_tabs_to_spaces": true,
"word_wrap": false,
}
@luanlmd
luanlmd / fstab
Created November 25, 2011 18:44
Mount folder
#add this to fstab
/var/www/ /home/luan/www none rw,bind 0 0
@luanlmd
luanlmd / pgsql_pass.sh
Created September 12, 2011 18:31
Reset PostgreSQL root password
# paste line by line into the right console
sudo su postgres
psql -d template1
ALTER USER postgres WITH PASSWORD 'newpass';
@luanlmd
luanlmd / apt.conf
Created July 19, 2011 13:40
apt-cacher client config
# /etc/apt/apt.conf
Acquire {
HTTP::Proxy "http://10.55.2.224:3142";
FTP::Proxy "http://10.55.2.224:3142";
}
@luanlmd
luanlmd / transmissionLimit.php
Created December 3, 2010 18:55
Set limits for transmission if there is another PCs in the Network or... not
#!/usr/bin/php5 -q
//require https://gist.github.com/725875
<?php
while(true)
{
$alone = shell_exec('./aloneInTheNetwork.php');
if ($alone == 'true')
{
echo 'go go go!';
echo shell_exec('transmission-remote localhost:9091 -AS');
@luanlmd
luanlmd / aloneInTheNetwork.php
Created December 2, 2010 19:16
Check if the PC is alone in the network
#!/usr/bin/php5 -q
<?php
$broadcast = "10.55.2.255";
$ignore = array('10.55.2.240','10.55.2.66');
$ignore = implode('|',$ignore);
$string = "ping -b {$broadcast} -c 2 | grep 'icmp_req=1' | grep -vE '{$ignore}'";
$result = shell_exec($string);
if (trim($result))
{
exit('false');
@luanlmd
luanlmd / etag.php
Created November 18, 2010 20:59
Etag test in PHP
<?php
ob_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Etag test</title>
</head>
<body>
@luanlmd
luanlmd / backup_compact.sh
Created November 7, 2010 20:27
Compact folders after sync
cd /home/secombkp/backup/
DATE=`/bin/date +%Y-%m-%d`
for FILE in *
do
FILENAME=$FILE"-"$DATE".tar.gz"
echo "Creating" $FILENAME
tar -zcf ../backup_history/$FILENAME $FILE
done
@luanlmd
luanlmd / backup_rsync.sh
Created November 3, 2010 21:17
Sync backups
#!/bin/bash
/usr/bin/rsync --progress -avhz --delete --update /folder/from/ user@host:~/folter/to/ --ignore-errors
@luanlmd
luanlmd / backup_pgsql.sh
Created November 3, 2010 21:15
Backup PostgreSQL Databases
#!/bin/bash
LIST=$(/usr/bin/psql -l | /usr/bin/awk '{ print $1}' | grep -vE '^-|^\(|^List|^N[o|a]me|template[0|1]')
for d in $LIST
do
echo "Backuping: " $d
pg_dump -i -h 127.0.0.1 -p 5432 -U postgres -F t -b -f "/backup/backup/$d.backup" $d
tar -zcf /backup/backup/$d.tar.gz -C / backup/backup/$d.backup
rm /backup/backup/$d.backup