Static-X    Static-X.infopop.cc  Hop To Forum Categories  Open Discussion  Hop To Forums  Open Discussion    the geek thread
Page 1 3 4 5 6 7 8 9 11
Go
New
Find
Notify
Tools
Reply
  
  Login/Join 

Picture of Lorazepam
Posted Hide Post
Another neat Python trick that you may not know:

List notations are a quick and easy way to apply a transformation to every element in an iteratable data structure. Say that you wanted a list of numbers from 0 to 100 in a list. Instead of doing this:

a_list = []
for x in xrange(0, 101):
    a_list.append(x)


You can do this:

a_list = [x for x in xrange(0, 101)]


If you need to, you can apply more logic to the for loop as well:

# This will exclude 53 from the list.
a_list = [x for x in xrange(0, 101) if x != 53]


I used something like this not too long ago to figure out my passcode for my office door:

def passcode(last_name):
    last_name = last_name.lower()
    int_list = [ord(char) - ord('a') for char in last_name]
    return "".join([str(i) for i in int_list])[0:5]


This is one of my favorite Python shortcuts.


---

 
Posts: 658 | Registered: Tue February 12 2008Reply With QuoteEdit or Delete Message
Picture of hardkoretom
Posted Hide Post
How often do you guys put comments in your code? do you just comment functions or do you put in a ton of comments to describe whats going on in the function?


 
Posts: 3320 | Location: Anaheim, CA | Las Vegas, NV | Registered: Sat July 15 2006Reply With QuoteEdit or Delete Message

Picture of Lorazepam
Posted Hide Post
quote:
Originally posted by hardkoretom:
How often do you guys put comments in your code? do you just comment functions or do you put in a ton of comments to describe whats going on in the function?


I don't put comments inside functions unless the function is doing more than one thing (which, in principle, it shouldn't). Document what the function does before declaration. If you can't tell how a function actually performs the operation by looking at its source code, the author did something wrong.


---

 
Posts: 658 | Registered: Tue February 12 2008Reply With QuoteEdit or Delete Message
Picture of hardkoretom
Posted Hide Post
quote:
Originally posted by Lorazepam:
quote:
Originally posted by hardkoretom:
How often do you guys put comments in your code? do you just comment functions or do you put in a ton of comments to describe whats going on in the function?


I don't put comments inside functions unless the function is doing more than one thing (which, in principle, it shouldn't). Document what the function does before declaration. If you can't tell how a function actually performs the operation by looking at its source code, the author did something wrong.


its more like that spagetti arrangement. The part i dont like doing is having to search the different class files this guy wrote trying to find out what array is stored in a variable or what the referenced functions are doing. i'm looking at porting the program over to python from php and i want to start off with the most simple function, which he made linking vars and functions from like 4 class files.

i dont mean to keep complaining about the same program, but i am still trying to decide where to start.


 
Posts: 3320 | Location: Anaheim, CA | Las Vegas, NV | Registered: Sat July 15 2006Reply With QuoteEdit or Delete Message

Picture of Lorazepam
Posted Hide Post
In the spaghetti arrangement, it's always best to comment on what each logical block does.

PHP is such an awful language.


---

 
Posts: 658 | Registered: Tue February 12 2008Reply With QuoteEdit or Delete Message
Picture of hardkoretom
Posted Hide Post
so i'm setting up a lamp server on my laptop so i can use that as my testing environment. Ubuntu was more than easy to install and setup to be ok for what I need. Actually, they added an installer that boots up in windows that will alter the partitions install ubuntu and make it so you can use windows mbr instead of grub or lilo(dont know if anybody still uses lilo). Then i setup mysql which was a simple apt-get, and i did a make install of both apache 2.3 and php5 (only using php for phpmyadmin) and i am now having issues linking the php with the apache. but I think i am almost over that issue and will be moving on to setting up phpmyadmin and then installing anything else i need. python and django were easier to setup than the lovely php program and django worked after 5 minutes.


 
Posts: 3320 | Location: Anaheim, CA | Las Vegas, NV | Registered: Sat July 15 2006Reply With QuoteEdit or Delete Message

Picture of Lorazepam
Posted Hide Post
I never had trouble getting Apache+PHP to work, then again I've always used something pre-packaged, whether it's apt-get, macports or xampp

If there's a package for Apache+PHP I'd use that, you can always install mod_wsgi or mod_python later.


---

 
Posts: 658 | Registered: Tue February 12 2008Reply With QuoteEdit or Delete Message
the virtuous gizzard
Picture of Oblivion
Posted Hide Post
quote:
Originally posted by hardkoretom:
How often do you guys...


how many people do you think you're talking to ?


 
Posts: 1057 | Location: fuck yourself | Registered: Tue March 15 2005Reply With QuoteEdit or Delete Message

Picture of Lorazepam
Posted Hide Post
quote:
Originally posted by Oblivion:


get out


---

 
Posts: 658 | Registered: Tue February 12 2008Reply With QuoteEdit or Delete Message
Picture of hardkoretom
Posted Hide Post
quote:
Originally posted by Oblivion:
quote:
Originally posted by hardkoretom:
How often do you guys...


how many people do you think you're talking to ?


at least 2 people, neither of them being you.


 
Posts: 3320 | Location: Anaheim, CA | Las Vegas, NV | Registered: Sat July 15 2006Reply With QuoteEdit or Delete Message
the virtuous gizzard
Picture of Oblivion
Posted Hide Post
no need to get defensive, i really was curious

i'm not really a fan of one-click encoding but this program might be of use to some people, it can encode almost everything to almost everything




http://www.erightsoft.com/S6Kg1.html


 
Posts: 1057 | Location: fuck yourself | Registered: Tue March 15 2005Reply With QuoteEdit or Delete Message

Picture of Lorazepam
Posted Hide Post
i wouldn't use that just becaues the website is so fucking awful

use handbrake or mediacoder if you want programs that don't suck absolute shit

ps get out


---

 
Posts: 658 | Registered: Tue February 12 2008Reply With QuoteEdit or Delete Message
the virtuous gizzard
Picture of Oblivion
Posted Hide Post
the web site is not just awful, it's a silent hill labyrinth, i spend 10 mins trying to find the download link
handbrake is just a cheap encoding gui and mediacoder is just another half way between proper encoding and one click solution

super's simple but surprisingly good

ps jerry springer is on, mom's gonna say how your uncle harry's really


 
Posts: 1057 | Location: fuck yourself | Registered: Tue March 15 2005Reply With QuoteEdit or Delete Message
»Cµłť ǿƒ Ŝţāţić«
Picture of GhosthunterX
Posted Hide Post
Calm yourself Lorazepam -_-

P.S. I hate Jerry Springer


 
Posts: 59 | Location: Behind the Wall of Sleep | Registered: Tue December 16 2008Reply With QuoteEdit or Delete Message
Picture of hardkoretom
Posted Hide Post
How to watch videos in linux terminal window

http://www.howtogeek.com/howto...nux-terminal-window/


 
Posts: 3320 | Location: Anaheim, CA | Las Vegas, NV | Registered: Sat July 15 2006Reply With QuoteEdit or Delete Message
Picture of Rosco
Posted Hide Post
This is geeky shit....HardKore nerd.


myspace.com/angel1620
 
Posts: 89 | Location: Inland Empire | Registered: Mon March 26 2007Reply With QuoteEdit or Delete Message
Like salt to old wounds...
Picture of Kriss
Posted Hide Post
quote:
Originally posted by Rosco:
This is geeky shit....HardKore nerd.


Wow. Thanks for your deep insight.



__________________________



Kriss's DeviantArt
 
Posts: 3095 | Location: Dee! | Registered: Sat December 04 2004Reply With QuoteEdit or Delete Message
Picture of hardkoretom
Posted Hide Post
quote:
Originally posted by Rosco:
This is geeky shit....HardKore nerd.


And proud of it too. as soon as my vision insurance goes thru, i am going to be a 4 eyes as well, with nice black framed glasses.


 
Posts: 3320 | Location: Anaheim, CA | Las Vegas, NV | Registered: Sat July 15 2006Reply With QuoteEdit or Delete Message
Picture of Rosco
Posted Hide Post
ThanX for not getting all sensitive Brian, ya know I was just joshing you.


myspace.com/angel1620
 
Posts: 89 | Location: Inland Empire | Registered: Mon March 26 2007Reply With QuoteEdit or Delete Message

Picture of Lorazepam
Posted Hide Post
quote:
Originally posted by GhosthunterX:
Calm yourself Lorazepam -_-

P.S. I hate Jerry Springer


out


---

 
Posts: 658 | Registered: Tue February 12 2008Reply With QuoteEdit or Delete Message
  Powered by Eve Community Page 1 3 4 5 6 7 8 9 11 
 

Static-X    Static-X.infopop.cc  Hop To Forum Categories  Open Discussion  Hop To Forums  Open Discussion    the geek thread