Skip navigation

Tag Archives: linux

I’ve been messing around a bit with C lately. So I have decided to make a little virtual pet type thing in it. I have no clue how to deal with a lot of things, such as, how in a text based ascii character drawn application, do you make it constantly receptive to input without being constantly demanding of input.

Secondly some more difficult aspects of my ascii animation, do I have to rwdraw everything every frame? Is it not possible to only redraw the actual moving part?

I am having a lot of fun though. So far of all the programming languages I tried (in this incredibly short space of time) I have had most fun with C. I think this is because it’s simple. Like, python was not so simple, it threw a whole load of concepts at me before I’d really grasped the basics. Because it had simpler syntax it seemed like I should be able to grasp more concepts at once, but concepts involve more cognitive load than syntax.

C had at first intimidating looking syntax, but its nice and regular and pedantic. So it quickly floated into the background.

I also think partly its because I really don’t understand this object oriented thing yet. C is not confusing me with object oriented stuff that I don’t understand (although I am told it can :p).

Anyway, even though its quite simple really, it is very satisfying to see my little ascii creature bobbing around the screen. All thanks to Linux without whom I never would have discovered the coolness of programming :p

I used to sleep at regular hours. I had a neat little schedule going. I ate 3 times a day and listened to my Russian language learning tapes every day.

Then I discovered Linux.

After discovering Linux, I used to sleep a normal amount, when I felt tired. I sometimes spent time with my family. I posted on my blog too often.

Then I discovered C.

I have discovered C, and I do not remember what this thing “sleep” is. I vaguely recall it, as for everything else, well lol.

But I am posting on my blog.

*dereferences null pointer*

*segfaults*

Being an impressionable young lady when people suggest to me that I learn python, well I give it a go.

I decided, what would be a fun way to go at this project? And I decided to make a text adventure game. Each chapter, I decided, would use a few new functions since the last, and so slowly but surely I would learn the functions and how to apply them in practical situations, and, I theorised, it would all happen in such a smooth progressive way that I’d hardly notice I was learning new things :p.

However, I also wanted each chapter to be a separate file so it would be simple to work on them one at a time. Which means that right at the outset I have to get the hang of this confusing “import” thing.
“Import isn’t confusing” I hear you say, well I suggest you google it, the very first page says:

The import and from-import statements are a constant cause of serious confusion for newcomers to Python.

So there, that proves it.

Anyway I just imported a module which does nothing but set a variable then print it, into a script that does nothing but print the same variable. The variable prints twice when I run it. Ok… I agree… its not that confusing… lol, at least not in that context.

But what I want to do is save all the variables that the person running the game inputs, basic things like character name, the items in their inventory and so on. I’ve got the hang of setting the variables. I’ve not quite got the hang of the syntax of actually printing stuff (I swear that two identical syntaxes are getting me alternate results!). I have the basic idea of this importing thing, but have yet to make it work in practice. I am faaaaar away from saving the variables…

But its fun eh? This is a fun way to spend a summer. Best summer I ever had I think, but to tell the truth I have very poor concept of past states of mind. I’m not saying I’m all zen and in the now, but just that everytime I am happy I feel like “this is the happiest I have ever been it will be like this forever” and everytime I am sad I feel like “this is the worst thing in the world, I will never again taste joy”. So even if I say “I never had more fun in my life” which is how I feel. I could be wrong.

And now to the “what the heck is wrong with my syntax mobile!” Mwahahahahaha!

- I can log on to my university central server (of course with severe limitations :p) from home using ssh.
- I can use irssi from there. I don’t know what the point of that would be, but its still pretty cool.
- My crappy drinking script works fine on their computer but I have not worked out how to export my filestore folder to PATH yet.
- I can see who else is logged in to central.aber.ac.uk too :D (don’t know em tho *yawn*).

It said at the beginning “blah blah only authorised users, if you don’t know that you’re authorised you aren’t” which kinda freaked me out. But I am sure I must be since my username and password work fine. So yay…

OOOH COOOL it tells me when I get emails too!
I’m gonna see what programs I can use now… apart from irssi… is it sad that I checked that first?

Edit: I just fingered a whole bunch of compsci students/staff two physics people (one a phd student one I guess was staff) several information services staff and a registration officer :p

I made a .plan file… I wonder if I can copy across my ,bashrc… (I just tried to close this blog client with :wq)

EDIT: wewt, indeed I can! And now my PATH variable is correct ;)
I bet I am the only humanities student to ever venture into this dark realm! I feel like a pioneer!

It’s very studenty…
If you wanna see the proper formating and not the weird wordpress formatting then feel free to ask and I can send you the file.

#!/bin/bash
# This is my second ever script. It is to decide whether or not to have a drink. It asks the
# user a series of questions to determine if it is safe for them to drink and if it is safe
# flips a coin to make a final choice.
clear
echo "Welcome to Should I Have a Drink 1.0"
echo

# first I will ask if the user is already drunk
echo "are you drunk?"
select choice in yes yesh no quit;
do
case $choice in
'yes')
echo "do you feel sick?"
select sick in yes no;
do
case $sick in
'yes')
echo "you are too drunk, do not have a drink!"
exit
;;
'no')
echo "are you an alcoholic?"
select alcoholic in yes no;
do
case $alcoholic in
'yes')
echo "go to an AA meeting!"
exit
;;
'no')
echo "flipping coin"
coin=$(( 1+(`od -An -N2 -i /dev/random` )%(10-0+1) ))
if [ "$coin" -gt "5" ]; then
echo "have a drink! ^_^"
exit
else
echo "don't have a drink"
exit
fi
;;
esac
done
;;
esac
done
;;
'yesh')
echo "Go to bed!"
exit
;;
'no')
echo "do you feel sick?"
select sick in yes no;
do
case $sick in
'no')
echo "flipping coin"
coin=$(( 1+(`od -An -N2 -i /dev/random` )%(10-0+1) ))
if [ "$coin" -gt "5" ]; then
echo "have a drink! ^_^"
exit
else
echo "don't have a drink"
exit
fi
;;
'yes')
echo "are you hungover?"
select hung in yes no;
do
case $hung in
'yes')
echo "are you an alcoholic?"
select alcoholic in yes no;
do
case $alcoholic in
'yes')
echo "go to an AA meeting!"
exit
;;
'no')
echo "hair of the dog: have a drink"
exit
;;
esac
done
;;
'no')
echo "curl up in bed and watch films, drinking will just make you sicker!"
exit
;;
esac
done
;;
esac
done
;;
'quit')
echo "Bye Bye"
exit
;;
esac
done
exit

# Uncommenting the following three lines will polyinstantiate
# /tmp, /var/tmp and user’s home directories. /tmp and /var/tmp will
# be polyinstantiated based on the MLS level part of the security context as well as user
# name, Polyinstantion will not be performed for user root and adm for directories
# /tmp and /var/tmp, whereas home directories will be polyinstantiated for all users.
# The user name and context is appended to the instance prefix.
#
# Note that instance directories do not have to reside inside the
# polyinstantiated directory. In the examples below, instances of /tmp
# will be created in /tmp-inst directory, where as instances of /var/tmp
# and users home directories will reside within the directories that
# are being polyinstantiated.
#
# Instance parent directories must exist for the polyinstantiation
# mechanism to work. By default, they should be created with the mode
# of 000. pam_namespace module will enforce this mode unless it
# is explicitly called with an argument to ignore the mode of the
# instance parent. System administrators should use this argument with
# caution, as it will reduce security and isolation achieved by
# polyinstantiation.

Polyinstantiate? *Googles*

…nope… I am none the wiser…

Follow

Get every new post delivered to your Inbox.