Updates from July, 2011 Toggle Comment Threads | Keyboard Shortcuts

  • diegor 5:23 pm on October 12, 2012 Permalink | Reply
    Tags: apache, , htaccess   

    HOWTO: allow Apache access from IP without password using htaccess 

    Very straightforward. Just write these lines in your VirtualHost, Location or Directory configuration.

    Order deny,allow
    Deny from all
    AuthName " password prompt"
    AuthUserFile /path/to/.htpasswd
    AuthType Basic
    Require valid-user
    Allow from 172.17.10.1
    Satisfy Any

    Easy, isn’t it? Anyway If you have any problem, drop me a comment or a mail. :)

     
    • stefano11 3:47 pm on October 19, 2012 Permalink | Reply

      it works correctly also if you write only:

      Deny from all
      Allow from 172.17.10.1

      Ciao boro! :-)

  • diegor 12:19 pm on September 15, 2012 Permalink | Reply
    Tags:   

    HOWTO: linux terminal cheat sheet 

    Without spending too many words, here you go the image to set as background for your desktop :)

    PS: most of them work also in OSX

     
  • diegor 10:12 am on July 18, 2012 Permalink | Reply
    Tags: ,   

    HOWTO: backup a MYSQL database 

    Backup a database is simple as to dump it. From a Unix shell:

    #> mysqldump --opt -uUSER -pDBPASSWD -hHOSTNAME DBNAME > DUMPED_TEXTFILE

    Ok, now you can dump it following this post. :)

     
  • diegor 5:29 pm on July 17, 2012 Permalink | Reply
    Tags: ,   

    HOWTO: dump data into MYSQL 

    From a Unix shell:

    #>  -hHOSTNAME -uUSER -pDBPASSWD DBNAME < DUMPED_TEXTFILE

    Simple eh :)

     
  • diegor 11:02 am on May 23, 2012 Permalink | Reply
    Tags:   

    HOWTO: Firefox, fix profile in use 

    If you use Firefox and sometime you can have a strange error that prevents its execute:

    “Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system” (on OS X: “A copy of Firefox is already open. Only one copy of Firefox can be opened at a time“).

    A window like the one below will appear:

    No worries, the solution is pretty simple. It’s enough to delete these files:

    • Linux: ~/.mozilla/firefox/.parentlock and ~/.mozilla/firefox/lock
    • OSX: ~/Library/Mozilla/.parentlock
    • Windows: %APPDATA%\Mozilla\parent.lock

    Once deleted those files, launch again Firefox and it should work. If not, drop me a comment.

    PS: Stefano, diegor has come back :)

     
  • diegor 8:13 pm on September 19, 2011 Permalink | Reply
    Tags:   

    HOWTO: import old logs in AWStats 

    AWStats is a great software to analyse Apache logs for having statistics about your sites. Unfortunately it doesn’t offer a tool to import old logs into AWStats. For that I’ve created a small python script to do this. Here you go:

    import commands
    raw_data = commands.getoutput('ls -rt /var/log/2/wespot-access80.log.*.gz')
    logs = raw_data.splitlines()
    for log in logs:
        commands.getoutput('zcat %s > /tmp/tmplog' % log)
        commands.getoutput('/usr/lib/cgi-bin/awstats.pl -update -config=config.site.com -LogFile=/tmp/tmplog')

    If you have problems, comment this post! :)

     
    • Andrea Corbellini 11:09 pm on September 19, 2011 Permalink | Reply

      Hi! AWStats ships with a tool (logresolvemerge.pl) which does exactly the same thing. Also, I think the best way to use the script is not via a temporary file, but specifying something like this in the configuration:

      LogFile=”…/awstats-7.0/tools/logresolvemerge.pl …/access.log* |”

      The pipe symbol tells AWStats to read logs from the output of the command instead of from a file.

      [This is with AWStats 7.0, I don't know about older versions]

      • diegor 10:51 am on September 20, 2011 Permalink | Reply

        Thanks Andrea for your suggestion! When I used AWStats, there wasn’t any tool to do that, so I created my own :)

    • Thomas K. 3:23 pm on July 16, 2012 Permalink | Reply

      Could you explain how to use this python script?

      • diegor 4:25 pm on July 16, 2012 Permalink | Reply

        Obviously you have to replace wespot-access with your filename. The script order in desc way all the logs and start to import into the database using awstats.pl
        Anyway check out the Andrea’s comment, maybe it’s a better solution.

    • Louis 11:26 am on April 5, 2013 Permalink | Reply

      Was trying to do a similar thing in bash but this worked first time… thanks!

  • diegor 6:06 pm on July 29, 2011 Permalink | Reply
    Tags:   

    HOWTO: rename all files in lowercase 

    Pretty simple.

    1. If you don’t have a *NIX operating system, please skip this post.
    2. Create a script with this content:
      #!/bin/sh
      for f in *; do
      g=`expr "xxx$f" : 'xxx\(.*\)' | tr '[A-Z]' '[a-z]'`
      mv -n "$f" "$g"
      done

      and call it “rename.sh”

    3. Give it execution permissions, typing:
      chmod u+x rename.sh
    4. Execute the script from the directory where you have your files to rename
    If you have two files, “Foo” and “foo“, you’ll be notified and no files will be overwritten. So, don’t worry about that, you won’t lose any information. To be sure, try it with a few files in “/tmp” directory.
    Question? Suggestion? Comment! :)

     

     
    • Luca De Vitis 6:26 pm on July 29, 2011 Permalink | Reply

      ls -1 | while read file ; do mv -nv “${file}” “$(echo “${file}” | tr ‘[A-Z]‘ ‘[a-z]‘)” ; done

      • diegor 6:53 pm on July 30, 2011 Permalink | Reply

        Hi Luca, thanks for the trick.
        I tried but it doen’t work.. I have this:

        “namefile not overwritten”

        It works only if I drop “-n” option from mv command (too risky!!)

c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel

Switch to our mobile site

%d bloggers like this: