User:Yoana Buzova/ prototyping: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
 
(17 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''MY browser''' / mmths + yoana
'''MY open hours''' / mmths + yoana
 
 
[[File:MYopenhours.png|600 px]]
 
 
[[File:Closed-sign.jpg]]
 




Line 7: Line 14:
   
   


<source lang=bash>
#!/bin/bash


[[File:Closed.png]]]]


while true; do


if pgrep Safari || pgrep firefox || pgrep Chrome  &>/dev/null; then
----------------------------------
echo alive
sleep 4
pkill Safari
pkill firefox
pkill Chrome
/usr/bin/osascript <<-EOF


     tell application "System Events"
An application that applies working times for your browser.
        activate
the user can choose from four different version (inspiration from the NS railways korting system)
        display dialog "We are closed!"buttons{"Sorry"}
 
    end tell
 
Cyberslacker - Browsing is available during the week from 09:00-17:00.
 
Night surfer - Your browser is open on weekdays from 18:30-04:00.
 
Dal Voordeel (Off-peak surfing) – Your browser is not available in weekdays between the peak hours of 06:30-09:00 and 16:00-18:30.
 
Weekend Vrij (Weekend free browsing) – Your browser is available only at the weekend, from Friday 18:30 to Monday 04:00.
 
 
== script MYnightsurfer==
<source lang="python">
import subprocess, re, os, datetime, time
from datetime import date
 
while True:
    now = datetime.datetime.now()
    today = date.today()
    daytoday = date.isoweekday(today)
    hour = now.hour
    isWorkingTime = [18, 19, 20, 21, 22, 23, 0, 1 ,2 , 3, 4]
    isWorkday = daytoday < 5
    print "."
 
    if hour in isWorkingTime and isWorkday:
        print "open"
 
    else:
        # BASH: ps aux
        # to get list of all processes
        proc = subprocess.Popen(['ps aux'], stdout=subprocess.PIPE, shell=True)
        (out, err) = proc.communicate()
        killed = False
        for line in out.splitlines():
            line = line.lower()
            if 'firefox' in line or 'safari' in line or 'chrom' in line:
                parts = re.split(r"\s*", line)
                pid = parts[1]
                print pid
                os.system("kill "+pid)
                killed = True
 
        if killed:
            os.system("/usr/bin/osascript < feedback.applescript")
 
     time.sleep(5)
</source>
 
<source lang="applescript">
tell application "System Events"
                activate
                display dialog "Sorry! We are closed!
 
Opening hours
 
Monday:-----18:00 - 04:00
Tueasday:---18:00 - 04:00
Wednesday:--18:00 - 04:00
Thursday:---18:00 - 04:00
Friday:-----18:00 - 04:00
Saturday:---closed
Sunday:-----closed
 
                "buttons {"OK"}
            end tell


EOF
else
echo DEAD!!!
fi
done
 
</source>
</source>




[[File:Closed.png]]]]
==app==
[http://pzwart3.wdka.hro.nl/mediawiki/images/d/dc/MY.zip MY.zip]
 
[http://pzwart3.wdka.hro.nl/~ybuzova/MYopenhours/MYopenhours.zip MYopenhours.zip]

Latest revision as of 18:24, 30 June 2013

MY open hours / mmths + yoana


MYopenhours.png


Closed-sign.jpg




Closed.png]]



An application that applies working times for your browser. the user can choose from four different version (inspiration from the NS railways korting system)


Cyberslacker - Browsing is available during the week from 09:00-17:00.

Night surfer - Your browser is open on weekdays from 18:30-04:00.

Dal Voordeel (Off-peak surfing) – Your browser is not available in weekdays between the peak hours of 06:30-09:00 and 16:00-18:30.

Weekend Vrij (Weekend free browsing) – Your browser is available only at the weekend, from Friday 18:30 to Monday 04:00.


script MYnightsurfer

import subprocess, re, os, datetime, time
from datetime import date

while True:
    now = datetime.datetime.now()
    today = date.today()
    daytoday = date.isoweekday(today)
    hour = now.hour
    isWorkingTime = [18, 19, 20, 21, 22, 23, 0, 1 ,2 , 3, 4]
    isWorkday = daytoday < 5
    print "."

    if hour in isWorkingTime and isWorkday:
        print "open"

    else:
        # BASH: ps aux
        # to get list of all processes 
        proc = subprocess.Popen(['ps aux'], stdout=subprocess.PIPE, shell=True)
        (out, err) = proc.communicate()
        killed = False
        for line in out.splitlines():
            line = line.lower()
            if 'firefox' in line or 'safari' in line or 'chrom' in line:
                parts = re.split(r"\s*", line)
                pid = parts[1]
                print pid
                os.system("kill "+pid)
                killed = True

        if killed:
            os.system("/usr/bin/osascript < feedback.applescript")

    time.sleep(5)
tell application "System Events"
                activate
                display dialog "Sorry! We are closed!

Opening hours 

Monday:-----18:00 - 04:00
Tueasday:---18:00 - 04:00
Wednesday:--18:00 - 04:00
Thursday:---18:00 - 04:00
Friday:-----18:00 - 04:00
Saturday:---closed
Sunday:-----closed

                "'  buttons {"OK"}
            end tell


app

MY.zip

MYopenhours.zip