Programming, computers, etc. [Serious]

All things asdf (and anything else)
User avatar
Dreams
ASDF High Priest
ASDF High Priest
Posts: 2306
Joined: Tue Nov 29, 2011 7:04 pm
Location: STOP STALKING ME! I'M INSECURE!
Contact:

Re: Programming, computers, etc. [Serious]

Post by Dreams » Tue May 01, 2012 5:00 pm

Now that's just contradictory :(

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Tue May 01, 2012 7:29 pm

I think it will get more people to try Linux out (though live CDs are pretty cool, too).
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Tue May 01, 2012 8:39 pm

I've been spending the good part of today on learning linux bash scripting, I'm writing a test tomorrow..
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Dreams
ASDF High Priest
ASDF High Priest
Posts: 2306
Joined: Tue Nov 29, 2011 7:04 pm
Location: STOP STALKING ME! I'M INSECURE!
Contact:

Re: Programming, computers, etc. [Serious]

Post by Dreams » Wed May 02, 2012 4:16 pm

Good. Don't destroy system files.

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Wed May 02, 2012 7:06 pm

Bash scripting can be really powerful.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Sun May 06, 2012 11:34 am

My flash sig seems to not work properly all of a sudden.. it stops between the last and the first image, i think. I'm just gonna change it to a simple image, i guess, I don't bother with bugs that come out of nowhere..
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Sun May 06, 2012 2:16 pm

Maybe an update to Flash?
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Thu May 10, 2012 10:06 pm

i'm writing a tough Assembly test tomorrow, wish me kind registers!

Code: Select all

mov bed,atomtengeralattjaro
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Fri May 11, 2012 2:29 pm

May your registers behave themselves.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Fri May 11, 2012 4:30 pm

and so they did :) Fortunately we had enough time, and I think I passed. Only for some reason when the program drew a triangle, it also drew a bunch of other lines in other places.. :S i guess i lost my way in the video memory somehow.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Fri May 11, 2012 7:41 pm

It's easy to get lost in assembly.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Fri May 18, 2012 9:11 pm

I feel bad double posting, but I found out something interesting today.

First, the known facts:
In Python, everything has a "truthiness" to it. That is, logically, everything is either True or False. If it's None, False, 0, 0.0, or the length of it is 0, it's considered to be False. Everything else is True (including functions and classes).

What I found out:
The logical "and" and "or" in Python don't always return True or False. They return one of the operands. "and" returns the first operand if it's "False-like" and the second one otherwise. "or" returns the first operand if it's "True-like" and the second one otherwise. Sure, you can "cast" it as a bool, but if you don't, it can lead to some interesting side effects.

Examples:

Code: Select all

5 and "Bob"
is "Bob"

Code: Select all

5 or "Bob"
is 5
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Fri May 18, 2012 9:48 pm

this truthiness thingy is spooky. Do you know any scenarios where this can be used? i think it would just confuse me, but it does seem interesting.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Sat May 19, 2012 2:07 am

Well, I don't know exactly when it would be used... It behaves exactly the way that you would expect it to in if statements and while loops. The truthiness thing exists in C/++, too. You can do "while(5){doStuffThatHopefullyEventuallyBreaksOutOfTheLoop();}". It only gets weird if you use it as a statement itself.

One possible use: Say you have 2 lists of Strings. The lists have the same length, just to make things simple. If an item in list1 is an empty string, you want to use the corresponding item from list2. There are several ways to do this. This is an unconventional one using "or":

Code: Select all

[i[0] or i[1] for i in zip(list1, list2)]
Here's one more like what you would expect:

Code: Select all

result = []
for i in range(len(list1)):
    if list1[i] != "":
        result.append(list1[i])
    else:
        result.append(list2[i])
Or, the same thing, as a list comprehension:

Code: Select all

[list1[i] if list1[i] != "" else list2[i] for i in range(len(list1))]
Still, it's just an oddity. If you want to force a boolean, you can use bool(a or b). It is a documented oddity. I just hadn't realized that it was there. Like I said, in most cases, it behaves as you would expect it to.

It also makes the implementation pretty easy, actually. For example:

Code: Select all

def customAnd(a,b):
    return a if not a else b

def customOr(a,b):
    return a if a else b
Voila! It all depends on the truthiness of a. In the implementation of the language, b isn't even evaluated unless it needs to be. I guess you could also use that side effect. For example:

Code: Select all

def printMe():
    print("Hello")
    return 0

def dontPrintMe():
    print("I should not print")
    return 1

printMe() and dontPrintMe() # This should only print "Hello"
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Sat May 19, 2012 10:01 am

woah..
i'm lost.
i have no idea about the whole syntax in your first example, and i don't even know what "zip" does :oops:
And the last one is just plain weird. But it makes sense. Took me a while to get it though..
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Sat May 19, 2012 1:29 pm

zip takes n lists and produces one list. That list contains tuples (which could be considered a special type of list) of n elements - one from each list. It's defined to stop at the end of the shortest list. so zip([1,2,3], [4,5,6]) would produce [(1,4), (2,5), (3,6)]. So in that look for strings example, it goes through each element in the zipped list, and does firstValue or secondValue. If firstValue seems False (i.e. It's the empty string), it uses the second value.

A modified first example (the C/++ code):

Code: Select all

if(5)
{
    cout<<"5 is considered to be \"True\" in C++";
}
In Python, "x if condition else y" is kind of their ternary (?) operator. If the condition is true, it results in x. If not, it results in y.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Sat May 19, 2012 4:46 pm

I see! I think it's clear now.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Fri Jun 01, 2012 10:26 pm

Speaking of Python...

I just learned of a site called Udacity today. It's kind of like an online school, with free online courses. It's not accredited, so you don't get a degree, but the instructors are university professors or professionals in their field. They're mostly programming classes, and the language used, as far as I can see, is Python 2.7 (though the theory learned is valuable regardless of the language). I may or may not have signed up today and enrolled in all of the classes. Simultaneously... Good thing there's no strict deadline! :)
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Sat Jun 02, 2012 1:05 pm

woah :o and it's free! as in free beer?
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Sat Jun 02, 2012 3:50 pm

It's free as in free online classes.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

Post Reply