Snow
We went for a walk through the snow and some sledding today, here are the pics i shot ….
[album=7,compact]
We went for a walk through the snow and some sledding today, here are the pics i shot ….
[album=7,compact]
Farmvill can be a fun way to pass some time, but if your fields get to be a bit big clicking on every single field can get to be a bit tiresome. I found this autohotkey script in the depths of the internet. It simplifies the process greatly 😉
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
!^c::
GoSub GetFarmSq
GoSub Getfirstsq
i=1
SetMouseDelay, 0
cycle := farmy/2
newx=%startx%
newy=%starty%
loop, %cycle%
{
Click %newx%,%newy%
Loop, %farmx%
{
newx+=25
newy-=12
Click %newx%,%newy%
}
newx+=25
newy+=12
Click %newx%,%newy%
Loop, %farmx%
{
newx-=25
newy+=12
Click %newx%,%newy%
}
newx+=25
newy+=12
}
return
GoSub Getfirstsq
GetFarmsq:
Inputbox, farmy, Hi, Enter the number of fields to the right to click on,,200,150,,,,,6
if ErrorLevel
GoSub Esc
Inputbox, farmx, Hi, Enter the number of fields upwards to click on,,200,150,,,,,6
if ErrorLevel
GoSub Esc
farmx--
return
Getfirstsq:
Msgbox, Click on the leftmost field to start with ("9 O'clock" position).
KeyWait, LButton, D
KeyWait, LButton, D
MouseGetPos, startx, starty
return
Esc:
!^x::reload
Return
|
Sometimes it is useful to switch into the directory of the script e.g. when we need to call or include further files and don’t want to go through the hassle of searching for the script in the file system. Especially when symlinks are involved everything get a bit more interesting. This little snippet switches into the directory of the script, using readlink to dereference symlinks if the script is called via a symlink.
1
2
3
4
5
6
7
8
9
|
## a small snippet to switch into script directory
SCRIPTDIR=${0}
if [[ -L ${SCRIPTDIR} ]]
then
# dereference the symlink
SCRIPTDIR="$(readlink -e ${0})"
fi
# chop off the scriptname and switch into the directory
cd ${SCRIPTDIR%/*}
|
Today I ran into any old problem: you have a script that should do something when it recieves a signal (e.g. if someone sends it USR1 it should write to a log/syslog), but the script uses a long sleep because it normally only checks/calculates stuff every x min. If you send it a kill -USR1 $pid it will normally execute the trap AFTER the sleep is done, not so great. I figured of the following solution today: put the sleep in a while loop that checks if the full time was slept, and inside the loop a sleep that sleeps the X seconds remaing in the background followed by a wait.
If the script now recieves a USR1 it can kill the wait, execute the trap and will continue the remaining sleep on the next iteration of the loop.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#!/bin/bash
initialize() {
set -o nounset
trap cleanup INT TERM EXIT
trap print_foo USR1
}
cleanup() {
exit 0
}
print_foo() {
echo "foo"
}
initialize
# sleep 1 min
SLEEPTILL=$(date '+%s' --date="+1 min")
while [[ $(date '+%s') -lt ${SLEEPTILL} ]]
do
sleep $(bc <<< "${SLEEPTILL} - $(date '+%s')") &
BACKGROUND=$!
wait $BACKGROUND
done
|
I made some of my cookies this evening and used the opportunity to take some pictures. The lighting wasn’t perfect, so everything has a slight yellow tint. I decided to leave the pictures that way instead of trying to correct the problem in Photoshop.
[nggallery id=6]