Samstag, 28. September 2013

Ein Phantastisches Tool in Javascript um prozeduren step by step darzustellen. Ein Must have für alle Mathe/Physik-Lehrer http://www.fullstack.io/choc/

Freitag, 19. Juli 2013

Replace Dropbox with BitTorrent Sync and a Raspberry Pi

This is soo neat..
http://jack.minardi.org/raspberry_pi/replace-dropbox-with-bittorrent-sync-and-a-raspberry-pi/

But also take a look at this:
https://gnunet.org/

and this.. which is the very nice and comprehensive
http://owncloud.org/

Samstag, 29. Juni 2013

Windows batch bat - Compare and Sync larg filelist (images) by FTP and convert with irfan bevore upload

So I give you my aproach to upload files to your FTP Folder on windows. The job runs every 5minutes on the client system. To have all your products as soon as possible online - and hey?! why not if you CAN! :)

Task I     Compare lokal files with your FTP-Account and upload missing files.
Solution: Copy the files to a local txt/text and grep the filenames of local files in the downloaded text. If File is missing upload that file

Task II  Convert image with irfanview on windows
Solution: Irfanview is your friend

What to face behinde the scene :
TI 1. Looping through thousands of files and comparing them with the remote could be endless
TI 2. Love grep.exe: findstr in batch/bat is woodo and no good for a serious aproach on large file systems.

TII 1. FTP to a non standard port
TII 2. Have a reliable FTP-Client on windows who won't break png's

What you need to install: 
========================
Grep: http://gnuwin32.sourceforge.net/packages/grep.htm
ncftp client for windows: http://www.ncftp.com/download/

The Script (sorry, the code could be a bit messi. but its just a copy and paste
==============================================================================
@echo off
REM
REM Call AdOptimize for more confusing scripts mk@adoptimize.de 2013
REM - sorry we don't die in beauty but we move on -
REM
:: config

SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION

set orgFolder=C:\yourFolderWithHighResImages\uploads\
set "destFolder=C:\yourFolderWithLowResImages\800x600\"
set "irfanFolder=C:\Program Files (x86)\IrfanView\"
set processFolder=C:\image-convert-batch
set "imageExists=0"


:: Load files listed remote in tmp.txt
Del tmp.txt
ncftpls -P 22121 -u ftpUserName -p ftpPassword -m ftp://yourServer/httpdocs/yourUploadFolderToCompare > %processFolder%\tmp.txt
echo loaded remote files

:: search for all files in folder
for %%f in (%orgFolder%*.png) do (call :funcExists %%~nxf)


::
:: if file does not exist, convert create and move to ftp
:funcExists 

    set "filename=%1"

    :: read files from tmp.txt remote file list

    if Exist %destFolder%%1  (
        :: locally saved images might not exist remote. we check this
        pushd "C:\Program Files (x86)\GnuWin32\bin\"
        grep "%filename%" %processFolder%\tmp.txt >%processFolder%\result.txt

        set /p result=<%processFolder%\result.txt
        echo Error-Level aa%result%aa "!result!"
     if "!result!" == "" (
            call :ftpupload %1
        ) else (
            goto :next_2
        )
        popd
        goto :eof
    ) else (
        echo Brand New File %1
        call :convertAndUpload %1  
        goto :eof
    )
:next_2
goto:eof
:: /funcExits


::
:: convert the image and upload to remote host
:convertAndUpload

    cd /d "%irfanFolder%"
    :: convertieren und in ZielDatei ablegen 
    i_view32.exe %orgFolder%%1 /resize_long=800 /aspectratio /resample /convert=%destFolder%%1
    echo irfan view modified image %1
    call :ftpupload %1

goto :eof
:: /convertAndUpload


:: upload a file to the webserver
:ftpupload
    
    echo uploading %1
    cd /d %processFolder%\
    ncftpput -P 22121 -f ncftpput-cnf.txt httpdocs/yourUploadFolderToCompare %destFolder%%1

goto :eof
:: / upload


:: OBSOLETE
::
:: extract date and filename from tmp.text dir listing
:processline

    set imageExists=0
    set line=%*
    :: extract the last part of the line seperated by a space is filename in file
    for /f "tokens=1,2 delims= " %%a in ("%line%") do (
        set var1=%%a
        set filenameTmp=%%b
       
        if "%filename%" == "%filenameTmp%" (
            set imageExists=1
     REM echo Found: "%filename%" == "%filenameTmp%"
            goto :next
        )
    ) 

:next
goto:eof
:: /processline


cd %processFolder%


ENDLOCAL
:eof

Papers and essays that every programmer should be aware of

Brilliant HowTos Brillant Tips in a beautiful aproach http://projectmona.com/bits-of-brilliance-session-five/

Freitag, 21. Juni 2013

Batch Script Help redirecting stdout into an evironment variable and %~dp0 http://weblogs.asp.net/lorenh/archive/2006/03/24/silly-batch-file-tricks-redirecting-stdout-into-an-evironment-variable-and-dp0.aspx