User:Tsalumet: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 93: | Line 93: | ||
fi | fi | ||
done | done | ||
</source> | |||
'''PYTHON ARVESTUS''' | |||
<source lang="python"> | |||
#!/usr/bin/python | |||
# -*- encoding: utf-8 -*- | |||
#krüpteerimis algoritm, mis nihutab 10 tähemärki edasi | |||
import sys, os | |||
try: | |||
sisendfail, v2ljundfail = sys.argv[1:3] | |||
except: | |||
print "Kasutamine: krypto.py <sisendfail> <väljundfail>" | |||
exit() | |||
fout = open(v2ljundfail, "w") | |||
a = ord("a") | |||
z = ord("z") +1 | |||
A = ord("A") | |||
Z = ord("Z") +1 | |||
for l in open(sisendfail).readlines(): | |||
l2 = [] | |||
for c in l.strip(): | |||
n = ord(c) | |||
if n in range(a, z): | |||
l2.append(chr((n + 10 - a) % (z - a) + a)) | |||
elif n in range(A, Z): | |||
l2.append(chr((n + 10 - A) % (Z - A) + A)) | |||
else: | |||
l2.append(" ") | |||
fout.write("".join(l2)) | |||
</source> |
Revision as of 16:54, 6 June 2011
QUEST 27:
#!/bin/bash
#Taavi Salumets A21
#Versioon 0.1
# CD ROM seade
CDROM=/dev/cdrom
# NB! Väljund file, seda tuleb muuta vastavalt enda süsteemile
OF=/home/student/cdimage.iso
BLOCKSIZE=2048
# Võib kasutada suuremat kiirust, kui seda toetab
SPEED=2
echo; echo "Sisesta data CD, millest tahad pilditõmmist teha"
echo "Vajuta ENTER kui valmis"
# Oodatakse sisestust
read ready
echo; echo "Kopeerin data CD asukohta $OF."
echo "See võib natuke aega võtta, palun ole kannatlik"
# Kopeerimine
dd if=$CDROM of=$OF bs=$BLOCKSIZE
#Lisame imagele MD5 räsi
md5sum $OF
echo; echo "Eemalda data CD."
echo "Sisesta tühi CDR."
echo "Vajuta ENTER kui valmis "
# Oodatakse sisestust
read ready
echo "Kopeerin $OF tühjale CDR."
cdrecord -v -isosize speed=$SPEED dev=0,0 $OF
echo; echo "Kopeerimine $OF tühjale CDR seadmelt $CDROM on valmis"
echo "Kas soovid image kõvakettalt kustutada (y/n)? "
read answer
case "$answer" in
[yY]) rm -f $OF
echo "$OF kustutatud."
;;
*) echo "$OF ei kustutatud";;
esac
exit 0
QUEST 31:
#!/bin/bash
#Skript, mis 2ratab unise tudengi
#Versioon 0.1
stty intr undef &&
alarm="null"
until [ $alarm = "olenylevaljavalmis" ]
do
mplayer /home/student/alarm.wav && mplayer /home/student/alarm.wav
clear
echo "Nyyd on sinu v6imalus t6estada, et oled yleval"
echo
echo "Kirjelda enda hetke olukorda ja vajuta ENTER"
read -t 15 alarm &&
if [ $alarm != "olenylevaljavalmis" ]
then echo "Vale!! Proovi uuesti"
else echo "Kena 2ra enam magama j22!!"
fi
done
PYTHON ARVESTUS
#!/usr/bin/python
# -*- encoding: utf-8 -*-
#krüpteerimis algoritm, mis nihutab 10 tähemärki edasi
import sys, os
try:
sisendfail, v2ljundfail = sys.argv[1:3]
except:
print "Kasutamine: krypto.py <sisendfail> <väljundfail>"
exit()
fout = open(v2ljundfail, "w")
a = ord("a")
z = ord("z") +1
A = ord("A")
Z = ord("Z") +1
for l in open(sisendfail).readlines():
l2 = []
for c in l.strip():
n = ord(c)
if n in range(a, z):
l2.append(chr((n + 10 - a) % (z - a) + a))
elif n in range(A, Z):
l2.append(chr((n + 10 - A) % (Z - A) + A))
else:
l2.append(" ")
fout.write("".join(l2))