Programming Confessions Thread
-
@magus said in Programming Confessions Thread:
@ben_lubar Just define a new enemy type based on a Pern crossover.
This may just be post 500.
Flagged for Jeffing.
-
@tsaukpaetra Also, 502 OK?
-
Making post 503 unavailable.
-
504 Post response timeout.
Edit: whoops
-
U-505 Submarine
-
U235 (90%, weapons-grade)
Filed Under: One of these things in not like the others
-
NECRO!
matchRequest = i.key().second.replace(QRegularExpression(R"r(\[(\*):(\w+)\](\??))r"), ".+") .replace(QRegularExpression(R"r(\[(i|s):(\w+)\]\?)r"), "([^/]+)?") .replace(QRegularExpression(R"r(\[(i|s):(\w+)\])r"), "[^/]+") .replace(QRegularExpression(R"r(([^/])$)r"), "\\1/?");
My C++ looks like fucking Perl. Whether that makes it better or worse it up to you.
And to save you the headache of trying to actually figure out what in the holy fuck this is doing: it's converting stuff like
/extensions/[s:extension]/redirect/[s:state]?
into
/extensions/[^/]+/redirect/([^/]+)?/?
Basically, converting a human-readable route definition into a regex I can run against the actual HTTP request I got so I know if it matches and I should go and try parsing the parameters.
-
@Onyx said in Programming Confessions Thread:
My C++ looks like fucking Perl.
You done fucked up for real!
-
@Onyx said in Programming Confessions Thread:
My C++ looks like fucking Perl.
I don't want to see the offspring of that unholy union!
-
Ok, ok, I fixed it, jeez:
QStringList routeParts = i.key().second.split('/', QString::SkipEmptyParts); QStringList newRouteParts; for(QString part : routeParts) { if(routeParameterMatch.match(part).hasMatch()) { part = part.remove('[').remove(']'); if(part.split(':').at(0) == "*") { newRouteParts << "(?<any__" + part.split(':').at(1) + ">.*)"; } else if(part.split(':').at(1).right(1) == "?") { newRouteParts << "?(?<" + part.split(':').at(0) + "__" + part.split(':')[1].remove('?') + "__optional>[^/]+)?"; } else { newRouteParts << "(?<" + part.split(':').at(0) + "__" + part.split(':').at(1) + ">[^/]+)"; } } else { newRouteParts << part; } } QRegularExpression testRouteComponents("/" + newRouteParts.join('/'));
There! Now it transforms
/extensions/[s:extension]/redirect/[s:state]
into
/extensions/(?<s__extension>[^/]+)/redirect/(?<s__state__optional>[^/]+)?)
Which means I have named groups (in form of
datatype__varname(__optional)?
) that I can just run the URL request through and get all the things at once!... send help?
Filed under: I probably just could have done a string concat instead of
join
ing a list, but eh, fuck it, easier to debug like this, That's my excuse at least!, Fuck this shit, I'm on vacation next week, it can wait!
-
@Onyx you are absolved, but only if you precompile your colon.
-
@ScholRLEA said in Programming Confessions Thread:
Sorry, I guess you missed an earlier post of mine; I was referring to SalesForce.com Apex, a proprietary language which is superficially like Java but is in actuality a hobbled, mangled example of vendor lock-in at its worst. It runs solely as a cloud-based extension of SalesForce, and is 'optimized' (if that is the right word) for working with the bizarre structure of that particular CRM. It is mostly used for server-side 'controllers' operating on an HTML derived markup language called VisualForce, which shares with Apex some of the worst excesses of proprietary design since IBM in its heyday. SFDC manage to make Microsoft and Oracle look good, despite the fact that they don't have anywhere the influence those two do.
I normally don't mind proprietary systems per se, but this one is littered with bad design decisions which were clearly made for the sole purpose of making the customers entirely dependent on their services.
It wouldn't be half as bad if the documentation was up to snuff, but in yet another business-driven decision, they deliberately made the docs hard to follow without having going through their specific indoctrination about terminology and methodology. They turn generally accepted terms on their heads in ways even Steve Ballmer would consider unethical, they are deliberately inconsistent in the names and descriptions of parts of their system, and the only way to make sense out of it all is to hire a team of 'experts' from them to act as native guides. Given the lack of skill some of these consultants show, I think I'd rather be lost.
Filed Under: Don't hold back, Schol, tell them how you really feel...
I confess that I have to deal with these ass fucks and their shit system on a daily basis...mostly Salesforce Marketing Cloud which used to be Exact Target which SF bought and munged it into their shitty ecosystem of other products they bought. I've dealt with everything you've stated. They have also consciously removed any form error handling from their tools that would allow an actual programmer to figure out anything on their own when something goes wrong all in an effort to force you to contact their shit support...which BTW if you don't have premium support, good luck getting them to fix a bug in their code...been dealing with that over the past 2 or 3 weeks now. They broke a core function of their server side javascript framework...which is as terrible as it sounds, but it's better than their AMPScript garbage...I ended up having to determine what exactly they broke and no one there even cares. So what they broke was their HTTPPost function...it will no longer send your data payload if you use a ContentType other than "text/html"...
-
-
@ben_lubar Prevents any escaping being done at all. Like
'
or"""
in other languages.
-
/* snip */ } else if($type == 'email') { if(preg_match('/.+@.+\..+/', $val)) { // Close enough for government business $val = (string)$val; } else { $val = null; } } /* snip */
If I have to burn in hell, so be it, it's close enough for the shit this will have to handle. Anything outside of that would probably explode the minds of people using it.
-
@Onyx That's generally all you should be checking anyway. Addresses without
@
or without.
can be valid, but for internet-facing applications they won't be. And beyond that it's better to send a confirmation email.
-
@PleegWat said in Programming Confessions Thread:
@Onyx That's generally all you should be checking anyway. Addresses without
@
or without.
can be valid, but for internet-facing applications they won't be. And beyond that it's better to send a confirmation email.You don't even need to send a confirmation email. Just connecting to the remote SMTP server and asking whether you can attempt to send an email to the address is enough to weed out most typos.
-
@ben_lubar said in Programming Confessions Thread:
Just connecting to the remote SMTP server and asking whether you can attempt to send an email to the address is enough to weed out most typos.
It may work for the domain part, but doesn't necessarily work for the mailbox part, as the public SMTP server may not be the system holding the mailboxes and can't decide that part; it's totally legitimate for the server to forward everything on to another internal system after applying checks for technical legitimacy. (That's how our email is done at work.)
-
@dkf People are pretty used to email verification anyway, and even without extra forwarding on the receiving host side the typo'd address may well exist. Still would be user-friendly to apply @ben_lubar's test and print a message immediately if the email send fails, rather than making the user wait whether or not it will ever arrive.
-
for (int i = 0, j = (ptr = data[4]) % 20, k = (j << 1) + 5, q = err.Length; i < err.Length; j = ((++i) + ptr) % 20, k = (j << 1) + 5) err[--q] = BitBender.PackUInt16(data, k);
Filed under: NURSE! My coat's coming untied at the back!
-
@PleegWat said in Programming Confessions Thread:
Still would be user-friendly to apply @ben_lubar's test
The reduced version of the test is to just to do a DNS lookup and see if there is an A or MX record (and not something derp-y set by your ISP). Without at least one of those, you really aren't going to deliver…
-
@Applied-Mediocrity said in Programming Confessions Thread:
for (int i = 0, j = (ptr = data[4]) % 20, k = (j << 1) + 5, q = err.Length; i < err.Length; j = ((++i) + ptr) % 20, k = (j << 1) + 5) err[--q] = BitBender.PackUInt16(data, k);
Code Review: E_FAIL
Reason: Fuck you, I ain't maintaining that shit.
-
@ben_lubar said in Programming Confessions Thread:
@PleegWat said in Programming Confessions Thread:
@Onyx That's generally all you should be checking anyway. Addresses without
@
or without.
can be valid, but for internet-facing applications they won't be. And beyond that it's better to send a confirmation email.You don't even need to send a confirmation email. Just connecting to the remote SMTP server and asking whether you can attempt to send an email to the address is enough to weed out most typos.
You need to send a confirmation email to make sure that it's their email address, though. You should be doing that anyway.
-
@anotherusername said in Programming Confessions Thread:
@ben_lubar said in Programming Confessions Thread:
@PleegWat said in Programming Confessions Thread:
@Onyx That's generally all you should be checking anyway. Addresses without
@
or without.
can be valid, but for internet-facing applications they won't be. And beyond that it's better to send a confirmation email.You don't even need to send a confirmation email. Just connecting to the remote SMTP server and asking whether you can attempt to send an email to the address is enough to weed out most typos.
You need to send a confirmation email to make sure that it's their email address, though. You should be doing that anyway.
Yes, but you don't need to send the email to validate it before they submit the form, and requesting to send an email can make your validation more accurate.
-
@ben_lubar said in Programming Confessions Thread:
validate it before they submit the form
You probably shouldn't do that sort of validation while the user is still typing into the field. At least wait until they focus out…
-
I finally got around to learning and using streams in Java.
-
@boomzilla said in Programming Confessions Thread:
I finally got around to learning and using streams in Java.
Finally boarded that boat, eh?
-
@Tsaukpaetra is that what the kids are calling it these days.
-
@boomzilla said in Programming Confessions Thread:
@Tsaukpaetra is that what the kids are calling it these days.
Sometimes it's better to be in the boat when it's rocking, but often enough others are content to watch it float on by...
-
@Tsaukpaetra
Float float float your boat down the Java DoubleStream...
-
@Applied-Mediocrity ... Merrily merrilz merrily merrilz you fucked up the precision and were subjected to IEEE rounding rule arcana.
-
Customer request: create a list of all phones connected to the system, with the extension number, IP address, user agent (effectively, model of the phone in 99.99999% of the cases, close enough anyway) caller ID (every phone has been set to show the user's first and last name in caller ID) and its MAC address (which is in a file but only because we put it there for automatic provisioning purposes).
- I can get everything but the user agent and IP address just from config files
- I can get everything but the user agent just from config files and Asterisk CLI commands
- I can get everything (most importantly, this is the only way to get the user agent) but the list of all extensions and the MAC address using dialplan functions
So, here's the idiotic hybrid of running the "script" from the dialplan, which also has to call Asterisk's command line and poke through a file and then parse shit using
awk
to get to the MAC address:// Can't get the list of all valid endpoints from the dialplan, so we have to use an Asterisk CLI command // List of hints is the easies to parse, so we'll use that Set(extensions=${SHELL(asterisk -rx "core show hints" | grep phone-context | cut -d '@' -f1)}); // Create a file Set(fileName=/home/asterisk/inventory_${STRFTIME(${EPOCH},,%Y-%m-%d_%H-%M-%S)}.csv); // Write headers Set(FILE(${fileName},,,l,u)="Extension";"Device";"Caller ID";"IP Address";"MAC"); // While there are extensions in the list while(${LEN(${extensions})} > 0) { // Get next line from hint output Set(extension=${SHIFT(extensions,\n)}); // Get the user agent using Asterisk dialplan functions Set(userAgent=${PJSIP_CONTACT(${PJSIP_AOR(${extension},contact)},user_agent)}); // Get the ip address using Asterisk dialplan functions Set(ipAddress=${PJSIP_CONTACT(${PJSIP_AOR(${extension},contact)},via_addr)}); // Get the caller ID using Asterisk dialplan functions Set(callerID=${PJSIP_ENDPOINT(${extension},callerid)}); // Grab provisioning MAC addresses from Asterisk's mutant INI config file Set(mac=${SHELL(awk -F'\\s*=\\s*' -v k='phoneprov/MAC' ' $0 ~ /^\[${extension}\]/{ f=1; next } /\[/{ f=0; next } f && $1==k{ print $2 }' /etc/asterisk/pjsip_wizard.conf )}); // Write the info to the file Set(FILE(${fileName},,,al,u)="${extension}";"${userAgent}";"${callerID}";"${ipAddress}";"${mac}"); } Hangup();
Cthulhu have mercy on my soul...
-
@Onyx said in Programming Confessions Thread:
Cthulhu have mercy on my soul...
If it were going to have mercy, you wouldn't be working with Asterisk.
-
I just spent 15 minutes looking for a solution for how to eliminate empty lines from the beginning and end of a text file that I'm creating by piping the value of a string variable to Out-File.
-
Just came across this in some old code of mine:
catch (Exception e) { // TODO: we need to take care of this EVENTUALLY
EDIT: Not yet.
-
You are a very wise man
Definition of eventually : at an unspecified later time
-
Confession: I have a long and successful career architecting and implementing solutions on a platform owned by a company that I have grown to disdain. I don’t want to have anything to do with the company or its products anymore but my resume is founded on this set of software and platforms. I feel trapped by my past success.
On the other hand, my current employer doesn’t actually require much of this skill and hopefully I can start fresh again and this won’t be an issue the next time I go looking for work.
Edit: For the sake of clarity, I actually really like my current employer and the job I do for them. The product is one I like and while working on it, I touch the Devil’s seed blessedly little these days. It’s more the thought of what I’m going to do N years from now that’s a bit daunting.
-
@WhatYouSay John McAfee, is that you?
-
@WhatYouSay said in Programming Confessions Thread:
I have a long and successful career architecting and implementing solutions on a platform owned by a company that I have grown to disdain.
The "why-the-i-hate-oracle-club: thread is
-
@anotherusername said in Programming Confessions Thread:
@WhatYouSay John McAfee, is that you?
What was that? I can’t hear you under this mountain of Brazilian women and cash.
-
@WhatYouSay if I were you, I'd move to another currency.
-
@Gąska said in Programming Confessions Thread:
@WhatYouSay if I were you, I'd move to another currency.
Is the bottom dropping out of Brazilian women?
-
@WhatYouSay depends on how rough you're doing it.
-
@WhatYouSay said in Programming Confessions Thread:
Is the bottom dropping out of Brazilian women?
These butt implants are going too far
-
@WhatYouSay said in Programming Confessions Thread:
I touch the Devil’s seed blessedly little these days
-
I would guess that if it were based on that alone the answer would probably be no.
-
@Polygeekery said in Programming Confessions Thread:
I would guess that if it were based on that alone the answer would probably be no.
The last one I looked for would probably indicate that I sometimes have problems getting relative URLs right in Markdown. (The real issue was the browser not using part of the URL that I expected to be there in preview, which won't be a problem once this stuff gets deployed.)
-
@Polygeekery said in Programming Confessions Thread:
I would guess that if it were based on that alone the answer would probably be no.
-
Last problem I've googled for was for college work. How to use a function returning a cursor in PL/SQL.
Last problem I've googled for at work was to find out whether Scala has this very cool feature I've seen in other languages that would really help me at the moment. Of course, I found out it doesn't. Every fucking time.
-
@Polygeekery said in Programming Confessions Thread:
I would guess that if it were based on that alone the answer would probably be no.
Does "how to interview for a dev job" count?
EDIT: Though the last thing I did google was: Why does VSTS dacpac build but not create a new table?
The results were less than helpful.