There is absolutely no latency difference in both. This is true across the popular RDBMS.
Actually 27 and counting. That was the first thing i noticed and I was like how stupid!!!
Was once looking for a method in Java’s Math class to convert a number to its negative equivalent. like 5 to -5, cant remember the use case though. But every time I remember I googled and saw an answer of “multiply by -1” on SO, I lol alone:joy:
Those are usually the best times. When you see a solution and wonder what you’ve been thinking.
Once, i used to convert to string, detect the minus, and remove it, or add the minus.
Then i figured out subtracting from zero would do the exact same thing.
I don’t think i ever used multiply by -1. Lol!
Split a file into chunks by loading it into memory, converting its bytes into base 64 string, and splitting the text at intervals.
When i tested for large video files, the program would crash every time.
Shying away from regex is really not such a “stupid” thing.
From a performance point of view, its actually advisable to “shy” away from regex as long as possible as most times its an overkill on what you want to do.
I saw someone at school here (Unilorin) who was using his email address as a database… On clicking submit on the
add form, it saves to his email address. Then you go to a url like
/item/10, it fetches stuffs from his email, get the body of the mail… Then display that…
Sounds like some genius stuff except it isn’t one
Seems pretty genius to me…
Lool… Classic. A mixture of genius and ignorance.
Funnily, this is actually the reason I shied away. I read something very similar in my earlier days of coding. And with that, and the fact that regex can be pretty scary at first, I kissed the damn thing goodbye and went off on my way to reinvent the wheel.
Imagine looping through a string of 500+ characters just to assert that it does or does not contain one or more characters. Or writing 20 if/then blocks just to validate one string. Just one string of characters. Or even doing something like:
if (startsWith("J") && endsWith("m") && contains("i") && !contains("y") && !contains("o") && !contains("h") && (length == 3 || length == 9)... ) // Note: startsWith(), endsWith() and contains() may not come easy // in real code
When you can knock the thing out with a few-character-regex-pattern.
I agree. There is no point using regex for things can easily be achieved using built-in string functions. And yes, there are performance concerns with regexs, but regex, as I’ve come to realize, is most certainly not as bad as it is sometimes projected to be.
From my experience, you always know instinctively when a good regex is the right screwdriver instead of a slew of
Re performance, for most use cases that have to deal with strings, you are probably optimizing prematurely (and inviting curses from future code maintainers) by rolling our your own pattern matching instead of using a pre-compiled regular expression object.
It’s like the difference between
n = n * 2 * 2
n = n << 2
Functionally they do the same thing, and at face value the bitwise operation looks faster but with the state of the art in compiler optimizations (as far back as the 90s i.e. pipelining, out-of-order processing, and more recently multi-core), the clock cycles to process the microcodes are practically equal.
Put simply, there are probably many other O(n!) and O(2n) code blocks in your code that you should be worried about than your regex.
About 8 or 9 years ago, I was writing an app in Vbasic to help manage my finances, despite the fact that I didn’t really have any back then. Anyway, I couldn’t figure out how to do the database connection and had very limited internet connectivity so couldn’t really Google it. I eventually ended up saving all the data into text files on disk. The application would read the values in multiple text files and update them as needed. It worked surprisingly well despite being a really dumb thing to do. Never really did use d app to manage any expenses though.
Did not understand the concept of global variables… so for every function i created that needed to talk to my DB, i rewrote the entire DB connection string…
Also wanted to submit a set of data from one form into two tables… So i created another form with hidden variables in the “action” page… The submit button in the action page… read “Are you really sure you want to submit this form ?”… the first submit was submitting to table 1 and second button was submit to table 2…lol
My brothers started loading Windows 98 around 9pm, can anyone remember it displays “Press Any Key To Continue …”, my brothers pressed all the keys on the keyboard severally and each time they do, it restarts the installation process again, until they came to wake me up at about 5 am, that the CD is not compatible with the Computer …
I once built a website using Microsoft publisher
why was it restarting the installation? Sorry I don’t understand this one
@hafiz i believe it’s because it shows press any key to load from cd… so everytime they press a key at that point… they restart the entire installation process even though its done already.
While in my 1st year, I tried to create a static site for the ICT department of my school… I created all pages as images using photoshop and then included it with img tags and anchor tags for navigation… Crazy
Nice. But they all go to upload anyway.