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 - "type conversion"
-
The story of the $500,000,000 error.
In 1996, an unmanned Ariane 5 model rocket was launched by the European Space Agency.
Onboard was software written to analyze the horizontal velocity of the spacecraft. A conversion between a 64-bit floating point value and a 16-bit signed integer within this software ultimately caused an overflow error just forty seconds after launch, leading to a catastrophic failure of the spacecraft.
That day, $7 billion of development met it's match: a data type conversion.12 -
I just invented a new JavaScript operator. It's named "plus with wings", and it's used to sum to numbers without ambiguity or any need of type conversion, for example:
3 -+- "2" // 5
"2.1" -+- "4" // 6.1
"-1.1" -+- "" // -1.1
So, from now, you won't have to wonder anymore what type is that variable.
Tested on all browsers25 -
Drop ur file here to convert it to another file type
10 mins later after conversion
99%
"Sorry but u can't convert ur file cause u got an adblocker enabled pls disable it and try again"
Have u guys ever whipped ur dick out and smacked the monitor with ur dick with hope that ur dick smack will transmit the smack into the website across their face9 -
I once had a client who wanted a system where no matter what type of file someone uploaded we'd make a PDF out of it. I don't mean "print to PDF", I mean like a straight conversion. A picture, a doc file, a speadsheet, an MP3, a video, a CAD file, a .ivt file format you and I make up right now and tell no one else about for storing Iowan votes, anything.
I told him that was impossible.* There are indeed things out there where you can print to a pdf, but it would mean that a program that knows what a .grml file is, and how to represent it on paper, assuming it even can be, is involved in the middle.
He refused to believe me, and found a company where the sales person swore up and down their product could do it. I said "then you explained it wrong" and we went back and forth. It culminated in me being put in contact with THEIR programmer. I explained what he was looking for. Their programmer replied along the lines of "but that's impossible, and also what would a PDF of half these examples even look like?" I basically said "I know, but your guy is telling my guy you can do this, so you need to tell your guy to STFU before we ALL get roped into trying to convert Duke Nukem maps and zip files full of dlls to pdfs."
Luckily it finally died after that, but the whole ordeal took months.
*I'm being direct/blunt for the sake of brevity when recapping what I said, just fill in the usual "talking with a client niceties"12 -
I hate all of these rants about JavaScript being a terrible language.
In reality, it's one of the easiest languages to work with. This makes it easier for new programmers to write messy code, but is it the language's fault?
People get mad about the things that happen when you multiply "undefined" and a string...what do you expect?
You also have the freedom to choose from a variety of tools the community has created to solve existing problems. People just don't realize that they don't *have* to learn everything, you just learn as you need them.
Don't blame JavaScript for you bad programming, terrible type conversion needs, and great tooling.23 -
Code review time:
Hey Rudy, can you approve my PR? ??? Shouldn't it be can you review my PR?(thought to myself)
Anyway, as a new practice, we(royal we) do not approve PRs with js files. If we touch one, we convert it to typescript as part of a ramp up to a migration that never seems to get here. But I digress.
I look at the laziest conversion in history.
Looked like
Import 'something';
Import 'somethingElse';
Import 'anotherSomething';
export class SomeClass {
public prop1: any;
public prop2: any;
public prop3: any;
public doWork(param: any){
let someValue = param;
// you get the idea
return someValue;
}
}
Anyway, I question if all the properties need to be visible outside of the class since everything was public.
Then if the dev could go and use type safety.
Then asked why not define the return type for the method since it would make it easier for others to consume.
Since parts of the app are still in js, I asked that they check that that the value passed in was valid(no compilation error, obviously).
Also to use = () => {} to make sure "this" is really this.
I also pointed out the import problem, but anyway.
I then see the his team leader approve the PR and then tell me that I'm being too hard on his devs. ????
Do we need to finish every PR comment with "pretty please" now?
These are grown men and women, and yet, it feels oddly like kindergarten.
I've written code in the past that wasn't pretty and I received "WTF?" as a PR comment. I then realized I ate sh*t on that line of code, corrected it and pushed the code. Then we went to Starbucks.
I'm not that old(35), but these young devs need to learn that COMPILERS DO NOT CARE ABOUT YOUR FEELINGS!!!!!
Ahhhhhh
Much better.
Thanks for the platform.8 -
Did I ever tell you kids about the time I worked for a company that got a contract to develop an iOS application around some object detection software that had been developed by another team?
Company I was working for was a tiny software consultancy, and this was my first ever dev job (I’m at my second now 😅). Nobody at the company has experience building mobile applications but CEO decides that the app should be written in React Native because _he_ knows React Native.
During a meeting with the client, CEO jokes about how easy the ask is and says he could finish it in a weekend. Please note that Head of Engineering had already budgeted a quarter for the work. CEO says we can do it in a week! And moves up the deadline. And only assigns two engineers to project. I am not one of those engineers.
The two engineers that are put on it struggle. A lot. They can’t seem to get the object detection to work at all, and the code that’s already written is in Objective-C. I realize one of the issues is that the engineers on the project can’t read Objective-C because they have no experience with Objective-C or even C. I have experience with C, so I volunteer to take a look at it to try to see what’s going on.
Turns out the problem is that the models are trained on one type of image format and the iPhone camera takes images in a different format.
The end of the week comes, they do not succeed in figuring out the image conversion in React Native. There’s an in-person demo with the customers scheduled for the next Monday. CEO spends the weekend trying to build the app. Only succeeds in locking literally every other engineer out of the project.
They manage to negotiate a second chance where we deliver what we were supposed to deliver at the original schedule.
I spent the weekend looking up how to convert images and figure it would be a lot easier to interface with the Objective-C if we used Swift. Taught myself enough Swift over the weekend to feel dangerous. Spoke to Head of Engineering on Monday and proposed solution — start over in Swift. Volunteer to lead effort. Eventually convince them it’s a good idea (and really, what’s the worst that can happen? If this solves our main problem at the moment, that’s still more progress than the original team made)
Spend the next week working 16 hour days building out application. Meet requirements for next deadline. Save contract.
And that’s ONE of the stories of my first dev job that got me hired as a senior engineer despite only having 10 months of work experience in the industry.11 -
FFUUUuucccckkk me sideways. So I decided to look into USB type-c's power delivery and alt modes. Cause I kinda want to make an adapter card to run my displays over a single cable. TLDR of the rest: USB-C has some huge capabilities which noone is interested in using since its way to complex to handle for what its worth in the end.
Now PD alone is kinda ok to deal with since a lot of powerbanks use it and some hobby guys documented how to work with it. I find it really odd thou that you NEED to use a dedicated IC for using the configuration chanel to negotiate how much power you can draw. Why the USB standard didnt use some simple 5V low speed signalling? Also the standard says that you only have to implement 5v 0.6A with every other power level being optional. (This is also true for cables. Most manufacturers use only the USB 2.0 standard for them and brag about how fast type-C is. ლ(ಠ益ಠლ) )
Now to the alt modes. These motherfuckers are a real shitshow to deal with. First you need a Mux to deal with USB-C's two way insertion, so your signals wont get flipped. Next thing is that you have four lanes at your disposal in alt mode. Which you can either use for four Display Port Lanes or two DP lanes and two USB 3.0 lanes. (You always get USB 2.0) Now you may think that there would be one simple chip to do it all? Nope you need atleast two at the price of 6$ each. One for PD and one for Alt modes. Both are very hard to solder (QFN, 0.5 mm pitch 40+ pins) TI ended up being the only one with a decent offering of IC's that do what I need. As for working with them, you would think that you just slap a simple MCU on there that communicates over I2C or SPI to configure the chips? Nope! You program the chips memory from which it configures itsself. And the programming is done with some TI tool which gives me no idea as to how you can handle everything whith no control logic behind it.
Looking into alternative IC's leaves me with cypress semi. And their documentation is basically a total mess. I wanna know what that chip is good for and what I need to do to make it work. I dont care about technical details mixed with marketing jargon nobody understands. And I really despise that I have to register just to download a datasheet. Especially since there is no info about it on the main page.
And this whole rant hasnt even touched the topic that USB-C only uses DP and nothing else. So you better hope that you have DP++ so you can use a passive conversion.
This was my Ted Talk about USB-C. Some info in it may be subject to my stupidity and errors as it currently is 02:15 in the morning and I need some sleep.14 -
Sooo a coworker and I tonight were working on some software and somehow got side tracked on discussion regarding our thinking process, and how one of our other coworkers always things so strangely always defensive etc.. which then lead us to saying it would be nice if we could like see and feel how another persons brain is and how they draw conclusions and think..
this conversion immediately changed to the inner-monologue discussion.
And holy shit went go distracted for 4 hours tonight!
I have inner monologue, visual, auditory, symbolic and non symbolic abstract thinking in my mind, and it’s all happening at the same time, like a million miles a minute.
The other coworker has no inner monologue at all.
4 hours questioning each other trying to understand how the other one things then debating what we believe how the one perticular Coworker thinks. And then placing bets on what we think all the other coworkers are.
I’ve never had such a deep discussion on how my brain works nor how someone else thinks.
Like I was like joking but serious not in a bad way I’m not crazy my brain switches thinking depending on the situation I don’t have to. Try or think about it just occurs..
Like remembering things I’ll daisy chain and hop pictures, words and thoughts to bring back things but no effort it just occurs.
When a song is playing I can remember the last time I heard that song or part of the song I can feel how it was, I can see what I was doing what was happening in the world etc.
In the shower or driving I will have debates in my mind and play scenarios out in my mind on how a conversation or situation will go. I visually see and hear and feel the conversation that did or did not occur at that time. And I can jump to “playing” each person.
Or when a large decision is to be made or brainstorming an idea to me I like having the British parliament in a room, and debating the topic.
When people are talking I visually see what they are saying.
I thought EVERYONE was like this.. apparently not lol.
But this conversation did bring up a lot of realization of why I can quickly jump to conclusions or quickly move thru a conversation or concept but my coworker is lagging behind. Or having a hard time visualizing what I’m saying, thus me drawing it very fast and him/them saying how did you come up with that that quickly... ugh because in my mind I’ve already drew it up I’m just drawing what I see. Almost having to slow down and go back in time to explain something to them.
THEN we called a few of my “Star” interns haha and asked them, apparently they are all think the same way I do or atleast somewhat, which explains why some people I work i able to express ideas and continue thru a topic very quickly. While others I must slow down.
We need more of these discussions until now I had no idea there was “a different way people mentally process things” the entire conversation was very enlightening for the both of us, now I know what I must do differently and so does the other one.
But then we thought what caused this? Is this a learned trait from experience as a child? Or evaluation? Or just the deck of cards we are delt? Is this left hand people or right hand? I’m left hand and the two interns are left hand and they think the same, but the other coworker in the discussion was a right hander.. then we thought was this a result of imaginary friends as a young child? Was this a result of reading as a young child? Is one version better at math than the other.. music etc... is this a result of hyperactive brain? Drugs? Could drugs induce it? What does alcohol do to it...
Yeah we questioned all these things and more seriously went down the rabbit hole tonight... lmfao, tomorrow we will be surveying the rest of the team to see if we can draw any spurious informer conclusions and how accurate our bets were based on what we know personality wise of the other coworkers
SOOOOO thoughts???? Hahah
How many of y’all knew the other type existed? What type are you? And are you introverted or extroverted? Any rational relations we can connect to better explain this shit?9 -
Im building an API with NancyFx (HTTP stuff) and mobgoDB (database). i had very strage errors when starting queres. and after 2 fucking days if debugging i found it!
accidentally I wrote somewhere in a custom type conversion "ObjectId" i stead of "OwnerId".
F M L
"""""""""
#MongoDB #NancyFx #CSharp/.Net1 -
Top 12 C# Programming Tips & Tricks
Programming can be described as the process which leads a computing problem from its original formulation, to an executable computer program. This process involves activities such as developing understanding, analysis, generating algorithms, verification of essentials of algorithms - including their accuracy and resources utilization - and coding of algorithms in the proposed programming language. The source code can be written in one or more programming languages. The purpose of programming is to find a series of instructions that can automate solving of specific problems, or performing a particular task. Programming needs competence in various subjects including formal logic, understanding the application, and specialized algorithms.
1. Write Unit Test for Non-Public Methods
Many developers do not write unit test methods for non-public assemblies. This is because they are invisible to the test project. C# enables one to enhance visibility between the assembly internals and other assemblies. The trick is to include //Make the internals visible to the test assembly [assembly: InternalsVisibleTo("MyTestAssembly")] in the AssemblyInfo.cs file.
2. Tuples
Many developers build a POCO class in order to return multiple values from a method. Tuples are initiated in .NET Framework 4.0.
3. Do not bother with Temporary Collections, Use Yield instead
A temporary list that holds salvaged and returned items may be created when developers want to pick items from a collection.
In order to prevent the temporary collection from being used, developers can use yield. Yield gives out results according to the result set enumeration.
Developers also have the option of using LINQ.
4. Making a retirement announcement
Developers who own re-distributable components and probably want to detract a method in the near future, can embellish it with the outdated feature to connect it with the clients
[Obsolete("This method will be deprecated soon. You could use XYZ alternatively.")]
Upon compilation, a client gets a warning upon with the message. To fail a client build that is using the detracted method, pass the additional Boolean parameter as True.
[Obsolete("This method is deprecated. You could use XYZ alternatively.", true)]
5. Deferred Execution While Writing LINQ Queries
When a LINQ query is written in .NET, it can only perform the query when the LINQ result is approached. The occurrence of LINQ is known as deferred execution. Developers should understand that in every result set approach, the query gets executed over and over. In order to prevent a repetition of the execution, change the LINQ result to List after execution. Below is an example
public void MyComponentLegacyMethod(List<int> masterCollection)
6. Explicit keyword conversions for business entities
Utilize the explicit keyword to describe the alteration of one business entity to another. The alteration method is conjured once the alteration is applied in code
7. Absorbing the Exact Stack Trace
In the catch block of a C# program, if an exception is thrown as shown below and probably a fault has occurred in the method ConnectDatabase, the thrown exception stack trace only indicates the fault has happened in the method RunDataOperation
8. Enum Flags Attribute
Using flags attribute to decorate the enum in C# enables it as bit fields. This enables developers to collect the enum values. One can use the following C# code.
he output for this code will be “BlackMamba, CottonMouth, Wiper”. When the flags attribute is removed, the output will remain 14.
9. Implementing the Base Type for a Generic Type
When developers want to enforce the generic type provided in a generic class such that it will be able to inherit from a particular interface
10. Using Property as IEnumerable doesn’t make it Read-only
When an IEnumerable property gets exposed in a created class
This code modifies the list and gives it a new name. In order to avoid this, add AsReadOnly as opposed to AsEnumerable.
11. Data Type Conversion
More often than not, developers have to alter data types for different reasons. For example, converting a set value decimal variable to an int or Integer
Source: https://freelancer.com/community/...2 -
So, the PowerQuery type system appears to be a Joke.
For those you that aren't familiar with PowerQuery, it's the ETL language that is used in PowerBI, and some other parts of the MS PowerPlatform. It was formerly known as the M Language.
The language has a type system, that includes records (think hashes) and tables, which are, for practical purposes, a list of records.
The wonderful M language specification document states that:
"Any value that is a record conforms to the intrinsic type record, which does not place any restrictions on the field names or values within a record value. A record-type value is used to restrict the set of valid names as well as the types of values that are permitted to be associated with those names."
Except that the restriction is only to the set of valid names, and the language interpreter doesn't throw an error when I place a number into a text field, but also doesn't do any sort of implicit conversion. This is all hunky-dory, until you then try to load the data into the Tabular Model that underlies the query engine, which does expect the values to be of the type that is specified, and it throws an error.
But PowerBI, in its infinite wisdom, doesn't actually *record* the error, it merely tells you the error exists, and tells you to go back to the query editor to list the errors thrown up by the powerquery engine. Which, as previously stated, doesn't throw up an error for this instance.
So I've spent all afternoon trying to work out why my queries aren't loading, because I have an error that doesn't exist. fml.
[You can follow this issue on the communtiy feedback site here: https://community.powerbi.com/t5/... ] -
Random learnings/realisations/hypothesis:
i have found a sense of happiness in weird symbiotic environment : being rich in a poor environment and live with a poor-but-secretely-rich lifestyle.
i call it the "sheep-hoodie" lifestyle: being a wolf in a herd of sheeps but not with a sheep's skin glued to your body. rather a hoodie so you can be a friendly wolf , ferocious wolf and a friendly sheep whenever you want to.
my 1 group of friends are in a sheep phase : struggling in their life , crunched on money, not saving a lot or focused on savings and stuff. At least that's what shows up from their discussions. however when we are together, i see that we are always supporting each other, and sharing resources/helping each other while having fun
my another group of friends have a wolf lifestyle:
they are insanely rich, if you want to party/do something with them at 'their' level, you gotta have a lot of cash to burn . they are wolves because they know how to sell their stuff, whom to sell and how to retain the info for success. i don't enjoy much with them as their solutions to life problems end up with something that involves a lot of money than effort.
So my lifestyle is to earn like them, but live like my broke friends. they think that am earning 20% of what i earn now, and am also in lots of debts and family crisis. someday my lie is gonna burst when i buy expensive stuff lol
--------
#2
i have realised that i have an OCD for silence and psychotic reaction to noise . for me ,
Silent Environment >> sex >> any relationship.
I might react so aggressively to noise while trying to focus that i may end up breaking the closest of relations with anyone
--------------
#3
thinking of having 3 twitter accounts just to fix the problem of devrant not saving content of dormant accounts :
- professional : an id where i will share my professionally stupid questions, achievements, debates etc
- personal/partial-anon : an id where i will share my personal thoughts and stuff. it might also include devrant screenshots / embarrising content that i make here
- true-anon : a full anonymous account for my(some) extreme thoughts, trigger content and explicit researches
my current twitter feed is a mix of first 2, but making 2 seperate accounts might give me more freedom(the level of devrant) to express myself than what i do now (as my followers are also interesting people but mostly related to tech)
guess i should move my tech content there than my personal content.
------------------------------
#4
making an early opinion about something should only be done to research for truth/content/conversion/hype . final opinion should always be made after you trust something with a research. for eg, initial opinion of Elon Musk was he being a bad guy, but now after seeing his crazy ideas and approach towards twitter, he looks like someone who can truly make it a money minting machine.
------------------------------
#5
A simple perception towards making money as not being a bad thing does wonders at a management level and life .
liberal opinion of twitter layoff and later changes were emotional and blaming, but thinking from a business approach, his company partners(and whoever he likes) now have special golden badges to feel like VVIP and have an orgasm, while he gave a dummy melon to every person on earth to pay for feeling like a VIP and have an orgasm.
a brilliant tactic to make money without anyone calling the minting of money as BAD. genius
------------------------------
#6
was randomly checkin Insta, saw an ex-collegue share a random deep thought quote, and i realised that i might have known her for just a week or 2 in college, but she had a very nice nature.
However, she was the daughter of a very rich ass dad and had almost everything in life. she gave a bit spoilt(for me) look, like someone who did ciggs or drink, but her talks then and our chats later just on chat gave me a very nice hustler vibe (the type of people i like: hustling and professional)
I indirectly asked her on a date and she agreed. so, this is something very interesting for me, as i am hopelessly single and full of judgemental opinions/ strict rules. share your tips and notes on how to have a successful date, and stuff that one must NOT do . much grateful if you do not come under rule 29 of internet and share your POV