14 November 2014

A fast and simple image gallery in PHP

I've just finished a very basic and simple image gallery/explorer in one single PHP file with zero configurazion needed. :)

Demo: http://mira.scavenger.ch/~pascal/psg/gallery.php

Download: https://github.com/pascalbrax/psg

10 November 2014

14 March 2014

Send SMS from Bash script

Since Gnokii failed me without any valid reason, I tried to write myself a piece of code to send SMS from the Linux bash command line.
This script is still buggy and has several race condition issues if you usually send more SMS at once.

MODEM=/dev/ttyUSB0
NUMBER=$1
shift 1
TEXT=$*

echo -e -n "AT+CMGF=1 \015" > $MODEM
echo -e -n "AT+CMGS=\"$NUMBER\" \015" > $MODEM
echo -e -n "$TEXT \015" | cut -c1-150 | tr -d '\n' > $MODEM
echo -e -n "\032" > $MODEM
echo To: $NUMBER
echo Text: $TEXT
echo SMS sent.

20 October 2013

mail bash script for SSMTP

Save this in your path and chmod +x for a nice tiny  "mail" command.

#!/bin/bash

SENDER=`whoami`
RECIPIENT=$1
shift 1
SUBJECT=$*

if test -z "$RECIPIENT"
then 
echo "Missing parameters.

Usage: mail RECIPIENT SUBJECT

  RECIPIENT: Target email address
  SUBJECT: Mail subject


Pascal Brax - http://pascalbrax.blogspot.com
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND"
exit
fi

if test -z "$SUBJECT"
then SUBJECT="Small mail"
fi

echo To: $RECIPIENT
echo Subject: $SUBJECT
echo -n "Short message: "
read MESSAGE
BODY="To: $RECIPIENT
Subject: $SUBJECT

$MESSAGE"
echo "
Sending..."
echo "$BODY" | ssmtp $RECIPIENT 
echo "Mail sent."

16 June 2013

PHP check for the latest Sony Xperia Z firmware

So, I was inspired by this post on XDA, I just wanted put some lines together and created this page:

http://scavenger.ch/sonyupdate

What it does is simply check against http://fuas.sonymobile.com and retrieve the XML with the latest firmware version for the Xperia Z mobile phone (both C6602 and C6603 models). This page can be bookmarked with own model and custom number.

This little stuff has been made with parts of crXml parser from freshmeat.

1 February 2013

Maildir bash script check for new mail

I've set up that tiny script and saved it as "newmail" in /usr/local/bin and added a line at the end of /etc/bash/bashrc

And here it is:

#!/bin/bash

if [ -d ~/.maildir ]
then
  newmail=`find ~/.maildir/new -type f | wc -l`
  if [ $newmail -gt 0 ]
  then
    echo "You have $newmail new mails."
  else
    echo "No new mail for you."
  fi
fi


This script works out-of-the-box for the Gentoo and Funtoo distro, YMMV.