the permanent TODO

March 8, 2010

uncommenting a code block with Vim

Filed under: Uncategorized — {Francisco,François} Varas @ 9:30 am

Note: I use the set number option by default.
To uncomment a block beginning with the character “#” from line 9 to line 13

Use:
:9,13s/^//g

March 1, 2010

commenting a code block with Vim

Filed under: Uncategorized — {Francisco,François} Varas @ 9:30 am

Note: I use the set number option by default.
To comment a block with the character “#” from line 9 to line 13

Use:
:9,13s/^/#/g

and so on…

February 25, 2010

indentation with Vim

Filed under: Uncategorized — {Francisco,François} Varas @ 11:50 am

to indent a block, select lines with v or shift+v
and j or down arrow, then use the > command.

Nice one :)

February 15, 2010

exporting users between two debian machines

Filed under: tech — Tags: , , — {Francisco,François} Varas @ 9:00 am

I wanted to create an account in my backup machine for a good friend of mine.
As laziness is a fundamental virtue I wanted to avoid as much work as possible, including the part of calling my good friend to tell him to change the password that was random generated in the second machine.
mi first try was:
(as root)
grep <user> /etc/{passwd,shadow,group} >> user_info.text

Then, copy each line of users_info.text into the passwd, shadow and group file in /etc/ on the second unit

February 1, 2010

Installing Go with debian

Filed under: tech — Tags: , , , — {Francisco,François} Varas @ 10:50 am

I tried to install Go (Google’s programming language) this WE.
Under MAC OS X the install was clean, but under Debian I had a lot of error messages.
To avoid all that noise, you need to go to $GOROOT/src/pkg and edit the Makefile
search the NOTEST section and (respecting the identation) add:

http\
net\
syslog\

Try again and let me know if it works :)

January 25, 2010

mounting an NFS filesystem

Filed under: tech — {Francisco,François} Varas @ 9:00 am

Imagine you want to share all your music at home, avoiding annoying VoD servers. Here’s the trick:

Server: 192.168.0.11
Clients: 192.168.0.0/24 (this means: “everybody in this network”)

in the server:

  • apt-get install nfs-kernel-server
  • then edit /etc/exports
    • add the line:
    • /home/invitado/ 192.168.0.13(rw,no_root_squash)
  • exportfs -a

in the client(s):
192.168.0.11:/home/invitado /mnt/storage2 nfs nfsvers=3,intr,timeo=5 0 0
If you find weird RPC errors and are unable to mount NFS, edit /etc/default/portmap and comment the line OPTIONS=”", which makes portmap to listen locally.
If you are using nfs-user-server, avoid “nfsvers=3″ in the client conf.

January 18, 2010

dumb apache2 iptables security

Filed under: tech — Tags: , , — {Francisco,François} Varas @ 9:00 am

This is an aggressive script that will -j DROP anything that moves.

This is the regexp list (noisily named “regexp-list.ib” in my filesystem):

#file containing idiotblocker's database
w00tw00t
php.my.admin

This is the script:

for i in `grep -iv ^# regexp-list.ib`
do for a in `grep -i $i /var/log/apache2/access.log | awk -F'-' '{print $1}' |sort -n | uniq`
do echo "$a found and screwed with iptables"
iptables -A INPUT -s $a -j DROP
done
done

January 11, 2010

building packages from the source with apt-get

Filed under: Uncategorized — {Francisco,François} Varas @ 9:00 am

want to build gkrellm from the source?
if you see something weird in the code below, IT’S A JOKE
If you don’t see anything weird, nevermind…life goes on

c:\>su [troll] not sudo, sudo is for newbies [/troll]
c:\>cd /usr/scr
c:\>apt-get build-dep gkrellm
c:\>apt-get source mplayer --build
you can safely go for an orange juice can now
c:\>dpkg -i gkrellm_2.3.2-5_i386.deb

And, of course this procedure will work for other packages.

Have a nice day!

January 4, 2010

forgot the name of your mysql database?

Filed under: Uncategorized — {Francisco,François} Varas @ 9:00 am

you will search for existent mysql databases:

sweet@home:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2745
Server version: 5.0.51a-24+lenny2 (Debian)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| wp-database |
+--------------------+
3 rows in set (0.00 sec)

mysql> Bye

then:

sweet@home:~$ mysql -u root -p wp-database
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2747
Server version: 5.0.51a-24+lenny2 (Debian)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show tables;
+-----------------------+
| Tables_in_xxxxxx |
+-----------------------+
| wp_commentmeta |
| wp_comments |
| wp_links |
| wp_options |
| wp_postmeta |
| wp_posts |
| wp_term_relationships |
| wp_term_taxonomy |
| wp_terms |
| wp_usermeta |
| wp_users |
+-----------------------+
11 rows in set (0.00 sec)

mysql> Bye

December 28, 2009

wordpress backup

Filed under: Uncategorized — {Francisco,François} Varas @ 9:00 am

keeping in mind the quick and dirty ethics, no boring explanations, here’s my approach on how to backup wordpress’ mysql database. it’s useful to do it before upgrades, long holidays in southamerica, dull sundays, political p.o.v. modifications and because it is a healthy habit.

this is my script (if you carefully google it, you will find out that it is not an original idea)


#!/bin/sh

DBBDATE=`date +%Y-%m-%d_%H.%M.%S`
DB_USER=user
DB_ACCESS=xxxxxxxx   #password
DB_NAME=wpdatabse    #how you named your wp database
BLOG=TODO

mysqldump --opt -u $DB_USER -p$DB_ACCESS $DB_NAME > database_$BLOG-at-$DBBDATE.sql

#un comment the following line to make a local copy
#cp database_$BLOG-at-$DBBDATE.sql /mnt/backups

#un comment the following line to make a remote copy
#scp -P 1234 database_$BLOG-at-$DBBDATE.sql user@remote.unit.com:/mnt/backups/

Stuff written in red MUST be changed, excepting only wise people that have a FQDN like “remote.unit.com” and a partition called ‘/mnt/backups/’ or so.

Older Posts »

Powered by WordPress