Programming Confessions Thread
-
Can you get me server hardware reasonably priced? =D
-
Ha! I knew that would be one of the first questions. Honestly, what we cannot use ends up going to NFP's for inflated valuations that I get to write off. Most server hardware can be used though. We keep expanding out datacenter presence and despite occasionally getting servers for free, we still have to buy them.
Server hardware is cheap if you find the right deal on the used market. Keep an eye on eBay and have the cash ready to snatch up the right deal. A year ago I picked up a few M1000e's full of blades (M610's maxed on processor and RAM) for less than $5K/per, IIRC. That is WAY more than enough to start a good sized SaaS business.
Hell, you can pick up an R710 with 24GB of RAM for < $600 right now on eBay.
-
Yeah, I bought a dell poweredge 2950 and filled up the bays with 15k drives. It should do me good for the near future. I like to dream big though. I'm building my own mini data warehouse, up to 14.5tb possible storage for my personal business. Someday I'll be to big data size!
-
I'm building my own mini data warehouse, up to 14.5tb possible storage for my personal business.
Nevermind the PM I just sent you then.
-
It's not wrong, but at my size self hosting is much cheaper for the HA stuff since it's within arms distance all day every day. But mid size hosted solutions are very nice, enterprise is a toss up on your infrastructure.
-
If you ever have any questions, feel free to IM me. I am no guru, but if I can help you avoid some mistakes that I have made I would be happy to do so.
-
self hosting
I am redic sad that my new internet prevents me from hosting anything in my living room anymore :(
-
That's one of the reasons I still haven't gotten around to getting an interwebz since I moved. (That and money.) I really miss my old ISP.
-
How are you posting on here if you don't have access to the interwebs?
-
Work; it's currently lunch time. Sometimes the library or other public WiFi hotspot.
-
Confession: Switching to XML made my software easier to update. I'm so sorry.
-
XML is a generally good standard.
It's just abused by people who mistakenly believe it's always the best way of representing data.
-
Confession: Today I worked around a bug by adding the following (anonimized) SQL statement:
UPDATE table SET ID=ID WHERE 1=0
-
Confession: Today I worked around a bug by adding the following (anonimized) SQL statement:
UPDATE table SET ID=ID WHERE 1=0 ```</blockquote> .... okay, now i want to know what sort of bug you could be working around with that noop sql....
-
@PleegWat said:
Confession: Today I worked around a bug by adding the following (anonimized) SQL statement:
UPDATE table SET ID=ID WHERE 1=0 ```</blockquote> .... okay, now i want to know what sort of bug you could be working around with that noop sql....</blockquote> I've seen my share of weird SQL weirdness, but am failing to think of a situation where that would be required. Also, bonus bug when quoting code with a language hint
-
Also, bonus bug when quoting code with a language hint
it's discourse.... it's bugs all the way down....
-
I just spent a day converting a csv into an excel sheet....
Whoops hit wrong reply. Sorry!
-
-
I have been proof of Greenspun's 10th Law…
[spoiler]… and I did it in Lisp.[/spoiler]
-
@accalia said:
@PleegWat said:
Confession: Today I worked around a bug by adding the following (anonimized) SQL statement:
UPDATE table SET ID=ID WHERE 1=0 ```</blockquote> .... okay, now i want to know what sort of bug you could be working around with that noop sql....</blockquote> I've seen my share of weird SQL weirdness, but am failing to think of a situation where that would be required.</blockquote> That table (and most other configuration tables in our DB) have an out-of-transaction after-each-statement trigger to update a table holding a modification time. I'm updating the mod time again at the end of the transaction because we're running into cases where the modification time update is seen before the actual change. The current trigger was originally in-transaction, but that caused deadlocks. We've got a proper fix planned after the upcoming release but we're not sure what that needs to look like and what implications it will have so we needed a stopgap fix.
-
Confession averted****strong text: today, in an effort to minimize the scope of major changes to a report, I almost wound up writing to an alternate data stream. (For raisins, this program works by writing plain text to a file, then calling another program that reads in the file and also uses a ComponentOne ActiveX to print a form behind the file. The change involved the report going from always using the same single form layout to sometimes using a second one, and I needed a way to pass "which form goes with which page".
-
And I had actually taught Java to my classmates when I was studying higher diploma.
Oh, what have I done to my classmates...
-
You know what? Every web developers have done something like that.
The difference is just on two things: How many websites are of that quality, and whether he/she is still making sites of that quality.
-
anyone who is foolhardy enough to add a CSS rule for "left" can suck it.
But it is a rule on a
<br>
tag - how wrong can it get?Well, a
.left
class would (or at least could) change the rendering of a<br>
element if it contained rules forclear:left
orfloat:left
, for one thing...most other values for
clear
andfloat
, orposition:absolute
,position:fixed
,display:none
, some values offont-size
,font-size-adjust
,line-height
,margin
, ... did I miss anything? (probably)
-
O(nooooooooooooooooooooooooooo)
I know this is ancient, but I wanted to say, I both: almost fell out of my chair reading this laughing, and I am sooooo stealing this ;)
-
I've also seen
O(mg)
andO(hell no)
-
Stolen :yoinkSoundEffect:
-
Well, real (non-Perl-extended) regular expressions are O(n) where n is the length of the input stream. Anything that can be represented as an LR grammar is O(n^3) or better, and if it can't be represented by an LR grammar, you probably can't write it as a regular expression of any kind.
-
Well, real (non-Perl-extended) regular expressions are O(n) where n is the length of the input stream.
Once a regular expression is compiled, it should be O(n) to match; there's a bunch of reasons why that doesn't happen with most REs that people care about, but capturing groups and backreferences are some of the most problematic pieces. The process of converting a regular expression into a deterministic finite automaton (or even an NFA) can be a bit expensive itself.
RE engines are… non-trivial unless you restrict to an extremely simple subset.
-
Yeah, but you only have to compile the regular expression once, or at worst, once per program run.
-
Yeah, but you only have to compile the regular expression once, or at worst, once per program run.
Yes, but the cost of that might be extreme.
-
Confession: I wrote this.
# define morse (((((((0 # define di * 2) # define da * 2 + 1) /* pay no attention */ # define dit * 4 + 1) /* to the man behind */ # define dah * 4 + 3) /* the curtain */ # define _ * 2) # define ascii * 256 + static const uint16 morse_table[] = { morse dit _ _ _ _ _ _ ascii 'e', morse dah _ _ _ _ _ _ ascii 't', morse di dit _ _ _ _ _ ascii 'i', morse di dah _ _ _ _ _ ascii 'a', morse da dit _ _ _ _ _ ascii 'n', morse da dah _ _ _ _ _ ascii 'm', morse di di dit _ _ _ _ ascii 's', morse di di dah _ _ _ _ ascii 'u', morse di da dit _ _ _ _ ascii 'r', morse di da dah _ _ _ _ ascii 'w', morse da di dit _ _ _ _ ascii 'd', morse da di dah _ _ _ _ ascii 'k', morse da da dit _ _ _ _ ascii 'g', morse da da dah _ _ _ _ ascii 'o', morse di di di dit _ _ _ ascii 'h', morse di di di dah _ _ _ ascii 'v', morse di di da dit _ _ _ ascii 'f', morse di da di dit _ _ _ ascii 'l', morse di da da dit _ _ _ ascii 'p', morse di da da dah _ _ _ ascii 'j', morse da di di dit _ _ _ ascii 'b', morse da di di dah _ _ _ ascii 'x', morse da di da dit _ _ _ ascii 'c', morse da di da dah _ _ _ ascii 'y', morse da da di dit _ _ _ ascii 'z', morse da da di dah _ _ _ ascii 'q', morse di di di di dit _ _ ascii '5', morse di di di di dah _ _ ascii '4', morse di di di da dah _ _ ascii '3', morse di di da da dah _ _ ascii '2', morse di da di da dit _ _ ascii '\n', /* AR, end of message */ morse di da da da dah _ _ ascii '1', morse da di di di dit _ _ ascii '6', morse da di di di dah _ _ ascii '-', /* BT, pause */ morse da da di di dit _ _ ascii '7', morse da da da di dit _ _ ascii '8', morse da da da da dit _ _ ascii '9', morse da da da da dah _ _ ascii '0', morse da di di da dit _ _ ascii '/', morse di di di da di dah _ ascii '\f', /* SK, end of contact */ morse di di da da di dit _ ascii '?', morse di da di da di dah _ ascii '.', morse da da di di da dah _ ascii ',' };
-
Well, it's not worse than the rectangle literal thing someone posted a while ago. Or Boost::Spirit.
Except how on Earth does it even work? How do you do useful lookups on this table?
-
Dude, you even missed the uppercase letters...
<yes i know..
-
I encoded my name in hexadecimal and created a GUID for it. I now use that GUID instead of a randomly created GUID when a batch job creates something in my database.
-
how on Earth does it even work? How do you do useful lookups on this table?
Confession: like this.
# define WORDS_PER_MINUTE 5 /* slow code (eyes are slower than ears) */ # define DITS_PER_DAH 3 /* standard relative timings */ # define DITS_PER_SPACE 7 # define DITS_PER_WORD 50 # define TICKS_PER_SECOND 1048576 /* time base runs from external 4MHz clock / 4 */ # define SECONDS_PER_MINUTE 60 # define TICKS_PER_DIT ((TICKS_PER_SECOND * SECONDS_PER_MINUTE) / (DITS_PER_WORD * WORDS_PER_MINUTE)) # define TICKS_PER_DAH (DITS_PER_DAH * TICKS_PER_DIT) # define TICKS_PER_SPACE (DITS_PER_SPACE * TICKS_PER_DIT) uint32 ref_time; int ch; EPPC *eppc_p = EPPC_P; uint8 *keypad_p = (uint8 *) CPLD_ADDRESS_KEYPAD; eppc_p->pio_pddat = PDDAT_D15; /* set PD15 latch to 1 to turn UA LED off */ eppc_p->pio_pddir = PDDIR_DR15; /* set PD15 data direction register for Output */ ref_time = get_TBL(); if (message_p == NULL) message_p = "SOS"; --message_p; while ((ch = tolower(*++message_p)) != '\0') { if (ch == ' ') { ref_time += TICKS_PER_SPACE - TICKS_PER_DAH; /* generate a full space between words */ } else { const uint16 *morse_p = morse_table; uint32 count = NUM_ITEMS (morse_table); --morse_p; do { uint32 morse_code = *++morse_p; if ((char) morse_code == ch) { for (morse_code >>= 8; morse_code != 0x80; morse_code = (morse_code << 1) & 0xff) { feed_watchdog(); if ((*keypad_p & CPLD_FIELD_KEYPAD_ESC) == 0) return; wait_until (ref_time); eppc_p->pio_pddat = 0; /* turn UA LED on */ ref_time += (morse_code & 0x80) ? TICKS_PER_DAH : TICKS_PER_DIT; wait_until (ref_time); eppc_p->pio_pddat = PDDAT_D15; /* turn UA LED off */ ref_time += TICKS_PER_DIT; /* generate a dit space after each flash */ } ref_time += TICKS_PER_DAH - TICKS_PER_DIT; /* generate a dah space between characters */ break; } } while (--count); } }
This is what happens when you make an assembly language programmer use a C compiler. It's not pretty. But the generated code is tiny.
-
Morse code is not case sensitive.
-
View raw on my post ;)
-
This Horrible abomination lives in a production database...
CREATE FUNCTION [dbo].[IsValidPhone] ( @number AS NVARCHAR(80), @country AS NVARCHAR(80) ) RETURNS INT BEGIN DECLARE @cleaned AS NVARCHAR(80); SET @cleaned = REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(@number, '|', 'F'), '\', 'F'), '}', 'F'), '{', 'F'), '0','|'), '1','|'), '2','|'), '3','|'), '4','|'), '5','|'), '6','|'), '7','|'), '8','|'), '9','|'), '(','{'), ')','{'), '-','{'), '+','}'), ' ','|'), 'x','\') RETURN CASE WHEN @number IS NULL THEN 0 WHEN LEN(@number) < 1 THEN 0 WHEN LEN(@number) > 30 AND ISNULL(@country, 'USA') <> 'USA' THEN 2 WHEN LEN(@number) > 21 AND ISNULL(@country, 'USA') = 'USA' THEN 2 WHEN LEN(@number) < 7 THEN 4 WHEN @cleaned LIKE '%[^|{}\]%' THEN 8 WHEN @cleaned LIKE '%\%\%' THEN 16 WHEN @cleaned LIKE '_%}%' THEN 32 WHEN @cleaned LIKE '%\|||||||%' THEN 64 WHEN @cleaned LIKE '%\%[^|]%' THEN 128 ELSE 0 END END GO
I created it to run a report on the quality of our data in our CRM almost a year ago, i was supposed to delete it after the report was run as it's horribly inefficient, but i forgot to..... now several reports use it.... and are complaining about performance issues....
oh woe is me! for i am undone by my own hubris!
-
Mein Gott! I've seen some bad sql in my time but that is something else
-
Mein Gott! I've seen some bad sql in my time but that is something else
well..... it's really only three statements in that function....
that's somehting, right?
i mean it is something.....?
-
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(No
DECODE
?
-
I was thinking that, but that's only for entire strings.
-
.... EUGH! that's PL/SQL!
no!
do not want!
this is t-sql.... and if there's an equvalent to DECODE for tsql i havent found it. (but i would like to know about it if there is)
-
that's PL/SQL!
Huh?
that's only for entire strings.
Ah, yeah, goood point.
-
That's curious. It produces various powers of two, but never the value
1
…
-
but never the value 1…
I presume
1
is reserved forThe user entered the phone number in the exact format requested
, but said format wasn't being checked here.
-
@dkf said:
but never the value 1…
I presume
1
is reserved forThe user entered the phone number in the exact format requested
, but said format wasn't being checked here.actually the original version only returned 0 for valid or 1 for invalid. i retired 1 when i made it give a reason.
as for why powers of two instead of counting up (it's not a flag field) .... i dunno, maybe i was feeling humorous?
-
-
When I was a couple years into my professional career I was assigned to the development of a project for a company that was doing research on animal genetic engineering. It was an intranet site that was basically all record keeping stuff. They had paper worksheets to fill out for every step of their process, with references to previous steps and all that, and you were supposed to be able to follow the chain from beginning to end. This project had been ongoing for several years. It was in pretty bad shape, but actively used by the company.
The problem was the process would regularly change so the previous relationships between types of records were not valid going forward. In order to "fix" the problem of not being able to pull up old records due to FK violations, I wrote scripts to move data around. Looking back that was probably a bad thing to do as it probably screwed the integrity of the records in the system, since the records didn't necessarily reflect what had taken place. I think this was especially bad because all this stuff had to be maintained for like FDA review. I was sole developer and didn't know enough to see the problem at the time. I've never run into this situation again, but I often think about it and wonder what the right design would have been for that system where the data model regularly changes.
I was on that for a year and a half or so before that company finally bailed on my company and hired someone else to deal with it.
Various wtf's that I'm remembering:
- VB.Net 1.1 project
- The original developer wanted something like .net 2's master pages and it ended up that every page was a user control loaded onto a common page. It was a disaster, everything was a postback and handling user actions was a mess.
- I was the 4th(?) developer to be responsible for this
- project manager was incompetent. she was let go I believe after the time period expired that would have allowed her to sue for wrongful termination resulting from sleeping with the boss. also she is very likely the worst driver I have ever ridden with. was honestly scared.
- there was a "spec" that was two binders full of absolutely nothing useful
- our contact at the company communicated stream-of-consciousness style. She literally wrote emails saying one thing followed by "I mean" then a second thing, instead of erasing the first incorrect thing.
- changes to db records had to be tracked. This was done in the same table by writing the deleted record back into the table with a parent id after the update happened.