As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
We're funding a new Acquisitions Incorporated series on Kickstarter right now! Check it out at https://www.kickstarter.com/projects/pennyarcade/acquisitions-incorporated-the-series-2

[Programming] Thread: Turning off the LAMP stack for mood lighting

11920222425100

Posts

  • SaerisSaeris Borb Enthusiast flapflapflapflapRegistered User regular
    I don't know if I agree with Go's particular design around exceptions, because I haven't used the language nearly enough to get a solid impression. It sounds really cool though, especially defer. And errors as a primitive type seems like a very, very good idea.

    But I do know I agree with their principle: errors and weird shit are a normal part of a program, and your code needs to deal with it as early as possible. Traditional try/catch exception handling doesn't do enough to encourage defensive programming.

    borb_sig.png
  • Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    edited May 2013
    I also like that you are never forced to catch a bunch of exceptions when you call library functions, both because panicking out of a library is discouraged, and also because recover is always optional. Defensive programming is great, but in Java it always seemed like you were constantly forced to wrap things in try/catch even when it made no sense at all (ex. catching IOExceptions when you were not really doing any IO). You can and should read and test the error values most library functions return with their results, but you don't HAVE to.

    Monkey Ball Warrior on
    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
  • Jimmy KingJimmy King Registered User regular
    I think my original question got lost in the fact that my office uses Cygwin so I figured I would repost. If you were left with a blank screen and no tasks, can anyone suggest a good way to learn shell scripting and using SQL? I'be been going through some online tutorials but they don't seem particularly robust and I was curious if anyone knew of a better way.

    I used to have a fairly decent o'reilly book on the bash shell and scripting. I suspect it's available online in some form or another. Shell scripting has always been more of a look up "how to do X" rather than "learn shell scripting" thing for me. The languages constructs are all simple enough, it's remembering the different shell commands that are available, and occasionally the really annoying and unintuitive syntax. Honestly, I'd say that's still your best bet. What do you want to do? Google that, or some smaller sub-process of that if your end goal is too broad. Eventually the patterns will stick with you. If you want a more in depth knowledge of programming in general, I'd consider using udacity or codecademy or coursera.

    I suspect coursera probably has some sql stuff as well. I don't really have any definite good resources for that, either. I got a job, there was a big ass database, there was Perl code with sql all over the place. I figured out how it works and honed my skills over the years by doing terrible things until I eventually figured out how to not be terrible. It's still far from a strength, I'm just not terrible.

    Ed Gruberman
  • templewulftemplewulf The Team Chump USARegistered User regular
    edited May 2013
    So, I have some PHP that is failing on another person's server but not mine. I'm running the latest Ubuntu LAMP, but I don't have their information.

    The bit that fails is (roughly) as follows:
                    //PDO automatically sanitizes data inserted into placeholders
                    //no need for old mysql_escape functions
                    $sql = 'SELECT SUM(datum) AS sum '
                            . 'FROM Data '
                            . 'WHERE color = :param;';
                    $statement = $this->db->prepare($sql);
                    $statement->execute(array(':param' => $param));
                    return $statement->fetch()['sum'] ?: 0;
    

    It's giving her a syntax error of "PHP Parse error: syntax error, unexpected '[' in /virtualhosts/testsite19/www/ColorVote-master/models/repository.php on line 37". Line 37 is the second comment line. I honestly have no idea what the problem could be, and I don't have access to her machine.

    Near as I can tell, she either has a corrupted version of the file, or her older version of PHP is choking on the subscript syntax and somehow reporting the wrong line number. Both of which sound dumb to me. Any better ideas?

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
    Kakodaimonos
  • Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    edited May 2013
    Wow... I was not aware how much PHP looks like Perl. I've never used PHP.

    Monkey Ball Warrior on
    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    edited May 2013
    PHP is a weird mishmash of perl, C and Java

    The readability of perl, the ease of use of C and the weirdness of Java all rolled into one

    Phyphor on
    iTunesIsEvilbowenThe AnonymousNightslyran_altamnesiasoft
  • EndEnd Registered User regular
    hm this code I just wrote not only took way less effort than I expected, but is now working suspiciously well...

    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpgsteam~tinythumb.png
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    It's a trap!

    EndMonkey Ball WarriorEvigilantEcho
  • bowenbowen How you doin'? Registered User regular
    templewulf wrote: »
    So, I have some PHP that is failing on another person's server but not mine. I'm running the latest Ubuntu LAMP, but I don't have their information.

    The bit that fails is (roughly) as follows:
                    //PDO automatically sanitizes data inserted into placeholders
                    //no need for old mysql_escape functions
                    $sql = 'SELECT SUM(datum) AS sum '
                            . 'FROM Data '
                            . 'WHERE color = :param;';
                    $statement = $this->db->prepare($sql);
                    $statement->execute(array(':param' => $param));
                    return $statement->fetch()['sum'] ?: 0;
    

    It's giving her a syntax error of "PHP Parse error: syntax error, unexpected '[' in /virtualhosts/testsite19/www/ColorVote-master/models/repository.php on line 37". Line 37 is the second comment line. I honestly have no idea what the problem could be, and I don't have access to her machine.

    Near as I can tell, she either has a corrupted version of the file, or her older version of PHP is choking on the subscript syntax and somehow reporting the wrong line number. Both of which sound dumb to me. Any better ideas?

    When it gives you the error of a comment line, 90% chance it's the code directly above the comments.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
    NightslyrEcho
  • Ed GrubermanEd Gruberman Registered User regular
    @Jimmy King - Thanks a lot. I'll definitely Look at those. A better book than the one I have on Shell scripting will be good at least. And Coursera certainly looks interesting and might help me better myself while I'm waiting for SOMEONE to retire so I can start my actual job.

    steam_sig.png

    SteamID: edgruberman GOG Galaxy: EdGruberman
  • DrunkMcDrunkMc Registered User regular
    I fucking hate IT Security. I'm forced to have McAfee on this new Linux Box I just got. Fine, I get it. However, EVERY SINGLE THING I DO cause a scan!!! So I goto IT and I tell them what its doing, they are like.......ummmmmmmmm, "I dunno". They force me to use this shit, but have no clue how to manage it. So I read the docs on McAfee on Linux and tell them the page number and section they need to read to edit the server to stop every fucking on access scan.

    Grrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

  • Ed GrubermanEd Gruberman Registered User regular
    edited May 2013
    One of my favourite experiences was while I worked at a University business school. I brought by boss's macbook down to the IT department and told them I needed the network key. The guy looked at me and said "We don't do Mac" and walked away. Fortunately, the guy right behind him had pity on me and directed my eyes to a small piece of paper on the wall that happened to have the network key. The first guy couldn't even be bothered to point to the damn wall.
    But enough complaining about IT. That could go on FOREVER

    Ed Gruberman on
    steam_sig.png

    SteamID: edgruberman GOG Galaxy: EdGruberman
  • iTunesIsEviliTunesIsEvil Cornfield? Cornfield.Registered User regular
    I like to rant about IT/SYSADMINS in the IT/SYSADMIN thread. They like the feedback. :wink:

  • urahonkyurahonky Registered User regular
    Awesome. Just lost all admin privs on my developer machine.

  • InfidelInfidel Heretic Registered User regular
    Hack the Gibson.

    OrokosPA.png
  • urahonkyurahonky Registered User regular
    And, to run Flash Builder, you need admin rights for some damn reason.

  • urahonkyurahonky Registered User regular
    Also had a guy on my team commit a broken build.

  • bowenbowen How you doin'? Registered User regular
    Thinking about rolling back to linux with virtualbox's seamless mode. Hm.

    Which distro though... ubuntu seems to have gone full retard last I knew with their new gnome layout.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • urahonkyurahonky Registered User regular
    It's simple... You break the build... I break your legs.

    The AnonymousIncindiumMonkey Ball Warrior
  • NightslyrNightslyr Registered User regular
    bowen wrote: »
    Thinking about rolling back to linux with virtualbox's seamless mode. Hm.

    Which distro though... ubuntu seems to have gone full retard last I knew with their new gnome layout.

    Mint. The ease of Ubuntu without Unity's bullshit.

    PSN/XBL/Nintendo/Origin/Steam: Nightslyr 3DS: 1607-1682-2948
    Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
    bowenurahonkymightyjongyo
  • bowenbowen How you doin'? Registered User regular
    Thanks Nightslyr. I'll give that a shot in a vm before I make the plunge.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
    Nightslyr
  • urahonkyurahonky Registered User regular
    Yeah Mint is built off Ubuntu so it's pretty grand.

  • iTunesIsEviliTunesIsEvil Cornfield? Cornfield.Registered User regular
    Arch+XFCE!

  • bowenbowen How you doin'? Registered User regular
    Pft, I don't want a 3rd job in managing my desktop OS and compiling from source.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
    mightyjongyo
  • iTunesIsEviliTunesIsEvil Cornfield? Cornfield.Registered User regular
    Hey, I didn't say Gentoo! C'mon now.

  • zeenyzeeny Registered User regular
    edited May 2013
    templewulf wrote: »
    So, I have some PHP that is failing on another person's server but not mine. I'm running the latest Ubuntu LAMP, but I don't have their information.

    The bit that fails is (roughly) as follows:
                    //PDO automatically sanitizes data inserted into placeholders
                    //no need for old mysql_escape functions
                    $sql = 'SELECT SUM(datum) AS sum '
                            . 'FROM Data '
                            . 'WHERE color = :param;';
                    $statement = $this->db->prepare($sql);
                    $statement->execute(array(':param' => $param));
                    return $statement->fetch()['sum'] ?: 0;
    

    It's giving her a syntax error of "PHP Parse error: syntax error, unexpected '[' in /virtualhosts/testsite19/www/ColorVote-master/models/repository.php on line 37". Line 37 is the second comment line. I honestly have no idea what the problem could be, and I don't have access to her machine.

    Near as I can tell, she either has a corrupted version of the file, or her older version of PHP is choking on the subscript syntax and somehow reporting the wrong line number. Both of which sound dumb to me. Any better ideas?

    PHP before 5.4 does not support array dereferencing. The error couldn't be more explicit.

    Edit: In case it wasn't obvious fetch()[] is causing the error.

    zeeny on
  • zeenyzeeny Registered User regular
    bowen wrote: »
    Thinking about rolling back to linux with virtualbox's seamless mode. Hm.

    Which distro though... ubuntu seems to have gone full retard last I knew with their new gnome layout.

    Ubuntu server install with ssh only, then do whatever you want on it.

  • bowenbowen How you doin'? Registered User regular
    zeeny wrote: »
    bowen wrote: »
    Thinking about rolling back to linux with virtualbox's seamless mode. Hm.

    Which distro though... ubuntu seems to have gone full retard last I knew with their new gnome layout.

    Ubuntu server install with ssh only, then do whatever you want on it.

    What do I look like, a VIM user?

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
    an_alt
  • zeenyzeeny Registered User regular
    bowen wrote: »
    zeeny wrote: »
    bowen wrote: »
    Thinking about rolling back to linux with virtualbox's seamless mode. Hm.

    Which distro though... ubuntu seems to have gone full retard last I knew with their new gnome layout.

    Ubuntu server install with ssh only, then do whatever you want on it.

    What do I look like, a VIM user?

    I didn't mean that you should stick with ssh, just install whatever window environment you want over the basic server install. You have pre-packaged *desktop packages if you are lazy, but if you aren't you may pick and choose what applications you want.

  • dobilaydobilay Registered User regular
    So I'm having a very interesting time dealing with holidays. The app that I'm working on doesn't let you pull information from before the oldest holiday in some internal database which is in 2011. Anyone know of any good external solutions for getting old holidays?

  • EndEnd Registered User regular
    edited May 2013
    You can install every desktop environment if you feel like it. There will be a thing you can click on to choose which one you want to use when you login.

    I still use ubuntu, but lately I've switched to xfce from mate because it runs better on my netbook. Since it seems pretty sufficient for my uses, now it's on my Linux dev VMs as well. Setting up the panels how I like took more effort than usual (and then adding a launcher after isn't very streamlined). Unity is still installed, but I don't touch it.

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpgsteam~tinythumb.png
  • urahonkyurahonky Registered User regular
    dobilay wrote: »
    So I'm having a very interesting time dealing with holidays. The app that I'm working on doesn't let you pull information from before the oldest holiday in some internal database which is in 2011. Anyone know of any good external solutions for getting old holidays?

    Can you provide any more information? What type of application? What type of database?

    9 times out of 10 if you type it out you'll figure it out right then and there. :)

  • zeenyzeeny Registered User regular
    I still run openbox + tint for window management at home/work and I doubt I'd change until some huge progress in UI or input devices.
    My development vm's(home and linode) are all just servers though, no window managers.

  • InfidelInfidel Heretic Registered User regular
    dobilay wrote: »
    So I'm having a very interesting time dealing with holidays. The app that I'm working on doesn't let you pull information from before the oldest holiday in some internal database which is in 2011. Anyone know of any good external solutions for getting old holidays?

    Grab the Outlook.hol file from an Office install and parse that?

    Depending on how far back you need the holidays you'll need older versions of Office.

    OrokosPA.png
  • dobilaydobilay Registered User regular
    There's a table somewhere that has an entry for every relevant holiday. There are only entries going back to 2011. The simplest solution is to just keep pulling holiday information from somewhere but that somewhere is what I'm trying to find in the first place; also that doesn't seem like the best solution long-term.

  • bowenbowen How you doin'? Registered User regular
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • bowenbowen How you doin'? Registered User regular
    <form method="POST" action="http://ray.met.fsu.edu/cgi-bin/calccal">
    <h3>Holiday Categories</h3>
    <input type=checkbox name="Civil" value="1" checked> Civil &nbsp;
    <input type=checkbox name="Christian" value="1"> Christian &nbsp;
    <input type=checkbox name="Hebrew" value="1"> Hebrew &nbsp;
    <input type=checkbox name="Miscellaneous" value="1"> Misc &nbsp;&nbsp;
    Gregorian Year:<input name="year" type=int value="2007" size=5>
    
    <h3>Output Calendar Type</h3>
    <input type=radio name="caltype" value="Gregorian" checked> Gregorian &nbsp;
    <input type=radio name="caltype" value="Hebrew"> Hebrew<br>
    <p>
    <input type=submit value="Gimme Dates">
    </form>
    

    You could probably do some posts against that page to brute force however far back you want to go.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
    Delmain
  • dobilaydobilay Registered User regular
    edited May 2013
    I forgot the best part: I need to be able to sort them into Canada and US holidays and some other categories which appear to be provincial holidays.

    AND it's all in Java :rotate:

    dobilay on
  • InfidelInfidel Heretic Registered User regular
    dobilay wrote: »
    I forgot the best part: I need to be able to sort them into Canada and US holidays and some other categories which appear to be provincial holidays.

    AND it's all in Java :rotate:

    Outlook.

    Stupid simple text format, broken down by country.

    OrokosPA.png
  • dobilaydobilay Registered User regular
    Infidel wrote: »
    dobilay wrote: »
    I forgot the best part: I need to be able to sort them into Canada and US holidays and some other categories which appear to be provincial holidays.

    AND it's all in Java :rotate:

    Outlook.

    Stupid simple text format, broken down by country.

    Thanks. That should help with the worst of it.

This discussion has been closed.