Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "string map"
-
A couple of months back I got an interview for a junior android devel position. I do not consider myself a junior devel, bt fuck it they paid 78k a year plus benefits and this is for south texas where it ain't thaaat expensive. So i kept my mouth shut and went with it.
The company was glorious, one of those hipsert marketing companies with cool couches and shit and people doing fuckign whatever all over the place and cool tools and desks.
So the initial interview with the hr dept went amazing, real cool guys and very down to earth. Next was the senior android dev.
This dude.
It was to be a phone interview, with a lil coding test. Fine whatevs. But the moment he called i knew shit was going down hill. Dude sounded dead af. Like he could not stand being himself that day. Asked asshole questions that every developer in Android should know that were frankly quite insulting ("what company develops the Android os" kind of deal) but kept my mouth shut and answered as needed.
Then the coding portion. Given a string, find the first position of the first repeated char, so if I had , fuck i dunno "tetas" then t was the first (and only) char repeated and it should have given out 2.
Legit finished it up in less than 6 mins and only because he was making me explain my entire thought process.
He got angry for some reason. Mind you I speak like a hippie, with a melow town and calm voice all the damned time, got that Texas swag going on as well as any good ol' boy from Texas should right?
Well this dude was not having none of that shit that day.
Dude was all like "ok now....why exactly did you do it this way?"
With a VERY condescending tone. And i explained that at first I normally think about solutions in pseudocode, so I wrote that as well...1 min or less. In python. This is after I still had the Java solution on screen with perfectly clean and working Java. I saif that since Python was as close to pseudocode as it gets that I figured i would just write the "pseudocode" in python and then map it to Java with all the required modifications.
"Welk i did not ask you to write it in java, so i dunno why you would even do that to begin with"
That is one of many asshole remarks. The first when I mentioned that I found React Native good for prototyping complex ideas for FUCKING FUN. Passion motherfucker. Shit so fly I do it for fun. "We don't deal with that here so I am not interested in what you can do with that or how would it help me"
Mofocka plz.
Well going back to the python shit. I explain (calmly) that it was just a way that I had to figure details, to think of different implementations. He continues by saying that it takes valuable company time.
Then he proceeds to tell me that he believes that i cheated since i fi ished the java "problem" too fast.
I told him that simple stuff like that should take even less for any senior java dev and that we could run another example if he wanted.
Bring it puto.
But no.
He then said that he still did not understand the need for Python in my solution. I lost it.
"Look man, getting real tired of your tone, i explained already, it is just a mental process, i do this when comming up with solutions, thinking in theory, not languages, helps me bridge the gap between problem and implementation, the solution works, it is efficient and fast and i can do it in 5 diff ways if you wanted, i offered and you said no. Don't really know what else you want"
"All i am saying, i am not going to hire you if you are going to be writing Python for Android, that is useless to me"
Lost it more.
I do sound different when pissed. So I basically told him that he asked for my reasoning behind and it was given, that not getting it was a you problem.
Sooooo did not get the job. Was relieved really. Can't imagine having a twat like that as a lead devel.19 -
Why in the name of Donald Knuth did you think it was a good idea to have a 1500 line Java Method? What THE HELL WERE YOU SMOKING THE ENTIRE FILE IS OVER 3000 LINES AND HALF OF THEM ARE COMMENTED OUT!
Don't even get me started on your "unit tests" which is a massive 5000 line behemoth that randomly has massive swaths of code commented out.
And of course no solution like this would be complete with you HARD CODING EVERY F****INIG STRING IN EVERY TIME!
And it's not like you don't know how to use classes as you have several of them, every single one of which is over 500+ lines and consists of only getters and setters. LET ME INTRODUCE YOU TO A MAP! REALLY WHY WOULD YOU USE 500 LINES FOR A CLASS THAT IS JUST GETTERS AND SETTERS?!
The part that really burns me about all of this though, isn't the fact that you sent it to me when I was running into a similar issue, and said "check this out it should help", what bothers me most isn't the indescribable rage I felt looking at your code, the part that really really really bothers me is that you are a veteran with over 15 years in Java development, and according to the org chart are a lead senior engineer getting paid substantially more than me, whereas I am considered a lowly mid-level developer, who isn't worth promoting to your level.
On the plus side you are now going to be featured on theDailyWTF so congrats on the notoriety.8 -
A dev team has been spending the past couple of weeks working on a 'generic rule engine' to validate a marketing process. The “Buy 5, get 10% off” kind of promotions.
The UI has all the great bits, drop-downs, various data lookups, etc etc..
What the dev is storing the database is the actual string representation FieldA=“Buy 5, get 10% off” that is “built” from the UI.
Might be OK, but now they want to apply that string to an actual order. Extract ‘5’, the word ‘Buy’ to apply to the purchase quantity rule, ‘10%’ and the word ‘off’ to subtract from the total.
Dev asked me:
Dev: “How can I use reflection to parse the string and determine what are integers, decimals, and percents?”
Me: “That sounds complicated. Why would you do that?”
Dev: “It’s only a string. Parsing it was easy. First we need to know how to extract numbers and be able to compare them.”
Me: “I’ve seen the data structures, wouldn’t it be easier to serialize the objects to JSON and store the string in the database? When you deserialize, you won’t have to parse or do any kind of reflection. You should try to keep the rule behavior as simple as possible. Developing your own tokenizer that relies on reflection and hoping the UI doesn’t change isn’t going to be reliable.”
Dev: “Tokens!...yea…tokens…that’s what we want. I’ll come up with a tokenizing algorithm that can utilize recursion and reflection to extract all the comparable data structures.”
Me: “Wow…uh…no, don’t do that. The UI already has to map the data, just make it easy on yourself and serialize that object. It’s like one line of code to serialize and deserialize.”
Dev: “I don’t know…sounds like magic. Using tokens seems like the more straightforward O-O approach. Thanks anyway.”
I probably getting too old to keep up with these kids, I have no idea what the frack he was talking about. Not sure if they are too smart or I’m too stupid/lazy. Either way, I keeping my name as far away from that project as possible.4 -
Unreal Engine adventures:
me: So ok, I need a map from int to String
Unreal: ya but it's called TMap, FCompactPoseBoneIndex and FName.
me: ..uhhh ok whatever
...
me: ok for debugging, please print this
Unreal: FName is not a string
me: k. Fname.toString().
Unreal: ya but it aint a TChar array now
...
IT'S A FKING STRING JUST PRINT IT. And the other guy is still an int with extra steps! Come the fuck on now....
I mean, honestly, a logging function that cannot print a fking FString? sigh...
Man, I miss python and blender...8 -
Sometimes human stupidity still surprises me.
Today I was able to stop the release of a ticket at the last moment that intended to put urls WITH A SECURITY TOKEN TO ACCESS USER DATA through a link shortener.
Some PM assumed that it would be a reasonable course of action to map an url secured via jwt through to a 4 character, countable, base64 string so that we don't have to send multiple sms if they contain this url. I can accept that the implications might slip through one person but the fact that this was put into a ticket by a pm, prioritized by PO, estimated by an entire team, implemented by a professional developer, reviewed by a senior and then scheduled for release without anyone asking themselves if there might be a reason for a security token to be long, that one shocks me.8 -
!rant
the most popular ecommerce solution in php is a massive (cosmological scale) pile of corporate crap (magento) and the next most popular is an abomination (opencart)
after fucking around with both for a month (the client asked for the project to be using only one of the two) I'm still barely reaching any results, and most of my time is wasted with the stupid bloated spaghetti that is opencart FUCK THIS,
like seriously. who the fuck writes a single line three left joins sql querry with four or five aliases a couple concacts and a bunch sorting fuckeries just to query the categories list, then just query the details of the specific category from a different function,
also why the fuck map each language string manually. or the fucking hardcoded seo urls, or the use of myisam for all tables, and no fucking foreign keys, let that settle for a minute, no foreign keys, the delete method in the model has at least a twenty lines, and then he came with the genius idea of duplicating models, in the front and the backend, accessing the same data, as the same user, but different naming conventions
I'm going to convince him to use something sane like codeigniter/laravel/fuelphp or I'll deny the project8 -
I read the pragmatic programmer a few months ago. The book advised learning a different programming language every month or so. I was doing Advent of Code so I decided to try out Elm because functional programming is all the rage these days.
It took me one hour to convert a string of numbers to an array of numbers! And when I finally finished with that I couldn't understand how to compare each element with the next one in an array using map or filter.
I realised that I've become too comfortable using javascript. Worst case scenario: In a few years when javascript is obsolete I'll be like those old dudes that know only Cobol. Best case scenario: I'll always be too dumb to earn a nice salary.
On a positive note: The first time I tried Elm I didn't understand jack shit, now I understood a few things.5 -
An anti-rant: I just made some code and out of nowhere it suddenly had an awesome feature that I didn't even program. No, not a euphemism for "bug", an actual feature.
Here's the story: A few months ago I made a shortcut for "System.out.println(…)" called "print(…)". Then I developed it further to also print arrays as "[1,2,3]", lists as "{1,2,3}", work with nested arrays and lists and accept multiple arguments.
Today I wanted to expand the list printing feature, which previously only worked for ArrayLists, to all types of List. That caused a few problems, but eventually I got it to work. Then I also wanted to expand it to all instances of Collection. As a first step, I replaced the two references to "List" with "Collection" and magically, no error message. So I tested it with this code:
HashMap<Integer, String> map = new HashMap<>();
map.put(1, "1");
map.put(2, "");
map.put(3, "a");
print(map);
And magic happened! The output was:
{1=1, 2=, 3=a}
That's awesome! I didn't even think yet about how I wanted to display key-value pairs, but Java already gave me the perfect solution. Now the next puzzle is where the space after the comma comes from, because I didn't program that in either.
I feel a bit like a character in "The subtle knife", who writes a barebones program to communicate with sentient elementary particles (believe me, it makes sense in context) and suddenly there's text alignment on the left and right, without that character having programmed any alignment.4 -
Data representation is one of the most important things in any kind of app you develop. The most common, classic way to do it is to create a class with all the fields you want to transport, for example User(name, lastName). It's simple and explicit, but hell no, in my current company we don't play that kindergarten bullshit, the only way we know how to do things here is full hardcore. Why would anyone write a class to represent a Song, a Playlist or an Album when you can just use a key-> value map for pretty much everything? Need a list of songs? No problem, use a List<Map<String, String>>, OBVIOUSLY each map is a song. Need a list of playlists? Use a List<List<Map<String, String>>>... Oh wait, need to treat a value as a number and all you have are strings? That's what casting is for, dumbass.
No, seriously, this company is great. I'm staying here forever!1 -
Converting javascript/ typescript Map to json
or python date to json
or anything complicated to json is mostly ending with implementing serialization patterns
With date it’s so annoying cause we have iso standards that every language implemented or have libraries
so typescript doesn’t recognize Map<string, string> so you have to convert it to array and then to object
with python you need to make your own serializer / deserializer
So much waste of power usage that if only Greta know it she would say ‘how dare you!’
It can stop global warming.5 -
a lot of dev have a miss concept about Unicode/utf8 including me but I believe my understanding get Better and this my last version.
For a project i was developing a rest api for mobile app
when an ios dev asked me
"I send you Unicode string but it appears as ????? in admin web panel "
OMG!!!😨😨😨
Unicode is not an encoding nor an algorithm. it's a standerd which just map a glyph to a codepiont .
but utf8 is the encoding of Unicode and how it's stored or transferred ,
the string you send must be a utf-8 encoded string as the rest of the json you sent . -
It reaaaally annoys me when my business logic is sound but the data is corrupted.
For example, find duplicates in a HashMap<String>.. but I didn't take into account the input could contain a space either before or after.. so I end up wondering: if a HashMap only contains unique keys, how come the count of items in the map is the same as the count of the input keys?! Well.. spaces were the culprit.
"12345" != "12345 ".. and therefore the Map sees it as two distinct keys..
What an annoying bug.
Lesson learned: 1) Sanitize input first and never trust it. 2) Never make assumptions16 -
Change my mind. Golang can be more difficult than it needs to be sometimes:
Find the first "non-null" value in an array:
Go:
Optional<String> result = Stream.<Supplier<String>> of(
() -> first(),
() -> second(),
() -> third() )
.map( x -> x.get() )
.filter( s -> s != null)
.findFirst();
Ruby:
@group_list.find { |x| !x["list"].blank? }16 -
TLDR: RTFM...
My dad (taught me how to code when I was a kid) was stuck serializing a Java enum/class to XML.... The enum wasn't just a list of string values but more like a Map(String,Object>.
He tried to annotate it with XMLEnum but the moment I saw this enum, I'm thinking that's unlikely to work.... Mapping all that to just a string?
He tried annotating the Fields in it using XMLAttribute but clearly wasnt working...
Also he use XMLEnumValue but from his test run I could clearly see it just replaced whatever the enum value would've been with some fixed String...
Me: Did you read the documentation or when the javadocs?
Dad: no, I don't like reading documentation and the samples didn't work.
I haven't done XML Serialization for years thought did use JSON and my first instinct was... You need a TypeAdapter to convert the enum to a serializable class.
So I do some Googling, read the docs then just played around with the code, figured out how to serialize a class and also how to implement XmlTypeAdapter.... 20 mins ...
Text him back with screenshots and basically:
See it's not that hard if you actually read up on the javadocs and realized ur enum is more like a class so probably the simple way won't work...2 -
Not a webdev so I don't care about how a website looks, but logical failures can really trigger me at times.
E.g. this German federal page you had a bunch of options to fill in your employment status. Though being incomplete it forced you to choose one from the list and then at the end you have to checkmark that you filled in everything correctly reminding you there might be legal consequences otherwise. Thanks.
Amusingly on the same page their enum to string converter seemed broken or they just didn't care. So options to choose from read like: Enum_marital_status_unwed_coupled
Fucked up the screen shot so I can't show, but made me chuckle.2 -
I am trying to extract data from the PubSub subscription and finally, once the data is extracted I want to do some transformation. Currently, it's in bytes format. I have tried multiple ways to extract the data in JSON format using custom schema it fails with an error
TypeError: __main__.MySchema() argument after ** must be a mapping, not str [while running 'Map to MySchema']
**readPubSub.py**
import apache_beam as beam
from apache_beam.options.pipeline_options import PipelineOptions
import json
import typing
class MySchema(typing.NamedTuple):
user_id:str
event_ts:str
create_ts:str
event_id:str
ifa:str
ifv:str
country:str
chip_balance:str
game:str
user_group:str
user_condition:str
device_type:str
device_model:str
user_name:str
fb_connect:bool
is_active_event:bool
event_payload:str
TOPIC_PATH = "projects/nectar-259905/topics/events"
def run(pubsub_topic):
options = PipelineOptions(
streaming=True
)
runner = 'DirectRunner'
print("I reached before pipeline")
with beam.Pipeline(runner, options=options) as pipeline:
message=(
pipeline
| "Read from Pub/Sub topic" >> beam.io.ReadFromPubSub(subscription='projects/triple-nectar-259905/subscriptions/bq_subscribe')#.with_output_types(bytes)
| 'UTF-8 bytes to string' >> beam.Map(lambda msg: msg.decode('utf-8'))
| 'Map to MySchema' >> beam.Map(lambda msg: MySchema(**msg)).with_output_types(MySchema)
| "Writing to console" >> beam.Map(print))
print("I reached after pipeline")
result = message.run()
result.wait_until_finish()
run(TOPIC_PATH)
If I use it directly below
message=(
pipeline
| "Read from Pub/Sub topic" >> beam.io.ReadFromPubSub(subscription='projects/triple-nectar-259905/subscriptions/bq_subscribe')#.with_output_types(bytes)
| 'UTF-8 bytes to string' >> beam.Map(lambda msg: msg.decode('utf-8'))
| "Writing to console" >> beam.Map(print))
I get output as
{
'user_id': '102105290400258488',
'event_ts': '2021-05-29 20:42:52.283 UTC',
'event_id': 'Game_Request_Declined',
'ifa': '6090a6c7-4422-49b5-8757-ccfdbad',
'ifv': '3fc6eb8b4d0cf096c47e2252f41',
'country': 'US',
'chip_balance': '9140',
'game': 'gru',
'user_group': '[1, 36, 529702]',
'user_condition': '[1, 36]',
'device_type': 'phone',
'device_model': 'TCL 5007Z',
'user_name': 'Minnie',
'fb_connect': True,
'event_payload': '{"competition_type":"normal","game_started_from":"result_flow_rematch","variant":"target"}',
'is_active_event': True
}
{
'user_id': '102105290400258488',
'event_ts': '2021-05-29 20:54:38.297 UTC',
'event_id': 'Decline_Game_Request',
'ifa': '6090a6c7-4422-49b5-8757-ccfdbad',
'ifv': '3fc6eb8b4d0cf096c47e2252f41',
'country': 'US',
'chip_balance': '9905',
'game': 'gru',
'user_group': '[1, 36, 529702]',
'user_condition': '[1, 36]',
'device_type': 'phone',
'device_model': 'TCL 5007Z',
'user_name': 'Minnie',
'fb_connect': True,
'event_payload': '{"competition_type":"normal","game_started_from":"result_flow_rematch","variant":"target"}',
'is_active_event': True
}
Please let me know if I m doing something wrong while parsing the data to JSON. Also, I am looking for examples to do data masking and run some SQL within Apache Beam4