ubuntu bluetooth bei start deaktivieren

von
webpirat

um unter ubuntu die bluetooth funktionen permanent (bei system start) auszuschalten,
öffne die datei /etc/rc.local

sudoedit /etc/rc.local

und editiere die datei mit folgendem:

rfkill block bluetooth

so das die datei etwa so aussieht:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

rfkill block bluetooth

exit 0

bluetooth kann natürlich jederzeit über die settings wieder aktiviert werden.

ant task – mysqldump mit gzip

von
webpirat

um mit ant einen gezipten mysqldump zu erstellen, gehe wie folgt vor

    <target name="tstamp" description="create timestamp for further usage">
        <echo message="create timestamp for further usage"/>
        <tstamp/>
    </target>

    <target name="mkdir" description="create backup directory">
        <echo message="create backup directory"/>
        <mkdir dir="${backups}"/>
    </target>

    <target name="dump" description="create db dump and gzip it - depends on tstamp, mkdir" depends="tstamp, mkdir">
        <echo message="create db dump and gzip it"/>
        <exec executable="bash" dir="${backups}">
            <arg value="-c"/>
            <arg line='"mysqldump ${db} -u${db_user} -p${db_pass} | gzip > ${backups}/${db}_${DSTAMP}_${TSTAMP}.sql.gz"'/>
        </exec>
    </target>

mit jhead image metadaten manipulieren

von
webpirat

nach einigen erfolglosen manipulationsversuchen von exif und iptc daten in images, kam jhead. damit ist es möglich, photoshop und windows metadaten in images zu löschen und eigene, echte metadaten in das image zu schreiben.

sentex.net/~mwandel/jhead/

einfach die bin an geeignete stelle kopieren, ausführbar machen und bspw. mit php verwenden:

exec('/usr/bin/jhead -purejpg source.jpg target.jpg');

agavi output type overwrite in action

von
webpirat

um den output type einer agavi action auch nach dem routing zu ändern, kann man innerhalb der action den output type überschreiben.


/**
 * assume that 'html' is the standard GET output for this action
 * when this action is called via POST you want to change the output type to 'json'
 * because on error or success you want to show small messages per json instead full html
 */
    public function executeRead(AgaviRequestDataHolder $rd)
    {
        return 'Input';
    }

    public function executeWrite(AgaviRequestDataHolder $rd)
    {
        $this->getContainer()->setOutputType($this->getContext()->getController()->getOutputType('json'));
        try
        {
            // do POST stuff
        }
        catch(Exception $e)
        {
            $this->setAttribute('message', $e->getMessage());
            return 'Error';
        }
        return 'Success';
    }