This forum is in permanent archive mode. Our new active community can be found here.

Weekend coding

17810121339

Comments

  • edited December 2011
    Yeah, that isn't what's causing the problem.
    As you've noted, your method is modifying the list that gets passed into it - this can happen because lists are mutable. The solution is basically to modify a duplicated input list rather than the original list.

    The problem occurs in two spots - where you do set += [set[-1] + 1] and where you do set[-1] += 1

    The first one could be fixed by changing it to set = set + [set[-1] + 1] and if I understand your code correctly, that would ensure that a new list is made since set would get the new value of either [1] or set + [set[-1] + 1] and hence would always be a different list from the one that's being passed in by the time it gets to the while loop, with the original list never being modified.

    Alternatively you could start off your method with set = list(set) or set = set[:] in order to create a duplicate rather than modifying the original list.
    Post edited by lackofcheese on
  • I have a choice between LibTorrent, which is updated constantly but written in C++ (Which I don't know.) and MonoTorrent, which is written in C# but hasn't been updated in a while.

    I want to build the prototype of a program that allows for embedding Bittorent videos and files in-line inside the browser.

    Should I use the outdated library or look into shifting my learning to objective C++?
  • I think I get it. So what's happening is that rather than pass the value of set, my code is passing a reference to the list itself, right?
  • So I just finished teaching myself CGI/Perl/Template Toolkit so I can modify Koha at work for our change management library. Perl may be the duct tape of the internet but..... FUCK Perl. and Fuck Koha too. Striaght in the goat ass.
  • So I just finished teaching myself CGI/Perl/Template Toolkit so I can modify Koha at work for our change management library. Perl may be the duct tape of the internet but..... FUCK Perl. and Fuck Koha too. Striaght in the goat ass.
    Much like duct tape, Perl is inelegant and ugly, but if often gets the job done quickly when nothing else will... At least that was back in the day. Nowadays, I'm not as sure, but I do keep a copy of the camel book handy as I do come across a lot of Perl from time to time.
  • Today I hacked together a script that reads all the exif data in all the jpg files in a single folder and spits a nicely formatted page of html to display handily in a blog post/forum post/email/static web page. There may be tools to do this already, but I couldn't find one that could read all the information that is included in Lightroom-exported jpg's. In the end I used a fail-safe system that should pick up on most of the exif data in most jpg files using the imported functions, and then falls back on my own jpg exif data parser (sooo clunky) to grab what else I need.

    The next step is to work out where the GPS location data is stored (this is embedded by a non-Lightroom, non-canon application) and then make a link for every photo that opens google maps with a pin it it where I took the photo.

    This is going to save me sooo much time in the future when writing blog posts, and hopefully bring some fun new functionality too.

  • Much like duct tape, Perl is inelegant and ugly, but if often gets the job done quickly when nothing else will... At least that was back in the day. Nowadays, I'm not as sure, but I do keep a copy of the camel book handy as I do come across a lot of Perl from time to time.
    The fact that I have to re-write some java classes in Perl is pissing me off.
  • The fact that I have to re-write some java classes in Perl is pissing me off.
    And rightfully so! Except for maybe shell scripts, I can't think of any legitimate excuse to rewrite anything in Perl. Even then, there are better options.
  • dsfdsf
    edited January 2012
    it's one of those CGI/Perl web apps. The original java I wrote was because someone had asked to parse x file into y format. Now I need to incorporate that parser into the web app. Another one of those, "I was a victim of my own success" deals.

    I will get my revenge.
    Post edited by dsf on
  • My AI project is to create a Flood It solver using Constraint Satisfaction. I have a working game/interface and can now construct a proper graph coloring where all contiguous tiles of the same color are a single node.
    image
  • Three color Flood-It is for babies.
  • Flood-It with c >= 3 colors is NP-Hard for any nxn board.
  • Flood-It with c >= 3 colors is NP-Hard for any nxn board.
    I know. That's why you gotta go for it.
  • I keep getting an error with the last line of this saying ./stayup.sh: 17: Syntax error: "done" unexpected (expecting "then")which makes me thing I've not closed something off somewhere.

    #! /bin/sh
    CHECKINGPERIOD=60
    while [1=1];
    do
    if [ ! "$(pidof Tribes2.exe)" ] # Comes back true if Tribes2.exe isn't running.
    then
    pkill wineconsole
    find /home/tribes2/Tribes2/GameData/base -name \*.dso -execdir /bin/rm {} \+
    cd /home/tribes2/Tribes2/GameData
    wineconsole --backend=curses Tribes2.exe -dedicated &
    else
    curl http://master.tribesnext.com/add/28000
    fi
    then
    sleep $CHECKINGPERIOD

    done
  • Why is there a then before the sleep?
  • That isn't there any more. I added it in to see if fi needed a then.
  • That isn't there any more. I added it in to see if fi needed a then.
    Uh, no. fi is endif in bash.

    Also, it looks like what you are trying to do is create a script that will restart tribes if it is no running. A bash script is a stupid and broken way to do this. The correct way is to use supervisord.
  • Scott, I'm saying this as a friend but you should try harder not to insult people while trying to teach them things. We get you have problems but we really believe in you.

    I'll have a look at supervisord, though, sounds good.
  • edited March 2012
    Good to see you're really working those interpersonal skills, Scott. Insulting while imparting knowledge is counterproductive for this sort of thing.
    Post edited by Churba on
  • Also, if you insult people when trying to convince them of something they will resist you during arguments rather than being won over to your points.
  • I'm sorry, but when did he insult someone? All he said was that the idea was stupid.
  • edited March 2012
    I'm sorry, but when did he insult someone? All he said was that the idea was stupid.
    I have to apologize. I didn't realize he was a bash script.
    Post edited by Apreche on
  • It's not a big deal, we can encourage him but it's going to take time.
  • If you were seriously insulted by his statement, you should get outside more.
  • It's not a big deal, like I said. I get worried that Scott's going to be out in the world one day and someone isn't going to take well to the way he acts towards others.
  • It's not a big deal, like I said. I get worried that Scott's going to be out in the world one day and someone isn't going to take well to the way he acts towards others.
    29 years, and doing fine. I think I'll ignore your "advice."

    Let me give you some advice in return for you to ignore. If someone tries to help you, don't randomly turn on a drama factory. Imagine you are sitting in a computer lab. Someone asks you for help. You see they are doing something a bad way, so you tell them the right way. They respond by saying "thou hast insulted me!" You're pretty much never going to want to talk to, let alone help, that person ever again.

    In the time you spent here, you could have had supervisord running already.
  • I am honestly confused.
  • Jesus christ, sometimes I think you people are actually just incapable of seeing things from someone else's point of view.

    Scott: I know you didn't mean it to be intended in this way, but there's an inference in what you said. It's
    A bash script is a stupid and broken way to do this. [And you are stupid for thinking that]
    If you can't see that, whatever, but it's there, and it's implied. Sometimes it pays off to be a touch careful about what people may infer from you saying something, even if you didn't mean it at all in that way.

    Omnutia: Scott is a logic robot. What he says is precicely what he means; no more. A Bash script is a stupid way of doing that, but don't infer anything else from that statement. No one thinks you're stupid.

  • Jesus christ, sometimes I think you people are actually just incapable of seeing things from someone else's point of view.

    Scott: I know you didn't mean it to be intended in this way, but there's an inference in what you said. It's A bash script is a stupid and broken way to do this. [And you are stupid for thinking that]
    If you can't see that, whatever, but it's there, and it's implied. Sometimes it pays off to be a touch careful about what people may infer from you saying something, even if you didn't mean it at all in that way.

    Omnutia: Scott is a logic robot. What he says is precicely what he means; no more. A Bash script is a stupid way of doing that, but don't infer anything else from that statement. No one thinks you're stupid.

    I am insulted! Screw you Farragar! You may not realize it, but your statements implied that you claim to have had any manner of lurid sexual relations with all of my family members simultaneously.
  • edited March 2012
    Jesus christ, sometimes I think you people are actually just incapable of seeing things from someone else's point of view.

    Scott: I know you didn't mean it to be intended in this way, but there's an inference in what you said. It's A bash script is a stupid and broken way to do this. [And you are stupid for thinking that]
    If you can't see that, whatever, but it's there, and it's implied. Sometimes it pays off to be a touch careful about what people may infer from you saying something, even if you didn't mean it at all in that way.

    Omnutia: Scott is a logic robot. What he says is precicely what he means; no more. A Bash script is a stupid way of doing that, but don't infer anything else from that statement. No one thinks you're stupid.

    I am insulted! Screw you Farragar! You may not realize it, but your statements implied that you claim to have had any manner of lurid sexual relations with all of my family members simultaneously. Yeah, gonna have to go with Scott here. It's not a big deal, just don't get mad at the Internet. You'd know if Scott were trolling, and would then recognize that he's trying to make you mad. He's pretty obviously trying to help here, he just uses the direct language he uses. If you don't like it, hate to break it to you, but there's no Internet HR.

    Post edited by ProfPangloss on
Sign In or Register to comment.