iCal: Arbeitszeiterfassung die 2.

by hubi on 12/08/2011

Marko hat mich gebeten das Zeiterfassungs-Skript, dass ich mal vor einiger Zeit geschrieben habe, etwas zu erweitern, so dass auch einen Statistik für den gesamten Monat ausgegeben wird. Zudem ist in diese Version auch ein Growl-Status-Anzeige eingebaut, so dass das Skript nicht kommentarlos den Kalender befüllt. Ich habe das Skript mit 10.7 getestet, ich denke es sollte aber auch problemlos noch unter den letzten beiden System funktionieren (Die App müsste eine reine Intel App sein, da 10.7 nicht anderes mehr auszugeben versteht. Auf einem PPC müsste der AppleScript-Editor aber damit zurande kommen, also in dem Fall einfach neu als App speichern und man hat wieder eine CarbonApp) =)DOWNLOAD
iCal_Time-Recording v.1.2
191.69 kB (98 hits)

7 Comments

OS X Lion: Fensterwiederherstellung für einzelne Programme sperren

by hubi on 11/08/2011
defaults write com.apple.QuickTimePlayerX NSQuitAlwaysKeepsWindows -bool false via OS X Lion: Fensterwiederherstellung für einzelne Programme sperren « macnews.de.In der Library, unter Saved Application State werden alle Programme aufgeführt, bei denen ein solcher SavedState bereits gespeichert wurde =) also warum nicht ein kleines Skript:

--11.08.2011 little script to edit saved state settings for a single app instead of all apps

global myhome

tell application "Finder"

set myhome to POSIX path of (home as alias)

set theitems to name of every item of folder "Saved Application State" of folder "Library" of home

set theapps to {}

repeat with theitem in theitems

if (theitem as text) ends with ".savedState" then

set theapps to theapps & ((characters 1 through -12 of theitem as text) as text)

end if

end repeat

end tell

set theapp to (choose from list theapps with prompt "Which app with saved state?") as text

set theactions to {"Delete SavedState", "Disable SavedState", "Enable SavedState", "Freeze Saved State", "Defrost Saved State"}

set theaction to (choose from list theactions with prompt "Which action?") as text

if theaction = (item 1 of theactions) as text then

my deleteSavedState(theapp)

else if theaction as text = (item 2 of theactions) as text then

my disableSavedState(theapp)

else if theaction as text = (item 3 of theactions) as text then

my enableSavedState(theapp)

else if theaction as text = (item 4 of theactions) as text then

my freezeSavedState(theapp)

else if theaction as text = (item 5 of theactions) as text then

my defrostSavedState(theapp)

end if


on deleteSavedState(appName)

--moves avedState to user's trash folder and plays drag to trash sound

do shell script "mv " & myhome & "Library/'Saved Application State'/" & quoted form of appName & ".savedState ~/.Trash/;afplay /System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/dock/drag\\ to\\ trash.aif"

end deleteSavedState


on disableSavedState(appName)

--uses defaults write to disable saved state for this particular app

do shell script "defaults write " & appName & " NSQuitAlwaysKeepsWindows -bool false"

do shell script "afplay /System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/ink/InkSoundBecomeMouse.aif"

end disableSavedState

on enableSavedState(appName)

--uses defaults write to disable saved state for this particular app

do shell script "defaults write " & appName & " NSQuitAlwaysKeepsWindows -bool true"

do shell script "afplay /System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/ink/InkSoundBecomeMouse.aif"

end enableSavedState


on freezeSavedState(appName)

--changes user permissions to read only, so that savedStated is frozen

do shell script "chmod u-w " & myhome & "Library/'Saved Application State'/" & quoted form of appName & ".savedState"

do shell script "afplay /System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/ink/InkSoundBecomeMouse.aif"

end freezeSavedState

on defrostSavedState(appName)

--changes user permissions to read&write again, so that savedStated is not frozen any more

do shell script "chmod u+w " & myhome & "Library/'Saved Application State'/" & quoted form of appName & ".savedState"

do shell script "afplay /System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/ink/InkSoundBecomeMouse.aif"

end defrostSavedState

Update:

Ok, das hier ist nun wirklich eine schönere Lösung: http://www.tuaw.com/2011/07/26/dear-aunt-tuaw-help-me-fine-tune-session-window-restores/
No Comments

Umlaute und Sonderzeichen in Datei- und Ordnernamen ersetzen

by hubi on 2/08/2011
Das war der Auslöser und es hier meine Lösung dazu:

-- hubionmac.com 02.08.2011

-- ersetzt in einem Verzeichnis und allen Unterordnern Sonderzeichen (Umlaute) in Datei und Ordnernamen

-- es können so nur einzelne Sonderzeichen gegen Zeichenketten ersetzt werden ä ->ae

set replacements_list to {{"Ä", "Ae"}, {"ä", "ae"}, {"Ö", "Oe"}, {"ö", "oe"}, {"Ü", "ue"}, {"ü", "ue"}, {"/", "_"}}


set thefolder to choose folder

set thefiles_x to do shell script "find " & quoted form of (POSIX path of thefolder) & " -not -name \".*\""

-- Baut sich eine Liste aus Aliasen, damit die Pfadangaben auch noch funktionieren,

--wenn mal ein übergeordnetes Verzeichnis bereits vom Skript umbenannt wurde

set thefiles to {}

repeat with thefile in every paragraph of thefiles_x

set thefiles to thefiles & ((POSIX file thefile) as alias)

end repeat


repeat with thefile in thefiles

tell application "Finder"

set thefilename to name of thefile

set old_filename to thefilename

end tell

repeat with replacement in replacements_list

set badchar to ASCII number of ((item 1 of replacement) as text)

set thefilename_ascii to asciilist(thefilename)

if badchar is in thefilename_ascii then

set thefilename to my replace_string(thefilename, ASCII character badchar, (item 2 of replacement) as text)

end if

end repeat

if old_filenamethefilename then

tell application "Finder"

set name of thefile to thefilename

end tell

end if

end repeat


on replace_string(itemname, searchstring, replacestring)

set old_delimiter to AppleScript's text item delimiters

set AppleScript's text item delimiters to searchstring

set the item_list to every text item of itemname

set AppleScript's text item delimiters to replacestring

set this_text to the item_list as string

set AppleScript's text item delimiters to old_delimiter

return this_text

end replace_string


on asciilist(thestring)

set myoutput to {}

repeat with a in every character of thestring

set myoutput to myoutput & (ASCII number of a)

end repeat

return myoutput

end asciilist

1 Comment

Airport Scanner

by hubi on 27/07/2011
Wie bekomme ich den aktuellen Kanal der umliegenden Station heraus. AirportRadar, KisMac oder AP Grapher muss man erst mal haben und laden, womit es auch geht ist mit/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -sosxdaily hat auch noch diese Zeile hier zum Besten gegeben, um einen einfacheren Aufruf zu gewährleisten: sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport Danach kennt das Terminal ein airport-Kommando =)
No Comments

Library unter 10.7 wieder anzeigen lassen

by hubi on 26/07/2011
Um nicht immer umständlich über "Gehe zu…" den Ordner öffnen zu müssen: chflags nohidden ~/Library
No Comments

Batch PNG Convert

by hubi on 21/07/2011
Sehr nützliches sips-Skript mkdir pngs; sips -s format png *.* --out pngs Einfach in einem Verzeichnis mit z.B. eine Menge PSD-Dateien ausführen und man bekommt recht schnell eine PNG-Version dieser Dateien.
No Comments

Synology: DynDNS mal anders

by hubi on 13/07/2011
Ich habe meine Synology NASs zur Zeit hinter einer Telekom-Leitung. D.h. ich habe alle 24 Stunden leider ein Zwangstrennung und der Router (Netgear :-( ) verpennt ab und an das DynDns-Update. Nun hat das NAS-System einen eingebauten DDNS-Client, nur steht nirgends, wie oft dieser Client ein Update durchführt. Nun folgender Tipipkg auf dem NAS installieren (hatte ich bereits) und dann über die Shell: ipkg update ipkg install inadyn Dann noch eine Konfigurationsdatei erstellen: vi /root/inadyn.conf mit dem Inhalt update_period_sec 1200 # Check for a new IP every 1200 seconds username hubionmac password 1skks9sjdj292 dyndns_system dyndns@dyndns.org alias blafasel.dyndns.orgund dann noch in in die /etc/rc.local eine den Aufruf für den Start einbauen: /opt/bin/inadyn --input_file /root/inadyn.conf & Neustart, fertig Ob das Funktioniert? Mal sehen =)optional kann man sich die Konfig-Datei auch sparen und den Aufruf direkt in die rc.local schreiben /opt/bin/inadyn --username blafaseuser --password blafasel --alias blafasel.dyndns.org --dyndns_system custom@dyndns.org --background
No Comments

Adressbuch: checkt ob eine Telefonnummer bereits vorhanden ist

by hubi on 30/06/2011
Das ist nur als Beispiel gedacht, wie so eine Funktion aussehen könnte:

tell application "Address Book"

activate

set my_phone_2_check to text returned of (display dialog "Telefonnummer:" default answer "0")

set allp to people

set phone_numbers to value of every phone of people

repeat with i from 1 to count of phone_numbers

set current_phone_numbers to item i of phone_numbers

if (count of current_phone_numbers) > 0 then

repeat with phone_number_2_check in current_phone_numbers

set phone_number_2_check to phone_number_2_check as text

if phone_number_2_check starts with "+" then

set phone_number_2_check to ("0" & characters 4 through -1 of phone_number_2_check) as text

end if

if phone_number_2_check contains " " then

set phone_number_2_check to my replace_chars(phone_number_2_check, " ", "")

end if

if phone_number_2_check contains "-" then

set phone_number_2_check to my replace_chars(phone_number_2_check, "-", "")

end if

if phone_number_2_check contains "/" then

set phone_number_2_check to my replace_chars(phone_number_2_check, "/", "")

end if

if phone_number_2_check = my_phone_2_check then

set selection to item i of people

error "Die Nummer gibt es schon"

end if

end repeat

end if

end repeat

end tell

to replace_chars(this_text, search_string, replacement_string)

try

if this_text contains the search_string then

set AppleScript's text item delimiters to the search_string

set the item_list to every text item of this_text

set AppleScript's text item delimiters to the replacement_string

set this_text to the item_list as string

set AppleScript's text item delimiters to ""

end if

return this_text

on error msg

error "error on replace_chars" & return & msg

end try

end replace_chars

No Comments

ChronoSync: Nerven bis die Platte dran ist…

by hubi on 24/05/2011

ChronoSync scheint ein sehr schönes Backup-Programm zu sein, schafft es aber nicht nachzufragen, ob man nicht auch mal die passende Festplatte für das Backup anschließen möchte. Stattdessen schlägt das Backup direkt fehl und man muss die Platte anschließend mounten und das Backup von Hand wieder anstoßen. Laut Support kann man sich eine entsprechende Abfrage per AppleSkript selber einbauen... Elgato fährt meiner Erinnerung nach die selbe Schiene: "Wenn Ihnen dieses (zugegebenermaßen grundlegende) Feature so wichtig sein sollte, können sie diese Funktion gerne selber per Skript einbinden." So lautete vor einigen Jahren die Antwort auf die Frage ob die Software den Rechner nicht auch ein/ausschalten könne. Aber da möchte ich gar nicht so negativ über diese Haltung herziehen, schließlich ist AppleSkript ja dafür da, dem User die Möglichkeit zu geben, eine Sofware um praktische Funktionen zu erweitern. Und AppleSkript-Support ist für eine Anwendung unter 40$ ja auch nicht gerade selbstverständlich. Um so besser, wenn es auch dem Naturell des Benutzer entspricht, den Feinschliff der gekauften Software selbst zu übernehmen ;-P

-- 24.05.2011 hubionmac.com

-- can be added as as a pref-sync script to a  ChronoSync-Job to ask the user

-- to connect a missing source/destination volume if needed

--https://discussions.apple.com/thread/3075920


tell application "ChronoSync"

set mysource to leftTargetPath of document 1

set mydesti to rightTargetPath of document 1

if mysource starts with "/Volumes/" then

set mydelimiter to AppleScript's text item delimiters

set AppleScript's text item delimiters to "/"

set sourceName to text item 3 of mysource

set AppleScript's text item delimiters to mydelimiter

else

tell application "Finder" to set sourceName to name of startup disk

end if

if mydesti starts with "/Volumes/" then

set mydelimiter to AppleScript's text item delimiters

set AppleScript's text item delimiters to "/"

set destiName to text item 3 of mydesti

set AppleScript's text item delimiters to mydelimiter

else

tell application "Finder" to set destiName to name of startup disk

end if

tell application "Finder" to set drivenames to name of every disk

set cancelbackup to false

if sourceName is not in drivenames then

repeat until 1 = 0

set myaction to button returned of (display dialog "Source disk (" & sourceName & ") is not mountet!" buttons {"Check again!", "Cancel Backup"} default button 1 giving up after 30)

if myaction = "Check again!" then

tell application "Finder" to set drivenames to name of every disk

if sourceName is in drivenames then

exit repeat

end if

else

set cancelbackup to true

exit repeat

end if

end repeat

end if

if cancelbackup is false then

if destiName is not in drivenames then

repeat until 1 = 0

set myaction to button returned of (display dialog "Destination disk (" & destiName & ") is not mountet!" buttons {"Check again!", "Cancel Backup"} default button 1 giving up after 30)

if myaction = "Check again!" then

tell application "Finder" to set drivenames to name of every disk

if destiName is in drivenames then

exit repeat

end if

else

set cancelbackup to true

exit repeat

end if

end repeat

end if

end if

if cancelbackup is true then error "Canceling"

end tell

No Comments

DropBox: “Sicher” sichern

by hubi on 18/05/2011

Ich habe gerade eine rezitierte "News"-Meldung gelesen und muss jetzt mal ein Lanze für DropBox brechen. Viele fühlen sich hier anscheinend in Ihrer Angst bestätigt, dass Cloud-Dienste etwas schlechtes sind.. zu unsicher, unkontrollierbar und für die DAUs da draussen schlichtweg gefährlich. Da gibt es sicherlich gute Negativ-Beispiele aus der letzten Zeit, z.B. die PSN-Attacke, die über die Amazon-Cloud abgefeuert wurde. Nutzerdaten wurden gestohlen (vermutlich auch meine) und die Amazon-Cloud hatte sich partiell selbst ausgelöscht. So etwas zeigt, dass das Internet nicht unbedingt nur ein Kindergeburtstag ist und auch die großen mal was auf den Sack bekommen können, weil sie fernab der Marketing-Abteilung halt auch nur mit Wasser kochen (und das ist manchmal vielleicht eine trübe Brühe...). Auch DropBox ist da sicherlich kein gutes Beispiel für Datensicherheit und die Anpassung der Nutzungsbedingungen spricht bände, aber fernab davon ist es einfach ein geniales Konzept! Die Idee ist es wert, zumal DropBox nicht nur mein Leben so unsagbar erleichtert/bereichert hat. Diese Empörung, dass die Daten auf der Dropbox von dritten gelesen werden können, wenn man sich nicht selber um eine Verschlüsselung bemüht, ist so sinnlos und naiv. Ich denke ich muss hier nicht weiter schreiben, um meinen Standpunkt klarzumachen ;-) Hier noch der Link zum Blog-Eintrag zu dem Thema... Dass man extra einen Paket-Sniffer einsetzt, um festzustellen, dass weniger Traffic über die Leitung geht finde ich aber etwas überspitzt.

Also, für alle Mac-Schafe mit Internet da draussen, die weiterhin ungetrübt auf der weiten digitalen Flur ihre Gras-Platz-Kooridinaten sicher austauschen wollen:

DropBox Verschlüsselung leicht gemacht:

No Comments