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.
0
Monkey Ball WarriorA collection of mediocre hatsSeattle, WARegistered Userregular
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
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.
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?
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
@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.
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.
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
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.
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.
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?
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
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.
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.
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.
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.
Posts
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.
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.
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?
The readability of perl, the ease of use of C and the weirdness of Java all rolled into one
When it gives you the error of a comment line, 90% chance it's the code directly above the comments.
SteamID: edgruberman GOG Galaxy: EdGruberman
Grrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
But enough complaining about IT. That could go on FOREVER
SteamID: edgruberman GOG Galaxy: EdGruberman
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.
Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
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.
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.
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.
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.
My development vm's(home and linode) are all just servers though, no window managers.
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.
Best I could do.
You could probably do some posts against that page to brute force however far back you want to go.
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.