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 - "const"
-
They're giving multiple projects to work on and it's so fucking hard to remember workflow of 4-5 projects while working on side projects as well10
-
My coding behavior:
1. console.log("Hello World");
2. CTRL S
3. this.date=moment();
4. CTRL S
5. const yesterday = this.date
6. CTRL S
7. Open Chrome Browser to preview
8. Accidentally pressed CTRL S and saved that page19 -
based on true story
> delivered project on time
> giving good performance
> boss noticed
> gives appreciation
> raise in salary
> profit2 -
!dev
const children = {
length: 1,
data: [{
name: "noah",
gender: "male"}]
};
children.length++;
children.data.push({
name: "mina",
gender: "female"
});
const happy = true;21 -
Hehe, stumbled upon an oldie :-)
struct ComputerContractor
{
double salary;
long lunches;
float jobs;
char unstable;
void work;
int hiring_him_again;
const pain_in_the_arse;
unsigned agreement;
short fuse;
volatile personality;
static progress;
};
/* and there are no unions in sight */3 -
So today I was with my I guess 9-10yo cousin. He was playing clash of clans.
I told him, “you can also make this type of games”.
After this he was stared at me for like 25-30sec his face expression was awesome. Then said “seriously? I thought games are developed on a certain place where all the games are made.”
I said “no anyone can create games if you know how to code and all.”
After that multiple questions was on the way and I answered all for him.
But he totally amazed with this knowledge. And I felt good to.10 -
Interviewed a dev for a junior role earlier this week...my first question:
const numbers = [0.1, 0.2, 0.3];
let sum = 0;
for (i = 0; i < numbers.length; ++i) {
setTimeout(() => {
sum += numbers[i];
}, 0);
}
// Refactor the preceding code so that the following returns true.
console.log(sum === 0.6);
---
He had no idea where to even start, so I asked him to walk through the code with me line by line, he couldn't get past line 1 - literally didn't know what an array was... I walked through the code with him and he just started to look more and more lost.
I didn't even bother with the rest of my questions on OOP, FP, etc...
Am I really expecting too much of somebody that claims to have 2 years practical experience in JavaScript, jQuery, Angular, and PHP?
Do you think this is a problem a junior dev should be able to solve...even if it takes some hand-holding?57 -
My code is reviewed twice, once by the team leader, and once by a tech lead.
One told me to move a const from file a to file b, so I did. The other told me to move it from b to a.
I really don't care, so now they are behind me duking it out :)5 -
It's so fuckin hard to work with people who don't get sarcasm or humour.
The UI guy gives me design (which is a regular design, not something unique)
Me: “wow fresh and unique design (obviously sarcasm).”
Designer: “thanks, I worked on this whole day. Glad you like it.”
Me: “huh...”
Now I feel like a terrible person.6 -
Oh you'll love this. A master password to access any user.
Something like:
const masterpassword = <dayABCyearXYZ>
if (password == dbpassword || password == masterpassword) { // allow access }
The best part is this code is available to our clients. They can literally see how this "master password" is generated. And they don't want me to remove it because it's being used by testers.7 -
today while I was at work, gets a call from an unknown number
Some lady: "hello, is this Mr XYZ."
Me: "yes".
she:" are you looking for a job? are you working somewhere?"
Me: "I'm currently wor... *she ends the call*."
what the fuck that was, fuck you. at least let me finish the sentence god dammit7 -
What was the biggest lies you heard about programming or programmers life.
Mine was: “programming is easy and high paying job.”
No it is not.12 -
Arch Linux is officially dead due to fanboys who always says “I use Arch Linux” everytime when they open mouth. It is considered as mental illness so they have to shut down.10
-
What's the meaning/story/idea behind your username?
PS.- don't bother if your actual name is your username76 -
When I slice the head off a list I usually call the rest decapitated.
const [head, ...decapitated] = myList1 -
In C++ we don't say "Missing asterisk" we say "error C2664: 'void std::vector<block,std::alocator<_Ty> >::push_back(const block &)': cannot convert argument 1 from 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<block> > >' to 'block &&'" and i think that's beautiful
(not mine, source: https://goo.gl/Akxjih)4 -
found this website that helps me to concentrate while coding, https://noisli.com
Different types of background sounds choose according to mood3 -
Finished all my tasks. Went to bed happily thinking i deserve this rest.
Then after going to bed:
const onSleep = (position) => {
const newPosition = position === 'left' ? 'right' : 'left';
setTimeout(onSleep(newPosition), 120000);
}
Fml
😫3 -
*enters in restaurant*
After 15sec new notification
*Write your review for this place, to help others*
At least let me see the godamn Menu first.
Fuck you google3 -
const nsfw = require('nsfw');
//Now that's a sexy name for an npm package
https://www.npmjs.com/package/nsfw1 -
On my first week in the internship, I have to create a small website and it has to be finished ASAP. So I used Bootstrap.
After finishing I tested the website in chrome debugger tools for every screen size (design responsiveness), it was working fine. My stupidity was that I haven't tested on actual mobile/tablet.
The site was live, I send the link to one of my friends and he said "why everything is so small? looks like I'm browsing on PC". I quickly grab my phone and visited the site and it was not responsive on mobile. Started to check the code again, tested again on chrome tools it was working. But not on mobile. Changed the bootstrap file but no fucking changes on mobile.
After few moments of thinking, I realized that I haven't included the "meta viewport" tag. I felt so stupid and it was kind of embarrassing for me.
Now I first include meta tags before working on new project.5 -
There's a protest going on in my city so all the public transportation is affected, almost everything is closed.
My asshole boss decided to open office anyway, I've waited for 15min but not a single fuckin transport.
Now I've to walk for almost 4KM (2.48 miles) to reach the office.
Fuck this.11 -
So a Developer not using a React-native component library because it is backed by Microsoft
This is next level shit
PS:- the library is actually pretty decent23 -
I am currently in a bit of a (well-deserved) lull at work, both of my projects are finishing up/ finished, so tomorrow should be pretty light, as the latter half of today was.
And I have really gotten interested in the HTTP protocol. It's so interesting learning how it all works under the hood.
So I think I'm going to be researching/ messing around with creating a cpp project that essentially implements cURL from the ground up, creating sockets, reading from them, parsing the HTTP requests... all that. I don't expect to actually get it done, but it should be an immense learning experience. I have a clear goal: implement this function:
std::string get(const std::string&);
Once I'm able to just GET as simple as that, I know I have achieved my goal!3 -
today is one the worst day of 2018, after this
https://devrant.com/rants/1571445/...
I was looking through the websites which were made in the company last year, and while looking at a website I said: "this website is looking total shit, what the fuck is this".
Guess what, the guy who made the website was there and more worst he's my senior, I'm currently doing a project with him. He was not happy with this comment ( I thought the guy who made this left the company ). I totally fucked up.
Now I will search for another job. I can't bear this.4 -
If you are teaching a newbie HTML and basic JS using ES6/ES2015 features, the "Hello World" app probably would be:
<!-- index.html -->
<html>
<body>
<div id='container'>
<h2> Enter a Name and Hit The Button</h2>
<input id='name'>
<button id='change-name'>Say Hello</button>
<h3 id='name-display'></h3>
</div>
<script type='module' src="./index.js"></script>
</body>
</html>
//index.js
import {sayHello} from './hello.js';
let displayArea = document.getElementById('name-display');
let input = document.getElementById('name');
let button = document.getElementById('change-name');
button.addEventListener('click', () => {
//displayArea.innerHTML = "Hello World"
displayArea.innerHTML = sayHello(input.value);
});
//hello.js
export const sayHello = (name='World') => {
return `Hello ${name}`;
};
Source: https://github.com/benmccormick/...7 -
So met a guy today in college and it was his first day in class. He told me that he is working as software engineer and having 4 years of experience and primarily works with Java lang.
We do programs in Java for practicals and I'm not good with Java (I fuckin hate). I thought maybe I can ask for help from this guy if I'm stuck. And so the practicals started.
And guess what the guy did not know how to compile Java program on 'cmd' and was seeking help from other guy. I'm like what the actual fuck. How the fuck he has 4 years of experience and can't compile a program. Can't even able to set path. Total idiot. Fuck this shit.10 -
Find the odd one out :
a) const int * foo
b) int const * foo
c) const * int foo
d) int * const foo7 -
TL;DR Pluralsight should be ashamed for taking 299 USD a year and writing some very low-quality quizzes.
I've always heard that Pluralsight is a great platform having some high quality courses, so I chose it as a benefit, as our company was giving us some budget for learning purposes. I've paid (or rather the company did it in the end) 299 USD for this year, which, I guess is not much for US standards, but it is a lot for Eastern European standards.
I didn't actually get to the point of watching any of the courses, but I started to use a feature called "Stack up", which is a long series of questions in a specific theme, like Java, Kotlin, C++, etc., accessible once a day. I must say, I'm amazed by the fact, that people pay quite a great amount of money and they get something so poorly made with a lot of errors and stupid questions.
Take the question from the included image for example. Not only that the 2 possible answers are repeated (and thus I failed to select the correct one from 2 equal answers), but the supposedly correct answer is also missing some type specifications. No Java compiler will compile it this way as far as I know. There would be at least 3 ways to fix it.
Then there is today's gem (should be included as first comment) as well, where the answer is wrong in both Chrome 96, Firefox 95 and Node v10. Heck, THIS IS one of the reasons why you should never use `var` in your JavaScript code, but always `let` and `const`!
So the courses on Pluralsight might be good, but I would be ashamed, if I were to release something like this. People might actually try to solidify their knowledge by solving these quizzes but instead of learning something useful, they will be left with some bullshit. I just don't get how could they release a feature with so much incorrect information and I am kind of disappointed, even if I didn't try the courses yet.9 -
My first login function
const login = (email, password) => {
If (email && password) {
return true
} else {
return false
}
}10 -
LOL that's why I love C!
The function pointer cast for strcmp because qsort expects a compare function with two const void * pointers instead of two const char * pointers, that's just beautiful.
Not to mention the hack to abuse strcmp on a struct - which just works because the first struct member is a string and the rest just gets swapped with memcpy as opaque data.
I guess that wouldn't pass a code review at work. :-)6 -
I don't understand people who write "Fu*k" instead of "Fuck", dude everyone know what's that means anyway and you definitely not going to become a Honorable man or you will go to heaven by doing this. Seriously.11
-
Project in college, many moons ago.
Team is building a robot for a project. Nothing too crazy, it does some simple tasks like walk along a path and shit.
3 weeks for the project. 3 team members.
The largest graded part of the project is the ability to follow a path based on vision.
The 3rd member INSISTS on doing that part, he says “I want to prove to the professor that I am the smartest in the class so he helps me get a work term.”
Of course, my other partner and I see this as the complete selfishness of a child who will never be employed anywhere worth talking about anyways. He is a big asshole about it and we end up giving in.
## Week 1
We get our parts done (working together the way a team would) without his help.
He struggles, hits walls, complains. You know, dumbass grown child stuff...
## Week 2
We offer to help since we are done. He refuses. The teacher sees all of this and doesn’t like it at all.
After class the 2 of us go to the teacher and let him in on the details. The guy insisted, he is struggling and will not take help etc.
Teacher goes and talks to him and tells him it is a team project for a reason and that we should be helping. He says yes.
Then he misses the rest of the classes that week and send an email saying...
“Since everyone decided to keep interrupting me and breaking my train of thought, I could not get anything done in class. Therefore I will be staying home to finish the project from there.”
And to top it off, he didn’t even take home the robot’s connectors he needed to do the damn thing. Haha.
## Week 3
We know he wasn’t going to get it done, so we approached the teacher. We make it clear that we have done all we can and that we are not ok with losing marks because of this.
Since we are both good students that he likes, he decides to give us an option.
You can take a 50% on his part even if he doesn’t get it done (for trying to help) or we can do it ourselves and he won’t get the marks if he doesn’t finish.
## Night before
We say fuck it and do the thing.
In fact, since we were learning Java at the time we decided to do it in Java. Our other prof sees us playing with robots and gets excited, he stays with us and suggest improvements.
In the end we rewrite all 3 robot functionalities in Java and hand in the project the next day.
## The day of
Partner 3 comes into class and says this...
“That walking path part is impossible, I didn’t get it done, but I bet nobody else did either. So at least we will get a 60% on the other 2 parts!” (With a big shit eating grin)
Prof calls our group up. We walk up and the prof looks at the 3rd guy and says.
“Since you have decided to do your part alone, we will have you present your part alone at the end of the groups”
He tries to say something but the prof cuts him off and tells him to sit down.
We show all of our code and the robot does everything perfectly.
Groups go by, now it’s that guys turn.
He says that the walking part was impossible but seems to realize right away that he just saw EVERY other group get it working.
The teacher ask him to stay after class.
## Result
We got a 98 (prof said he was hoping we would have done in VB like asked but he liked the result a lot).
Other guy gets a 5% for his non-working spaghetti code on 0s on the other 2 sections. He blames us, of course.
Bonus Content:
That same asshat above once said this to me...
“I don’t indent my code so that if I work for a company and no one else can understand the code then I am unfireable!”
Yes, he wrote all code like this...
const Example = () => {
Stuff
More stuff
For() {
Stuff
If() {
Stuff
}
}
}
Fuck that guy🖕🏽3 -
I almost got caught by this during an interview:
const foo = ['a', 'b'];
const bar = foo.findIndex(x => x === 'a'); // 0
if (bar) { // I'm an idiot
console.log('Do something');
}
🤦♂️23 -
You know what really grinds my gears? When people criticize a programming language but uses edge cases and stuff that can be avoided by using the tried and true "don't be an idiot". Take for instance JavaScript, a language I like and a language that has a lot you can criticize. But I feel like a lot of peoples criticism isn't warranted.
What's that? No ints? Use parseInt or Math.floor.
What are you saying? == works in strange ways? Yes, that's what we have === for.
Type coercion is wonky? Think it's weird how string + int works differently than string - int? Wanna string with number + - + - - + - - etc? Don't! Don't add strings and ints, don't subtract strings and ints. You can't in statically typed languages and you aren't supposed to in dynamically typed
Adding arrays and objects, arrays and arrays, objects and objects etc. is inconsistent? Why are you trying to do that?
Adding floats together gives odd results? Now we're getting somewhere! And Mozilla responded to that with a method called toFixed.
Declaring variables with var doesn't always work that well? Use let and const
Then there's this weird attitude that some people I've met have, where they will complain about the module system and how "well you rely on the community for those packages" as if it's a bad thing. And then coming with the "well you don't know what the (open source) packages do internally" as if I (for the most part) give a shit. Then they'll swear by companies like Zend or Microsoft as if they can't just stop supporting the languages they use. Maybe it's just because I like community content more because of video game mods.
Wanna criticize JS, then there's plenty to talk about. Like the built in date object is basically shit. Or how in NodeJS you can have node_modules in your node_modules. Or how classes don't really have the best syntax. Left-Pad. And so on (it's too late for me to be able to remember much more).1 -
!dev
finally, after a week of helping my friend to learn the basics of front-end web development, he got the internship at one of my friend's office ( he set up the interview on my request).
It does feel good.1 -
Taken a day off due to sickness, boss calls and said “can you fix an error on xyz website? it's urgent.”
I said No, I'm in hospital I can't. Even though I was at home.
He said “please look once whenever you'll reach home.”
Me: “sure.”
Idiot got no chill.
GFY5 -
Do you guys drop the S from your variable names? I am constantly in a dilemma as to what makes more sense.
For example a SQL Table:
Books
----------
BookID
BookName
....
---------
OR
Book
---------
BookID
BookName
.....
---------
Or even in a language like C# or JavaScript:
const BOOKS
var books
let books
or
const BOOK
var book
let book
Even if you have multiple items in that variable/table it seems very redundant to ever have the s.
What do you guys think? Any input appreciated!
Happy coding!24 -
this happened two months before,
there's a UI designer guy at my office when I was about to leave the office he gave me a web page UI which has to be done by the next day.
Next day I started working on that page when I was halfway done he came to my desk and said: "there're some changes in design, the client doesn't like this part and this."
I'm like, why the fuck you didn't take client confirmation on the first place that's a fucking basic and first thing need to do. Just like the client you are a fuckin idiot. And now we don't hang out anymore. -
How about creating a new programming language named "C slang"
highlights from the language:
1. variable declaration :
by default, all declaration are var, but inorder
to declare a constant, write:
cunt a = 15; // means const a = 15;
2. input and output :
suck(b) // input stored in variable b
spit(b) // output b
3. function declaration:
f**k <function_name>(parameters);
4. null or None will be replaced by sh*t
for example: if(node root == sh*t)....
any other sh**y recommendation will be appreciable6 -
!dev
can you guys suggest me good TV/Anime series with few seasons or episodes so I can use my Sunday. Not in a mood for work.37 -
I'm in a dental hospital now, after treatment (not mine) the doctor says “eat Ice-Cream after 10min and take medicine after that.”
I'm like this is the most beautiful words I've heard from a doctor. -
I can not fuckin stress how goddamn annoying it is to work with strings in C++. I'm not talking about std::string, those are bearable. But fucking char foo[number], char* foo, and const char* foo. AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA17
-
Recently one of my friends got an internship in front-end web, today he messaged me "dude, where I can find a responsive template for xyz category." I gave the link to that.
I told, "why you guys not using bootstrap to make responsive, to begin with".
He said, "my mentor said no to that."
I'm like, you guys download a fucking template but can't use bootstrap. wow.13 -
I need to delay execution of code in a for loop, how do I do that?
PHP: Sleep(3000)
Javascript:
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
console.log(num)
})
console.log('Done')
}
start()
Fuck you Javascript17 -
I want to explain to people like ostream (aka aviophille) why JS is a crap language. Because they apparently don't know (lol).
First I want to say that JS is fine for small things like gluing some parts togeter. Like, you know, the exact thing it was intended for when it was invented: scripting.
So why is it bad as a programming language for whole apps or projects?
No type checks (dynamic typing). This is typical for scripting languages and not neccesarily bad for such a language but it's certainly bad for a programming language.
"truthy" everything. It's bad for readability and it's dangerous because you can accidentaly make unwanted behavior.
The existence of == and ===. The rule for many real life JS projects is to always use === to be more safe.
In general: The correct thing should be the default thing. JS violates that.
Automatic semicolon insertion can cause funny surprises.
If semicolons aren't truly optional, then they should not be allowed to be omitted.
No enums. Do I need to say more?
No generics (of course, lol).
Fucked up implicit type conversions that violate the principle of least surprise (you know those from all the memes).
No integer data types (only floating point). BigInt obviously doesn't count.
No value types and no real concept for immutability. "Const" doesn't count because it only makes the reference immutale (see lack of value types). "Freeze" doesn't count since it's a runtime enforcement and therefore pretty useless.
No algebraic types. That one can be forgiven though, because it's only common in the most modern languages.
The need for null AND undefined.
No concept of non-nullability (values that can not be null).
JS embraces the "fail silently" approach, which means that many bugs remain unnoticed and will be a PITA to find and debug.
Some of the problems can and have been adressed with TypeScript, but most of them are unfixable because it would break backward compatibility.
So JS is truly rotten at the core and can not be fixed in principle.
That doesn't mean that I also hate JS devs. I pity your poor souls for having to deal with this abomination of a language.
It's likely that I fogot to mention many other problems with JS, so feel free to extend the list in the comments :)
Marry Christmas!34 -
KISS, DRY, Path of Least Resistance, Three Strikes and You Refactor, early returns, no array.map when nothing is returned, only use switch when # cases >= 3.
And using var in javascript instead of let/const to piss off my colleagues (and because I understand function scope well)6 -
my frontend colleagues always keep amazing me with their create way of writing code:
```
const input = "a";
const result = {
"a": () => console.warn("A was selected"),
"b": undefined,
"c": () => console.log("hello")
}[input || "c"]?.();
```
Poor man's switch construct ... (facepalm)16 -
#howToGetAGirl
const getAGirl = () => {
// TODO: Implement function
};
Anyone?
https://twitter.com/chuxmyk/status/...38 -
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
void setDate(const char* dataStr) // format like MMDDYY
{
char buf[3] = {0};
strncpy(buf, dataStr + 0, 2);
unsigned short month = atoi(buf);
strncpy(buf, dataStr + 2, 2);
unsigned short day = atoi(buf);
strncpy(buf, dataStr + 4, 2);
unsigned short year = atoi(buf);
time_t mytime = time(0);
struct tm* tm_ptr = localtime(&mytime);
if (tm_ptr)
{
tm_ptr->tm_mon = month - 1;
tm_ptr->tm_mday = day;
tm_ptr->tm_year = year + (2000 - 1900);
const struct timeval tv = {mktime(tm_ptr), 0};
settimeofday(&tv, 0);
}
}
int main(int argc, char** argv)
{
if (argc < 1)
{
printf("enter a date using the format MMDDYY\n");
return 1;
}
setDate(argv[1]);
return 0;
}7 -
As an exercise lets see how many different ways we can wish devRant Happy Birthday in code. Try not to copy peoples examples, use a different language or different method.
A couple of examples to start the process:
* LOLCODE *
HAI 1.3
LOL VAR R 3
IM IN YR LOOP
VISIBLE "Happy Birthday"!
IZ VAR LIEK 1?
YARLY
VISIBLE "Dear devRant"!
NOWAI
VISIBLE "to you"!
KTHX
NERFZ VAR!!
IZ VAR LIEK 0?
GTFO
KTHX
KTHX
KTHXBYE
* C *
#include <stdio.h>
#define HP "Happy birthday"
#define TY "to you"
#define DD "Dear devRant"
typedef struct HB_t { const char *s; const char *e;} HB;
static const HB hb[] = {{HP,TY}, {{HP,TY}, {{HP,DD}, {{HP,TY}, { NULL, NULL }};
int main(void)
{
const HB *s = hb;
while(s->start) { printf("%s %s", s->s, s->e); }
return 1;
}12 -
const abc: string = 'Hi';
Can we take a moment to appreciate how retarded it is that TSlint throws a warning here that the string type is inferred and unnecessary.
I want to put the type there because it looks more readable. Code looks better if every variable has a type, irrespective of whether it's a constant. I know the fucking type is inferred you braggart linter bitch. What the fuck does it expect? A fucking award because it inferred that a string constant is of the fucking type string? How the ever loving fuck does that warrant a squiggly ass yellow warning line, reminiscent of that smartass 10 year old in class who has to yell out every answer when the teacher never asked a question.5 -
ZAYN : Baby, let me be your man.
BABY : No let, only const.
...
Disclaimer : it's a JavaScript joke.
😂😂😂😂3 -
Converting one of my older projects to use functional components and hooks instead of class components and prop drilling. It's nice.
Though now I have this useState:
const [ disembodiedHead, setDisembodiedHead ] = React.useState("");
Promise it's not as creepy as it sounds.5 -
I am in a situation where I am tired to give suggestions or implement any improvements to the company's app. I am in a situation where I will just do as told, nothing more, nothing less.
Regardless of how many suggestions or improvements I had made, the boss is constantly sceptically asking for "BLACK AND WHITE " proof. Sometimes, something does not require proof but cause and effect. As the application constantly prompts a DataType issue, which is a common bug in this app! I declare datatype the issue went away.
I wonder how this application can go further when they declare every variable as `var`, not using `const` for constant value, and redundant methods everywhere, most methods are not specific (in dart when you do not specify the method, the method become `dynamic`), a long list of nested if-else for something can be easily solved with switch case, etc.
So, today, right now, I will revert every improvement, and keep the original structure. If anything goes wrong, I know why it happens (deep down I will say "I told you so"). I am here to work for food, not to reinvent the wheel.
I'm so exhausted to the point where I will just go along and tell my co-worker "as you wish"
No more me suggesting.
No more me giving ideas.
No more me pointing the mistakes .
I will let them find out themselves is much better than I say it, just to prevent getting unnecessary hatred from them.
The best punishment to give somebody is to never mention their mistake let their ego do the job of consuming them into ignorance and asleep, and never wake them up. Let them commit the same mistakes repetitively until them realised there's no way to revert.5 -
This is how I explain my co-workers when they see this line of code in my utilities projects:
export const pipe = (...fns) => x => fns.reduce((y, f) => f(y), x)3 -
Finally ended, the stupid meeting which was going from last 4 hours for a web app. In the end I got to know that I'm not part of it.
Wow, what a wonderful way to waste my time.3 -
Nothing ruins my day like having to touch up python scripts. I'm predominantly a Java dev and never learned Python properly so every time I do it its THE WORST2
-
TIL that you can use underscores as a decorative numeric separator in ES 2021 like
const FOURTY_FIVE_MILLION = 45_000_000;
I learned this from some shitty advertisement on a Minecraft economy server where I thought the little shit was just trying to be techy.
Luckily I wasn't actually rude to him because then I would have looked like an ass.5 -
AndroidOS.
Why: well it's built on Linux kernel so first good thing.
Due to open source everyone can get cheap (under $50) smartphones running on Android with millions of app to access. We can create custom ROMs.
Your one app can target billions of people around the world and so much more...
PS: half of the Play Store apps are shit.5 -
So we got a new Front-End intern today.
My senior was demonstrating to her how to minify and beautify JavaScript codes.
And I'm like WTF dude she has worked with Front-End technologies and she knows that.
And who the fuck beautifies and again minify jQuery script. Totally idiot.2 -
It's been more than 3 years since ES6 came out.
Why are tutorials STILL coming out with people using "var" over "let" and "const"?
Var is dead folks.8 -
typeof rant === "Encouragement"
Never let your self down, try to be your own const in life that know his scope and traits well enough to construct a peacefull life without any uncatched exceptions. Also try to return something to the public, keeping your magic pointers to your private makes it hard to review your glorious source of thoughts. And if it is getting hard try to REST a bit and git some timeout.
😉1 -
University: "It is important to distinguish between read-only variables and editable variables. They make it easier to find bugs if you're changing a value that should not be changed"
Me: changes all `const`s and `val`s for `var`s every time I get a re-assign error.2 -
Doing react-native and find out I can't develop iOS apps on windows pc.
Fuck you Apple and your XCode1 -
Any JavaScript developers out there willing to help me out with something?
I have an interview question that I like to ask candidates that no one ever seems to get right. But, to me, it seems pretty basic, so I expect MOST JavaScript developers at almost any level of expertise to get it, and I like it generally because it demonstrates some core knowledge of JavaScript concepts and syntax.
But I want to verify that my feelings about it are reasonable, because give how few ever seem to get it right (and I'm talking across literally hundreds of interviews, MAYBE 2 people have ever gotten it right), I'm starting to wonder if I'm right or not.
Look at this code, and then answer the question after. Please do so off the top of your head and without testing anything since that's normally the experience a candidate would have. I'll give the answer after some time for anyone who gets it wrong but is curious.
But this isn't about YOU getting it right or not, and it's not about whether it's the best way to do something in JavaScript or anything like that, it's just about whether it's a reasonable question and whether my expectation that MOST JavaScript developers should get it right is fair.
const O = {
sayHello : function() { alert("Hello"); }
};
const S = "sayHello";
Question: using ONLY the variables O and S (and you MUST use both), write code that executes the sayHello function.
Thanks!34 -
Why React is soo complicated? Seriously why do we always need to use some stupid shit like this
const [state, setState] = useState();
what the fuck is this? Who designed it that way, why it should always look like shit for no reason? Why its API feels like spaghetti? When i am comparing other front-end frameworks they feel like heaven in their structure.
AND WHAT IS WRONG WITH ME HAVING A QUOTE ON A PARAGRAPH ELEMENT, WHY DO I HAVE TO USE FUCKING HTMLENTITES FROM 2000?
FUCK'ERE35 -
It's so fucking hard to explain my job to people who don't have slightly idea about it
Person : what you do?
Me : Web development
P : what's that?
M : you know websites on internet for users or clients for products/information bla bla bla
P : like amazon, facebook, xyz ?
M : Yeah you get it
P : so you develop facebook?
M : huhh.... No not that I'm not working for FB that's a different company we create websites according to clients.
(Inner me: why don't you fuck off already)
P : huh... Okay ( no fucks given )1 -
<rant>
I was once a pure server side developer. Then came full stack development. So in order to keep up with the competition, I had to brave through front-end development.
But goddamn javascript, make up your mind between functions, and “Objects”.
Also variable visibility. Goddamnit. I thought ES6 was widely supported. I was happy doing const and let bbut goddamn testing frameworks, grunt and shit. Can’t make up it’s mind to support it unitedly.
And lastly, IE. Goddamn it, why the fuck are you not supporting Promise by default. We’re fucking 2017. [insert slowpoke meme]
</rant>
One good thing though, I like the library vuejs.
Bad thing is, this is just the beginning of a much more upcoming headache.4 -
I don't know how to tell but my love to JavaScript is undefined. I can't stop const sharing this information wherever i am.4
-
import answer from "./knowledge.js"
const topic = 'Vue'
const rant = false
const allowDumbAnswers
const q = 'Why to use only a single Vue instance?'
allowDumbAnswers ? return : answer(q);9 -
public const bool DEBUG_THAT_SHIT = ConfigurationManager.ParseBool("debugThatShit");
public const bool DEBUG_THAT_OTHER_SHIT = ConfigurationManager.ParseBool("debugThatOtherShit");
public bool iMadeANewFeature = ConfigurationManager.ParseBool("newFeature")?true:false;
Fucking new guy, can you not fucking read the other constants and make them look the same? Apparently not and I am the asshole. -
Do you test your codes while coding or after completion?
I test while coding.
PS:- I'm web developer.15 -
Sometimes I feel like I'm a dumb worthless retard, a pathetic excuse of an ape with no reason left to live this pathetic farce of a life.
But then I remember there are people who enforce "prefer-const" in their codebase, and there I realize that if those people are alive and well I must deserve something too, and thus I hold on.
I will outlive you. I will remove that dumb directive from your linter config and I will commit that to master. I care not what happens next.6 -
My friend sent me this as WYSIWYG
/* A simple quine (self-printing program), in standard C. */ /* Note: in designing this quine, we have tried to make the code clear * and readable, not concise and obscure as many quines are, so that * the general principle can be made clear at the expense of length. * In a nutshell: use the same data structure (called "progdata" * below) to output the program code (which it represents) and its own * textual representation. */ #include <stdio.h> void quote(const char *s) /* This function takes a character string s and prints the * textual representation of s as it might appear formatted * in C code. */ { int i; printf(" \""); for (i=0; s[i]; ++i) { /* Certain characters are quoted. */ if (s[i] == '\\') printf("\\\\"); else if (s[i] == '"') printf("\\\""); else if (s[i] == '\n') printf("\\n"); /* Others are just printed as such. */ else printf("%c", s[i]); /* Also insert occasional line breaks. */ if (i % 48 == 47) printf("\"\n \""); } printf("\""); } /* What follows is a string representation of the program code, * from beginning to end (formatted as per the quote() function * above), except that the string _itself_ is coded as two * consecutive '@' characters. */ const char progdata[] = "/* A simple quine (self-printing program), in st" "andard C. */\n\n/* Note: in designing this quine, " "we have tried to make the code clear\n * and read" "able, not concise and obscure as many quines are" ", so that\n * the general principle can be made c" "lear at the expense of length.\n * In a nutshell:" " use the same data structure (called \"progdata\"\n" " * below) to output the program code (which it r" "epresents) and its own\n * textual representation" ". */\n\n#include <stdio.h>\n\nvoid quote(const char " "*s)\n /* This function takes a character stri" "ng s and prints the\n * textual representati" "on of s as it might appear formatted\n * in " "C code. */\n{\n int i;\n\n printf(\" \\\"\");\n " " for (i=0; s[i]; ++i) {\n /* Certain cha" "racters are quoted. */\n if (s[i] == '\\\\')" "\n printf(\"\\\\\\\\\");\n else if (s[" "i] == '\"')\n printf(\"\\\\\\\"\");\n e" "lse if (s[i] == '\\n')\n printf(\"\\\\n\");" "\n /* Others are just printed as such. */\n" " else\n printf(\"%c\", s[i]);\n " " /* Also insert occasional line breaks. */\n " " if (i % 48 == 47)\n printf(\"\\\"\\" "n \\\"\");\n }\n printf(\"\\\"\");\n}\n\n/* What fo" "llows is a string representation of the program " "code,\n * from beginning to end (formatted as per" " the quote() function\n * above), except that the" " string _itself_ is coded as two\n * consecutive " "'@' characters. */\nconst char progdata[] =\n@@;\n\n" "int main(void)\n /* The program itself... */\n" "{\n int i;\n\n /* Print the program code, cha" "racter by character. */\n for (i=0; progdata[i" "]; ++i) {\n if (progdata[i] == '@' && prog" "data[i+1] == '@')\n /* We encounter tw" "o '@' signs, so we must print the quoted\n " " * form of the program code. */\n {\n " " quote(progdata); /* Quote all. */\n" " i++; /* Skip second '" "@'. */\n } else\n printf(\"%c\", p" "rogdata[i]); /* Print character. */\n }\n r" "eturn 0;\n}\n"; int main(void) /* The program itself... */ { int i; /* Print the program code, character by character. */ for (i=0; progdata[i]; ++i) { if (progdata[i] == '@' && progdata[i+1] == '@') /* We encounter two '@' signs, so we must print the quoted * form of the program code. */ { quote(progdata); /* Quote all. */ i++; /* Skip second '@'. */ } else printf("%c", progdata[i]); /* Print character. */ } return 0; }6 -
gta5 source code leaked
const char* testActionTreeName[] =
{
"ActionTree/Fuck",
"ActionTree/FuckYou",
"ActionTre",
"ActionTre/Fuck",
"ActionTree/Fuck/you/in/the/ass",
};2 -
Wasted a day as Shitlock Holmes with the build chain.
It would not reproduce the firmware hexfile that had been checked in. Reverse engineering that along with the mapfile to find out the cause, it was a const string that was guarded by an ifdef from another file that was auto-generated as prebuild step via a script that fetched some version control info.
Or, it would have been if the installation instructions had been correct and someone had described that no spaces in the absolute path name of the project are allowed. Otherwise, that shit just failed silently.
I then had to reverse engineer the intended workflow from the commit history in the version control to figure out that the last dev obviously hadn't quite understood the project specific workflow and how the version control interacts with these build scripts.
At least, I finally did get a matching hexfile.1 -
*laughing maniacally*
Okidoky you lil fucker where you've been hiding...
*streaming tcpdump via SSH to other box, feeding tshark with input filters*
Finally finding a request with an ominous dissector warning about headers...
Not finding anything with silversearcher / ag in the project...
*getting even more pissed causr I've been looking for lil fucker since 2 days*
*generating possible splits of the header name, piping to silversearcher*
*I/O looks like clusterfuck*
Common, it are just dozen gigabytes of text, don't choke just because you have to suck on all the sucking projects this company owns... Don't drown now, lil bukkake princess.
*half an hour later*
Oh... Interesting. Bukkake princess survived and even spilled the tea.
Someone was trying to be overly "eager" to avoid magic numbers...
They concatenated a header name out of several const vars which stem from a static class with like... 300? 400? vars of which I can make no fucking sense at all.
Class literally looks like the most braindamaged thing one could imagine.
And yes... Coming back to the network error I'm debugging since 2 days as it is occuring at erratic intervals and noone knew of course why...
One of the devs changed the const value of one of the variables to have UTF 8 characters. For "cleaner meaning".
Sometimes I just want to electrocute people ...
The reason this didn't pop up all the time was because the test system triggered one call with the header - whenever said dev pushed changes...
And yeah. Test failures can be ignored.
Why bother? Just continue meddling in shit.
I'm glad for the dev that I'm in home office... :@
TLDR: Dev changed const value without thinking, ignoring test failures and I had the fun of debunking for 2 days a mysterious HAProxy failure due to HTTP header validation... -
how lazy can you be
```
const { available, quantity, deliveryDate } = {
available: data?.getStockLevels?.[0]?.available || "Unavailable",
quantity: 0,
deliveryDate: data?.getStockLevels?.[0]?.deliveryDate,
};
```10 -
After 4 hours doing something didn't commit the code cause I don't have a fuckin clue what I did
guess I need good sleep. -
Never hated or loved Microsoft.
After joining devRant, within 4 days I hate Microsoft more than ever. Thanks Guys. -
[JS]
Which one do you think is faster? Pushing callbacks to an array and iterating them when they're due, or this:
const oldcb = cb;
cb = () => { someNewStuff(); oldcb(); }
The callbacks can never be removed and will finish fast, their order shouldn't matter.8 -
Erlang... variables you can't vary? WTF!
Writing JS two weeks later...
const a =1
const b = a + 1
Why would I ever assign over a? Pfft.
const c = b + 1
...1 -
I feel like it might be a tiny bit (not much) better among React developers, but I ended up within one of those enterprise Angular till death companies, and it seems like nobody would ever doubt their Typescript skills, yet nobody actually understands Typescript at all.
In theory, I love Typescript. But you can abuse it to a point where it's almost as painful to work with as normal JavaScript.
It's not that I'm a master of Typescript.
But while I feel like I'm the only one understanding the mental model behind Typescript and also get stuff like mapped types or why you might wanna replace your enums with as const assertions, the rest calls themselves Typescript developers in their CV, no doubt. But It's way to easy to write whatever Typescript, while it's not as easy to reel get the hang of it.7 -
so I started a side project a while ago.
the only thing it could do was to create some files with desired names and extensions. so this was basically a pretty simple editor.
I left this project with no future plans for a month or so until I started working on it again this week. I added comments to the editor, a console user interface.
the ui isn't futuristic. the program runs in the console. it just lists all the files and folders where the program is currently located in. in the beginning it could take user input and that input was the location where the files created in the editor would be saved. then I thought: it would be more interesting if I created a folder in which I saved the files from the editor. so I did this thing.
then I thought, again: hey, this console is pretty boring and stuff. why should I add some special commands? and so I did.
now you can create an empty folder, before you created a folder and saved at the same time the files created in the editor. now you can open another folder in which you can do the same stuff as before. you can get the current location of the folder you are currently in, so you don't get lost in your fancy computer. you can delete a folder completely, set color, reset color.
but one thing that I lost almost ONE FREAKING HOUR ON IT TO MAKE THE USER EXPERIENCE BETTER was the following: when creating a folder, either empty or with the files from the editor, the program automatically opens the folder, not in the console(hey, I didn't thought of that) but in the file explorer from the os. now it only works for windows and windows explorer because I used system(const char*). I know it's not portable or efficient but I just wanted things to work, I will optimise it later.
the thing that made me lose that one hour debugging was figuring out how to open that file.
ok, so I used windows api with GetCurrentDirectory, I knew how to use system, I knew how to form the path that would match up with the folder, I almost knew how to open the folder with system().
the problem was that I had the path complete, but if the folder had white spaces system() wouldn't recognise the freaking command!
so the string with the path would also contain the command used in system() and I would just .c_str() the string so it could work. as an example my wrong way to make the path was this:
"start C:\\path"
can you figure out what is the problem?
you don't?
it's just so trivial.
how cannot you figure it out?
of course you NEED to put "explorer" between the start command and the actual path!
pffft, you idiot! so easy to figure it out.
so yeah, the right way to open a folder is like this:
"start explorer C:\\path to heLL!!"
p.s.: I still don't understand why putting explorer works and without it doesn't. without explorer it just just says that path with the first word before the white space doesn't exist. -
const ifs = i => {
if (i === 1) return '2'
// (a lot more ifs)
}
const switches = i => {
switch (i) {
case 1: return '2'
// (a lot more cases)
}
}
console.time('time')
for (let i = 0; i < 1_000_000_000; i++) ifs(i)
console.timeEnd('time')
// time: 637ms
console.time('time')
for (let i = 0; i < 1_000_000_000; i++) switches(i)
console.timeEnd('time')
// time: 949.524ms25 -
const silicon_valley = true;
if(silicon_valley == true) {
watchSiliconValley();
} else {
work();
}
// yeah I know it's crappy1 -
Ted talks or music with tea (mostly office).
Food, music, hangout with friends/family, Animes, movies, TV series lot of options. 😀4 -
const int pi = 3.14;
This is the worst example ever to explain what a constant is to students.
I knew a lot of guys who think that math constants and programming constants were the same thing4 -
```js
const app = require('express')()
app.get('/myname', (req, res) => {
res.status(502).send('Bad Gateway.\nUnknown header in brain response: "Hello world!".')
})
app.listen(80)
```2 -
Last night I was awake until 5am watching tv series now feeling sleepy all day. Well it's Sunday so fuck why not.1
-
const topic = 'Laravel'
const subtopic = 'Queues'
Have you used Redis? Have you used it as your Queue driver? Is it cool? Are there better alternatives?5 -
Tomorrow is my internal exams in college and all I can think about working on my side project, kind of amusing
-
Can you guys give me Name suggestion for a website?
Under the name we will create mobile apps and websites. It will free to use for anyone.
Preferred .com domain
Thanks in advance :)11 -
const obj = {
a:5,
b:25
}
const {...Object.keys(obj)} = obj;
console.log(a);
It would have been cool if that worked 😅4 -
1. Find a function: getDayDiff(d1, d2)
2. d1 and d2 are momentjs dates.
3. See that function performs complex ancient math rituals and then returns an integer
4. Try to rewrite function, return d2.diff(d1, 'days')
5. Should be OK right? Run tests
6. Whole module melts down. WTF?!
Turns out the math performed returned the difference + 1 because it included the current day which moment's diff() function does not (out of the box).
Processes that depended on this function then uses the result like this:
const diff = getDayDiff(d1, d2)
if (diff-1 == should_match) { /* more fun logic */ }
$ git checkout .
$ run-shutdown-script-because-fuck-you2 -
So I figure since I straight up don't care about the Ada community anymore, and my programming focus is languages and language tooling, I'd rant a bit about some stupid things the language did. Necessary disclaimer though, I still really like the language, I just take issue with defense of things that are straight up bad. Just admit at the time it was good, but in hindsight it wasn't. That's okay.
For the many of you unfamiliar, Ada is a high security / mission critical focused language designed in the 80's. So you'd expect it to be pretty damn resilient.
Inheritance is implemented through "tagged records" rather than contained in classes, but dispatching basically works as you'd expect. Only problem is, there's no sealing of these types. So you, always, have to design everything with the assumption that someone can inherit from your type and manipulate it. There's also limited accessibility modifiers and it's not granular, so if you inherit from the type you have access to _everything_ as if they were all protected/friend.
Switch/case statements are only checked that all valid values are handled. Read that carefully. All _valid_ values are handled. You don't need a "default" (what Ada calls "when others" ). Unchecked conversions, view overlays, deserialization, and more can introduce invalid values. The default case is meant to handle this, but Ada just goes "nah you're good bro, you handled everything you said would be passed to me".
Like I alluded to earlier, there's limited accessibility modifiers. It uses sections, which is fine, but not my preference. But it also only has three options and it's bizarre. One is publicly in the specification, just like "public" normally. One is in the "private" part of the specification, but this is actually just "protected/friend". And one is in the implementation, which is the actual" private". Now Ada doesn't use classes, so the accessibility blocks are in the package (namespace). So guess what? Everything in your type has exactly the same visibility! Better hope people don't modify things you wanted to keep hidden.
That brings me to another bad decision. There is no "read-only" protection. Granted this is only a compiler check and can be bypassed, but it still helps prevent a lot of errors. There is const and it works well, better than in most languages I feel. But if you want a field within a record to not be changeable? Yeah too bad.
And if you think properties could fix this? Yeah no. Transparent functions that do validation on superficial fields? Nah.
The community loves to praise the language for being highly resilient and "for serious engineers", but oh my god. These are awful decisions.
Now again there's a lot of reasons why I still like the language, but holy shit does it scare me when I see things like an auto maker switching over to it.
The leading Ada compiler is literally the buggiest compiler I've ever used in my life. The leading Ada IDE is literally the buggiest IDE I've ever used in my life. And they are written in Ada.
Side note: good resilient systems are a byproduct of knowledge, diligence, and discipline, not the tool you used. -
So I have this code written in node:
Function connect(){
const client = net.blahblah
client.on('close', () => {
Connect()
}
}
As the connect is called from within the close call back, it wouldn't be recursive right? Like if it disconnected a million times, it shouldn't throw a recursion error or use up a bunch of memory right? Or am I thinking about it wrong?2 -
I just reviewed a pull request with a test case like (pseudo code):
# Test MyService
const mock = createMock(myService.myMethod)
.whenCalledWith("foo")
.returns("bar");
assert(mock.myMethod("foo") === "bar"));
Why though? Why are we testing the mock? What is happening here? This test has no reason of being there instead of a fuzzy feeling that we now have unit test to lure us into a false sense of security.
I asked why we don't do an integration test. Response was: "They are slow."
Well, duh, but at least they would actually test something.
What do you gain by asserting that the mock is working the way you set it up?3 -
Clean Coders Hate What Happens to Your Code When You Use These Enterprise Programming Tricks
https://youtube.com/watch/...
fantastic presentation all around
its like proving in realtime how i know those certain people who complained about a single const i used are in fact, total noobs and poor programmers!
🤡🤡🤡🤡🤡🤡4 -
A)
const gulp = require("gulp"),
sass = require("gulp-sass");
OR
B)
const gulp = require("gulp"),
const sass = require("gulp-sass");
I use A14 -
So at one point I worked on an inherited project that had the worst code I've ever seen. I mean bad, so bad there may no quantifiable measure that can accurately convey how bad. We ended up naming the thing 'the hydra', cause it had a million issues and they just kept growing as we fixed things. To my point, in C++ they implemented their own primitive type Boolean32 as a signed int32 pointer. If that wasn't enough they used it as an octal bit mask. They also switch the value using logical and / or between 2 numbers, 037777777777 and 000000000001. So essentially they only switch this value to 1 or -1 and end up comparing it to their own const true or false. In c++ any value not 0 is == true...apparently not in this code.undefined octals why me? why would you do that? terrible code awful code c++ coding no designs bad code
-
WHO THE FUCK THINKS
THIS SHIT
TS:
```
const a = function(callback: (err:any,data:string) => void):void{
callback(null,'balls');
}
a(function(err:any,data:string){
console.log(err,data)
})
```
IS BETTER THAN THIS
ES6:
```
const a = function(callback){
callback(null,'balls');
}
a(function(err,data){
console.log(err,data)
})
```
kys10 -
Cool project, cool people, but everything-just-works™ code makes it hard.
Every component has its own logic for the things that are already made, every table has its own filters and those filters are the same piece of code in every component.
I'll complain about this shit tomorrow as today I spent my day making a fucking table work, can't even copy the shit as it has its own intertangled logic that doesn't make any fucking sense.
Yesterday I ate Bolognese, today I'm working in one.
Lol the funniest thing Iis that dude who wrote this piece of shit is gonna review my code, can't wait for that call.
And yeah useMemo() on every fucking function. Functions pulling shit directly from state and returning it straight away...
Literally this:
const filteredData = useMemo(() => { return stateData }, [stateData])
Ok, what the actual fuck.
The weirdest wtf was that typescript is used as it should, like every case covered correctly. Not sure if gpt or just dumbasses working on this pos.7 -
Note: I have deleted my previous version of this question as I found it lacking crucial information and therefore being prone to misunderstandings.
Question : In C/C++ you can position the keyword 'const' either left or right of the left-most type specifier. Which variant do you prefer?
I ask that because I'd like to hear your opinion. Although I have been working with C over three decades now, I only learned this a couple of years ago. After some experimentation I decided for myself, that I like the placement to the right more. Although the positioning to the left is taught in literally every book and course, the original placement suits me better.
One reason, of many, is the listing of many member variables in structs or classes. To have them nicely aligned, I always had to put 'const' either on the previous line or put in extra indention to everything non-const. That was quite irritating sometimes.
Another, and my main reason is, that when reading from right to left, the rhs variant just makes more sense than the lhs variant. Reading from left to right almost never makes much sense without straining your eyes. But that is, of course, highly subjective.
This is even more so if you have pointers. The 'const' keyword modifies the type identifier(s) to the left. So if the 'const' is (anywhere) left of the '*', the data is const. If the 'const' is right of the '*', the pointer address itself is const. The same applies to references.
Examples, read right-to-left:
int* const i; // i is a const pointer to int data
int const* i; // i is a pointer to const int data
int const* const obj; // i is a const pointer to const int data
The "classical" or "taught" way, that is found almost everywhere would read, still right-to-left:
int* const i; // i is a const pointer to int data
const int* i; // i is a pointer to int data const
const int* const obj; // i is a const pointer to int data const
Not only that the second "lhs" form reads worse, it also looks worse. In my opinion, the first "rhs" variant makes it simpler to quickly determine that we are dealing with three ints, while on the second "lhs" variant, one has to first get past the 'const' keywords.
I know that this is not only a matter of taste, but of course of agreement, too. You can not just go and switch the 'const' placement in long standing projects. That would surely piss of a lot of people. Or even cost you your job.
But I like to know what you people think and why.
Thanks a lot in advance!5 -
Hi. I just wanted to share I failed the google online interview. Thought I was prepared, I vomit and had diarrhea 30mins before the interview, Always makes mistakes on google docs. I keep pressing tabs which uglifies the code, miss-spelled my variables and functions name, mistakenly put everything in const (I got used to my editor yelling at me when I used const instead of let, should not rely on this). But there's always next time. I hope.6
-
I thought I found a way to compute PI, but I actually just found a super shitty way to print a variable..
const precision = 1000000
// convert degree to radians
function rad(degree){
return degree * (Math.PI/180);
}
function calculatePI(){
// [x, y]
// take first point on start of unic circle
const point1 = [Math.cos(0) , Math.sin(0)];
// take second point at 0.001 degree
const point2 = [Math.cos(rad(1/precision)), Math.sin(rad(1/precision))];
// Estimate 0.001 degree of circle
const dist = Math.sqrt((point2[0] - point1[0] ) ** 2 + (point2[1] - point1[1]) ** 2);
// Calculate full circle
const perimeter = dist * precision * 180;
return perimeter;
}
console.log(calculatePI());4 -
have you ever created Hybrid app? which framework did you use?
OR
which framework is good to create hybrid app and easy to adapt?9 -
Saved almost 50min traveling time due to public holiday so less traffic while working on public holiday. It's a loss-loss situation anyway.
Well fuck. -
‘Groundhogging refers to the idea that people are going for the same type of person over and over again, while expecting different results,’ they explain. ‘People pick out someone who fits their ideal type, date them, but end up feeling underwhelmed.'
From: https://metro.co.uk/2022/02/...
Awfully resembles a pure function makeLoveHappenForMe with a single arg typeOfPerson:
const typeOfPerson = Jerk
// this is a pure function
makeLoveHappenForMe(new Jerk())
// will always fail
// but does it really have no side effects?2 -
TIL following two lines are NOT the same in JS with webpack, even though logically they should be - it should be just an application of an eta reduction... First line works, second one crashes, probably because mysteriously executed too soon, before obj is initialized.
export const t = (...args) => obj.t(...args);
export const t = obj.t;
Sometimes I really hate JavaScript magic.2 -
israel population = ~10 mil
uk population ~70 mil
popular vote uk = 0
popular vote israel = 325
huh?????? i finally believe the conspiracy theory... there is total bullshit moving through the undercurrents of international society. actually the entire media and everything on the planet is shifted by angry retards with an IQ of approximately 27 who read something on twitter and therefore they must of course conform and do it
rich hands of influence reach far across this modern world....
my twitter dies on wednesday, I think i'm quitting this platform too... i'm just so sick of wasting time 'discussing' with people who literally have informed their entire lives by sources of media that all have an agenda, and yet said reader can't recognize that. go to bot school you fucking 🤡
also inb4 eurovision is a clown event, i know it is, but the fact that 'israel' as a country was for a good 10 minutes at 1st place of the vote is simply mind boggling to me (and to be fair, switzerland, france, israel, portugal, and croatia acts in terms of art and musical talent were all shit IMO) but what do i know? apparently the 700 mio people who live in europe don't agree - but even then, who knows anything about anything as to the actual 'numbers' that are posted on these 'votes' - could all be fake, or, even worse, the entire WORLD could be fake and i'm just typing to a fucking reflection of my own conciousness on this box
ach i'm very close to just turning it all off, its just rubes on top of rubes, derivatives on top of derivatives all more retarded than the next, and each night
then i get people like kiki who rage at me for getting drunk, then 'brag' they ran 5k. i ran more and drank more than you today, get over it.
i didn't need pills to do any of it either.
or i get sid the it kid, who gives non ironic lessons in fucking PHP 😂😂😂😂 in 2024 on youtube, and yet acts like he's a badass because he pointed out a 'redundant' 'const' in my code 😂😂😂😂 actually i don't know why in the first place i listened to any of it... going my own way has ALWAYS been the best way
by 2030 i will sell my saas(es) for 500k(+) and wonder why i even gave clowns on this platform the time of day
you know what? fuck it, it's been fun devrant, as of today i become a hermit, sick of this planet, and these apes
read books, go running, learn math (or any skill at that matter) and stay calm.
i can't describe in words to all of you how much a fucking abysmal waste it all is... just build useful stuff that helps people. the enormous (and trust me, it is absolutely eclipsingly enormous) discussion about everything around everything else is truly and utterly mind numbing and time wasting to the absolute core
farewell14 -
Lol. In the years that `const` and `let` have been in Javascript, not once have they ever helped me read the code better or caught a bug. They have not helped me understand anyone else's code, nor have they really helped convey any sort of meaning for other developers that I have heard.
Usually the rule is, const first, then change it to let if you need to. It adds nothing.
All this gold plating is weighing things down.15 -
const json = {key: 0}
json.key=1
console.log(json);
>>> {key: 1}
I just wasted ages debugging that7 -
Looking into Kotlin, and it seems pretty cool, but I just can't get over how unnatural and annoying the mapOf syntax is.
In JavaScript: const obj = { a: 1, b: { c: 3, d: 4 } }
In Kotlin: val obj = mapOf("a" to 1, "b" to mapOf("c" to 3, "d" to 4))5 -
It's been one month since I joined devRant, the community is awesome and it is good to be here.
It was the second-best suggestion given by Google in recent times. -
Am I the only one who wants to be able to write functions in a human readable way, allowing for parameter in-between the words?
Instead of defining:
const enforceStringEndsWithChar(string: string, char: string) => {...}
I want to define it as:
const enforce(str: string)EndsWith(char: string) => {...}
.
.
.
I'll see myself out.6 -
Quick JS tip
If you want to split a string into characters, you can use the ES6 spread operator
If you have
const name = 'react-dev'
You can just spread it like this:
const charsInName = [...name]5 -
True story:
While doing a CR stumbeled upon the following line, with no documentation attached:
CONST = "{0}{1}{3}//{4}{5}{6}//{7}.{8}" -
I’m so sorry if this is the place for questions. I’m terrified of stack overflow and have been searching for a week for a solution and can’t find one. This is for React.js people.
I was tasked to create a webpage with react. The limitation is, they did not wanna adopt the node.js dependency. I said ok, I’ll figure it out. You can inject react, material UI, and babel with script tags in HTML, then put ur lil components in it. I did that and it works beautifully.
However, now I have to write tests for this. I think it’s actually impossible without a way to render React, so I have to use the browser, or node, right? I convinced my boss to allow me to use a node.js container just for testing, which I thought would make my life easier.
I don’t know how to render this thing with node. It’s just an HTML file that pulls react via script tags, and idk how to serve html with node. Additionally, none of the React testing libraries seem to support testing a system that wasn’t designed to be served with node, at least not easily. My gut tells me that the complication with how things are imported contributes at least a little to this (dependencies pulled via script tags in the HTML file and made available to react through global const variables).
I could be wrong about any of this — im fairly new. But how tf do I go about testing these react components? For reference, if you go to Reacts docs, there’s a section called “add react to a page in one minute” that’s pretty much what I did.20 -
It's time for war!
I have two examples doing the same thing. They're bot generated by chatGPT.
React:
import React, { useState } from 'react';
function IncrementalButton() {
// Create state to hold the count value
const [count, setCount] = useState(0);
// Function to handle incrementing the count
const increment = () => {
setCount(count + 1);
};
return (
<div>
<h2>Count: {count}</h2>
<button onClick={increment}>Increment</button>
</div>
);
}
export default IncrementalButton;
VUE:
<template>
<div>
<h2>Count: {{ count }}</h2>
<button @click="increment">Increment</button>
</div>
</template>
<script>
export default {
data() {
return {
count: 0,
};
},
methods: {
increment() {
this.count++;
},
},
};
</script>
<style>
/* Add your CSS styles here if needed */
</style>
Whats better in your opinion?17 -
What the fuck is this syntax in a typescript file, I'm having trouble finding documentation if anybody can enlighten or link me
const [, updateThing] = useMutation(UpdateThingMutation);
The [, throws me off
i fucking hate front end19 -
So I thought I had a basic, high level understanding of C++ STL strings, pointers, copy constructors and stuff. In comes a dirname, a -D_GLIBCXX_USE_CXX11_ABI=0 and... Toto, I've a feeling we're not in Kansas anymore.
So what is happening? I copy a string expecting a deep copy, but then I do the dirname or manipulation on the copy and it messes up *both* strings. gcc/C++ I know you're a beast, but what's going on there? Thing is only possible if I cast away const from c_str - which of course is a doubtful operation - but there also seems to be some strange copy on write logic that the data pointers initially point to same memory location and only with first manipulation on the copy they start to point to different addresses.
I had no clue. And still don't have.4 -
if anyone is familiar with immer js or immutable js:
if the producer copies the base state to nextState, and nextState is a const, doesnt that defeat the purpose?
I mean you're going for immutability, which is great for say an undo function, or for finding bugs, but what are you doing with all these immutable values now hanging around in memory?
I assume each new state returned is being pushed onto an array? (because you cant stuff it into nextState because nextState is immutable).
Wont this lead to memory usage increasing over a user session, the longer the session lasts?
I feel like I'm misunderstanding some core concept here.
edit: also what the hell is structural sharing?18 -
I'm ok with almost every language.
But this "everything is a function" concept of JavaScript always give me that "kill me painless and quick" itch !!!#":":/#*%¢|°°
const fuuuuuuuuuck = require('fuckoff.js')1 -
Filthy Pollo: import {globalStore} from '../main.js'
Filthy Pollo: is that unstandard javascript?
Filthy Pollo: it makes me think it's from webpack
Filthy Pollo: unforgiving...
Ron Chi: i wont answer these questions again
Ron Chi: i already told u chrome supports imports its been a few months
Ron Chi: modules are evaled once, so if u have some state living in ur module if u reimport it ull just get that same state
Ron Chi: myModule.js - const myShit = { 'a': 'eh?' }; export { myShit };
Filthy Pollo: https://i.imgur.com/1X4Taik.png
Filthy Pollo: gg
Ron Chi: index.js - import { myShit } from './myModule.js'
Filthy Pollo: import and export are unexcepted token
Ron Chi: import needs to be used at the top of a file, before any other code
Filthy Pollo: https://i.imgur.com/myrrIMx.png
Filthy Pollo: Im going to assume import and export aren't supported in the browser
Ron Chi: because ur squigly line in ur editor?
Filthy Pollo: This feature is only implemented natively in Safari and Chrome at this time. It is implemented in many transpilers, such as the Traceur Compiler, Babel or Rollup.
Ron Chi: https://github.com/paulirish/...
Ron Chi: actually i dont think its handled properly by babel, webpack handles it
Filthy Pollo: what the fuck why use import and export that wont work in other browsers like firefox, edge, etc. ?
Ron Chi: because other browsers are slow
Ron Chi: its still standard
Filthy Pollo: your answer is not really professional
Ron Chi: ?
Ron Chi: why because its my fault that other browsers are still working on it
Ron Chi: they fought over implementation details forever, than it has to be implemented properly before shipping it
Filthy Pollo: Im blaming the people who are still using export and import in the browsers
Ron Chi: u wont be using modules without transpiling without some limited market for a couple years, otherwise ull still be using rollup / system.js / webpack
Filthy Pollo: obviously webpack
Ron Chi: thats up to you, it seems the google ppl use rollup
Ron Chi: but most of the community chose webpack
Ron Chi: angular 2 uses system.js internally i think
Filthy Pollo: Firefox 54 – behind the dom.moduleScripts.enabled setting in about:config.
Edge 15 – behind the Experimental JavaScript Features setting in about:flags.
Filthy Pollo: nobody wants to be bothered to change settings in flags
Filthy Pollo: the developers who use experimental features are weirdos as hell
Filthy Pollo: the joke is when they use experimental feature for production and force them to download chrome
Filthy Pollo: Monopoly as hell
Filthy Pollo: Corruption of User Experience -
One of my least favourite parts of the world of programming is the "there's a usecase for everything" attitude. Like take this part of "You don't know Javascript" https://github.com/getify/...
> But var is still useful in that it communicates "this variable will be seen by a wider scope". Both declaration forms can be appropriate in any given part of a program, depending on the circumstances.
Now you would imagine that after this comment the author added a good example of this or at least had a reference to another part of the book where it showed this, but nope it goes on to include this note:
> It's very common to suggest that var should be avoided in favor of let (or const!), generally because of perceived confusion over how the scoping behavior of var has worked since the beginning of JS. I believe this to be overly restrictive advice and ultimately unhelpful. It's assuming you are unable to learn and use a feature properly in combination with other features. I believe you can and should learn any features available, and use them where appropriate!
Which again, "durr there's a usecase for this feature" or rather it's coming with basically an insult towards people who don't think you should use var without actually addressing anything. And what usually happens when someone tries to "there's a usecase for everything" is to either be really vague, or come up with some silly thing that you "might" do. -
I'm reading some react/typescript code and I haven't work much with any other language or paradigm where I might have a function return multiple objects that are different types
e.g.
const { sna, foo, bar } = useWhatever();
I mean I guess it's just unpacking properties from the actual return object but that isn't apparent to a newcomer at a glance (if I remember correctly)
https://softwareengineering.stackexchange.com/...
Looking for additional insights from the wise devrant community30 -
var job = {}
try {
const req = await searchJobs()
job = ffInterviewProcess(req)
}
catch(e){
console.error(“you have no job, go back to your country”, e)
}
finally {
console.log(“Tears in eyes for” + (job ? “” : “not”) + “getting a job”)
}2 -
Javascript really needs a way to define consts for a block 1 level up.
So instead of
const el = wide ? els.wide : els.tall
You can do
if (wide) const el = els.wide
if (!els) const el = els.tall
// etc..
Just makes chaining and backup values way easier than inline conditionals 🤔15 -
Couldn't find it on Google but does Node 6.9.1 support ES6 syntax and const, let, etc?
The code runs on my machine which uses 6.9.1 I think but the Code Style report raises issues saying it needs a esversion: 6. I can add it but dunno if it's gonna break in PROD -
Just spent 3 hours on a segfault bug that could have been prevented had I been diligently putting const where it should be. Shame on me. Never be too lazy for const-correctness ever ever ever...1
-
Fuck me, I must be trippin' some js balls. I have a number const which gets yanked out from a number[] and then compared in a find method. Trouble is, the const is somehow turned into a string at compile time.5
-
update on this
https://devrant.com/rants/1617751/...
My first interview was kinda okay, I think I'm not in the mood to join them as well. They have to create a web app and they are considering Angular and React but they're more favorable to Angular which I haven't used yet.
Second went pretty well as per my expectation, those guys using React, Vue in which I'm more interested and they seemed friendly to me. Instead of stupid questions (tell me about yourself bla bla bla), they asked the only logical question which was more related to work and my experience. In the end, they asked me about my salary expectations and joining period, and I'm feeling positive about it.
Now I've to wait for next week to get a response from both interviews.1 -
imagine building an app using javascript(react-native) that get list of skills which will be displayed to the user to select and the same list displayed as interest for the user to do the same if you try to treat them seperately but from the same source you get a shit result e.g
const list = responseFromApi;//array of object
let skills = list;;
let interest = list;
skills.checked = true;
interest is changed and the list constant variable is changed the values change were ever the list variable is assign to a variable and the variable is tempered.
the above code was the fustration i got with javascript when i didnt know of the mutation guy.
Mutation is a nightmare never knew javascript object are passed by reference which make them mutable this sucks....
another crazy behavior below though the same;
const person = {name:'Dan',age:43} //object
let person0 = person;
let person1 = person;
person1.name = 'David'
the value of both person0 and person get change.
this is madness .3 -
working from client's office from last 3 months.
The project manager whom I'm working with asking me to Join full-time there.
The company is way bigger than my current employer, package definitely will be 2x or more than my current package and I'm not sure.2 -
I have to say, I was excited about const and let, but seeing const written 10 times stacked on top of itself makes me wish it was just var. It's too long. If you are going to shorten a word - go all the way.1
-
rust can't even do rustfmt properly
it just does things unadvertised
like reorder_impl_lines which is described as putting type and const on top of files adds new lines between fn declarations and that's not disclosed anywhere. ffs took me a while to figure it out
and chain_width should be different for fn calls and match statements. because newlining multiple fn calls makes it readable, but newlining match statements and wrapping them in {} does not / makes it ugly. there is match_arm_blocks but it still newlines random stuff awkwardly, raaghh
I thought hey so cool I can write without caring about formatting and just press Ctrl + shift + i and all done but now I'm arguing with the formatter and the settings available suck and are poorly described. please don't write a formatting documentation with no examples, wtf? And disclose everything it does, preferably with consistent language so I can search the page (some of the descriptions say new line others call a new line a break. thanks)1 -
HELP
Why does gcc fails to compile?
main.c:10:1: error: unrecognizable insn:
10 | }
| ^
(insn/f 18 4 19 (set (mem:SI (pre_dec:SI (reg:SI 1 bx)) [0 S4 A32])
(reg:HI 0 ax)) "main.c":8:1 -1
(nil))
during RTL pass: shorten
main.c:10:1: internal compiler error: in insn_default_length, at insn-attrtab.c:221
0x61f93f _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
../../gcc/rtl-error.c:108
0x61f95b _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
../../gcc/rtl-error.c:116
0x742291 insn_default_length(rtx_insn*)
/home/user/Documents/gcc/build-d16i/gcc/insn-attrtab.c:221
0x9ee716 shorten_branches(rtx_insn*)
../../gcc/final.c:1118
0x9ee78f rest_of_handle_shorten_branches
../../gcc/final.c:4753
0x9ee78f execute
../../gcc/final.c:47828 -
Functional programming in a one liner:
const value = (define_value, start) => value(define_value(start))1 -
My destructor accidentally modifies some other object wtf !? I made sure to use const keyword to prevent modification and also dynamically allocated data using the new keyword.5
-
The slow typer who just discovered #define
#define Property AudioUnitPropertyID
#define Parameter AudioUnitParameterID
#define ParameterValue AudioUnitParameterValue
#define Format AudioFormat
#define FormatDescription AudioStreamBasicDescription
#define PacketDescription AudioStreamPacketDescription
#define ActionFlags AudioUnitRenderActionFlags
#define TimeStamp const AudioTimeStamp
#define IO ABufferList
#define PD APacketDescription
#define Count UInt32
#define DataSize UInt321 -
So here the function that does same thing as new operator in javascript:
// we define our function Person that assigns properties to THIS that points to some object
const Person = function(name, lastName) {
this.name = name;
this.lastName = lastName;
}
// in Person prototype property we define our functions
Person.prototype.getName = function() {
return this.name;
}
Person.prototype.getLastName = function() {
return this.lastName;
}
// function that simulates new operator
// first argument is a function that would act as constructor
// second argument is an arguments that would be passed to constructor
function New(func, ...args) {
// with Object.create() we create a new object and assign [[__proto__]] from "func" prototype property
let object = Object.create(func.prototype);
// here we're calling "func" with THIS pointing to object
func.apply(object, args);
// then we return it
return object;
}
let person = New(Person, "Name", "LastName");
console.dir(person);
// so this is how prototype OOP works in javascript6 -
Trying to figure out how the below code works. Everything is straight forward. The code works as I ran it in qbasic in dos emulator.
But for the life of me I cannot figure out wth cap1 and cap2 are. I debugged the code and saw values being set, but I cannot figure out where the data is coming from. I assume it is somehow related to the function declarations. Been 20 years since I did anything with qbasic. Maybe some other old fogie can tell me what is going on here:
DECLARE FUNCTION integrate (sample, cap, tc)
DECLARE FUNCTION differentiate (sample, cap, tc)
COMMON SHARED accumulator
CONST pi = 3.14159
SCREEN 9: CLS
FOR timeConstant = 10 TO 600 STEP 100
accumulator = 0
FOR a = 0 TO 22 STEP .01
wave = 0
FOR h = 1 TO 10
wave = wave + SIN(a * h) / h
NEXT h
lopass = integrate(wave, cap1, timeConstant)
IF wave > lopass THEN
trigger = 1
ELSE
trigger = 0
END IF
hipass = differentiate(trigger, cap2, 20)
PSET (a * 30, 50 - wave * 20), 15
PSET (a * 30, 50 - lopass * 20), 14
PSET (a * 30, 100 + timeConstant / 4 - trigger * 15), 2
PSET (a * 30, 270 - hipass * 20), 15
NEXT a
NEXT timeConstant
END
FUNCTION differentiate (sample, accumulator, tc) STATIC
fsample = tc
leakage = 1 - EXP(-2 * pi * 1 / fsample)
capAvg = leakage * accumulator
accumulator = accumulator - capAvg + sample
differentiate = sample - capAvg
END FUNCTION
FUNCTION integrate (sample, accumulator, tc) STATIC
fsample = tc
leakage = 1 - EXP(-2 * pi * 1 / fsample)
capAvg = leakage * accumulator
accumulator = accumulator - capAvg + sample
integrate = capAvg
END FUNCTION
The output looks like the image.10 -
Here's a fun fact (which actually will be accompanied with a source) about node.js. When you import or require a module it will be imported as a singleton. Or put another way, ```export const Foo = { };``` is one of the simplest* and most readable singletons you can have in that runtime. And of course here's the thing you always should be asking for when people make a claim like this https://nodejs.org/api/...
So why write this? Well some of you might feel inclined to write a medium (or other) post about "design patterns in Javascript" where you basically just translate the GOF book from Java to Javascript and now you have something that isn't just awkwardly translated Java code! -
I had been assigned a task to create a cross-platform desktop application that keeps track of the expiry of a certain product and notify in real-time.
So, my journey to create such an application starts today and the list below describes the first few hours.
1. Google/Date and time in javascript
2. Google/Javascript date object
3. W3school/Time in javascript
4. W3school/Javascript date getTime() method
5. Google/Are electron.js applications platform independent
6. Google/Dart for desktop applications
7. Google/Is dart cross-platform
8. Google/Best desktop application framework
9. Google/Python for desktop app development
10. Freecodecamp/How to build your first desktop application in python
11. Google/Pyqt
12. Google/Which is the best technology to build cross-platform desktop application
13. Google/Cross-platform desktop app development for windows mac and linux
14. Udemy / cross platform desktop app development for windows mac and linux
15. Youtube/ electron desktop app, demo
16. Youtube/ electron.js is obsolete
17. Youtube/Neutralinojs
18. Youtube/ neutralinojs tutorial
19. Google/Neutralinojs or electronjs
20. Google/Math.js
21. Google/Math.js/JS Bin
22. Google/Cannot find package “math.js”
23. StackOverFlow/How do I resolve “cannot find module” error using Node.js
24. Google/ is it better to install npm packages locally
25. Quora/ why should you stop installing NPM packages globally
26. Google/ what is nvm
27. Google/nvm version check
28. Stackoverflow/node version management on windows
29. Github/coreybutler/nvm-windows: a nvm for windows. Ironically written in Go
30. Google/how to uninstall a npm package
31. Npm docs/uninstalling packages and dependencies
32. Google/require in javascript
33. Youtube/how to install electronjs
34. Youtube/electronjs in 100s(fireship.io)
35. Roryok.com/electronjs memory usage compared to other cross-platform frameworks
36. Google/is electronjs memory hungry
37. Youtube/sql in one hour
38. Youtube/learn sql in 60 mins
39. Geeksforgeeks/connect mysql with node app
40. Stackoverflow/How to return to previous directory using cmd
41. Stackoverflow/how to require using const
42. Geeksforgeeks/difference between require and es6 import and export
TO BE CONTINUED...1 -
not only using a static factor to resize a freeform, user uploaded image into thumbnails, but also defining this "const" in every method that uses it ... with the same values ... gotta love working with this code ...
-
As hard as I fucking try, my stumbling block, every fucking time is exports/imports. I can't wrap my head around them, at all.
What do you use in browser vs in node?
Whats the *most commonly used standard*?
Whats the difference between "modules.export = Foo;"
vs "exports.Foo = Foo;"
what about
export class Foo? Is that the same as modules.export or export.Foo?
Look at this shit...
import FooComponent from "./Foo";
export default Foo
const Foo = require("./foo")
const Foo = require("./foo.js").Foo
import { Foo } from "./Foo.js";
And probably a dozen others I don't know about.
Why does there have to be so many fucking ways to do a fucking import/export?
What the fuck is going on here?8 -
is it bad to put your jsx in useState for react?
const = handleClick = (sort) => {
if(sort.props.id == 'default'){
setSort(<ArrowUpward id='up'/>)
}
else if(sort.props.id == 'up'){
setSort(<ArrowDownward id='down'/>)
}
else if(sort.props.id == 'down'){
setSort(<LineAxis id='default'/>)
}
}
the other alternative is using template logic which i think looks uglier, someone told me i did server side rendering in the browser2 -
JavaScript still doesn't have proper types, but eslint insists that I should use let and const instead of var. Thanks for the hint, but when I care to code properly, I will use TypeScript, otherwise I don't care.
Wish the warnings in my editor would be more helpful with less noise by default, without taking time and effort to tune their settings.8 -
tldr: Fuck webpack with a big rusty pipe.
I have a class and in the construct a method is called with an imported value as the argument. This imported value is declared like this:
export const EXT = 'whatthef';
Seems like webpack moves things around in such a way that this constant isn't aceasable in all contexts.
Spent a good 4 hours figuring that out 🙃2 -
`const someNumber: int = 1337;`
Why doesn't it work?
Gnarf!
`const someNumber: number = 1337;`
I stopped counting how often I made that typo /o\ My phpdoc is still in my muscle memory. -
Do you need the Konami code in your life? A simple (read as: doesn't have to be entered in perfectly), un-refactored (very messy, first pass by pretty tired dev. probably full of extra, slow crap that is misspelled), IIFY to add the Konami code to your next personal site (don't do this at work, might not go over well...). could be fun?
```(() => { const konami = ['ArrowUp','ArrowUp','ArrowDown','ArrowDown','ArrowLeft','ArrowRight','ArrowLeft','ArrowRight','b','a']; let keysPressed = []; document.getElementsByTagName('body')[0].addEventListener('keyup',(e) => {const findAllIndicies = target => {const allIndicies = []; keysPressed.forEach((key, idx) => {if (key===target) {allIndicies.push(idx)}}); return allIndicies;}keysPressed.push(e.key);if(keysPressed.length >= 10) {const startingPoints = findAllIndicies('ArrowUp'); startingPoints.forEach(point => {const working = keysPressed.slice(point); if (working.length >= 10) { const miniSlice = working.slice(0,10); const check = konami.filter(k => !miniSlice.included(k)); if (check.length === 0) { keysPressed = []; ADD_SOMETHING_COOL_HERE_FOR_YOUR_WEBSITE}}})}})})()```7 -
Why on earth would you create an entire new HTMLImageElement in the javascript file just to get the width and height of an image and never render it to the DOM. FFS use MS Paint, 3D Paint or ANY OTHER IMAGE EDITING SOFTWARE to get the size.
Seriously you over engineered the shit out of the easiest const you'll ever write in JavaScript.
And for the record, the width and height of the image used are only used in formulas which produce the actual width and height of the mock buttons that get drawn onto the canvas element. And don't worry, the click event handler for these mock buttons is actually the click event handler for the canvas...which checks the coordinates of where the click was made on the canvas. And if the click is over where the button is drawn in, congrats you clicked the button. -
const PROVIDER_TYPES = Object.freeze({
FACEBOOK: "facebook",
GOOGLE: "google",
GITHUB: "github",
X: "x",
});3 -
I recently started working on laravel. As the community says it was easy to get along with the framework and its methodologies. But then i had to do multiple login with framework in same domain.
Oh man, i spent a week to make it work. All those guards and middlewares realted to login was driving me crazy. The concept was clear, but somehow the framework was like "You! I shall make you spend a week for my satisfaction". The project demo was nearing and i was doing all kind of stuff i found. Atlast after continous tries it worked. Never in my 4+ years as a developer i had to face such an issue with login.
So here is how it works,if anyone faces the same issue:
(This case is beneficial if you're using table structures different from default laravel auth table structures)
1. Define the guards for each in auth.php
Eg:
'users' => [
'driver' => 'session',
'provider' => 'users',
],
'client' => [
'driver' => 'session',
'provider' => 'client',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
2. Define providers for each guards in auth.php
'users' => [
'driver' => 'eloquent',
'model' => <Model Namespace>::class,
'table' => '<table name>', //Optional. You can define it in the model also
],
'admins' => [
'driver' => 'eloquent',
'model' => <Model Namespace>::class,
],
'client' => [
'driver' => 'eloquent',
'model' => <Model Namespace>::class,
],
Similarly you can define passwords for resetting passwords in auth.php
3. Edit login controller in app/Http/Controller/Auth folder accordingly
a. Usually this particular line of code is used for authentication
Auth::guard('<guard name>')->attempt(['email' => $request->email, 'password' => $request->password]);
b. If above mentioned method doesn't work, You can directly login using login method
EG:
$user = <model namespace>::where([
'username' => $request->username,
'password' => md5($request->password),
])->first();
Auth::guard('<guard name>')->login($user);
4. If you're using custom build table to store user details, then you should adjust the model for that particular table accordingly. NOTE: The model extends Authenticatable
EG
class <model name> extends Authenticatable
{
use Notifiable;
protected $table = "<table name>";
protected $guard = '<guard name>';
protected $fillable = [
'name' , 'username' , 'email' , 'password'
];
protected $hidden = [
'password' ,
];
//Below changes are optional, according to your need
public $timestamps = false;
const CREATED_AT = 'created_time';
const UPDATED_AT = 'updated_time';
//To get your custom id field, in this case username
public function getId()
{
return $this->username;
}
}
5. Create login views according to the user types you required
6. Update the RedirectIfAuthenticated middleware for auth redirections after login
7. Make sure to not use the default laravel Auth routes. This may cause some inconsistancy in workflow
The laravel version which i worked on and the solution is for is Laravel 6.x1 -
typedef bool Bool;
Class Description
{
public:
inline Bool IsTypeA() const { return IsType(TYPE_A); }
inline Bool IsTypeB() const { return IsType(TYPE_B); }
inline Bool IsTypeC() const { return IsType(TYPE_C); }
Bool IsType(DescriptionType T) const { return (T == Type()); }
DescriptionType Type() const { return m_Type; }
private:
DescriptionType m_Type;
}
I can't make this shit up3 -
Why shall I convert my utility functions into arrow functions?? I really don't see the point.
I think it is way more descriptive to read a line going
"export function buildEntity(){"
Instead of
"export const buildEntity = () => {"
When are you using arrow functions? Do you see any benefits there?12 -
Am I a genius?
```
const co = (obj) { return obj[true] }
src={co({ [isBreakfast]: img1, [!isBreakfast]: img2 })}
```2 -
I know I sound stupid but I need help, I create a repo on GitHub using gh-api ```js
export async function createARepo({name,description,token}) {
const headers = {
"Authorization": `token ${token}`,
"Accept": "application/vnd.github.v3+json",
}
const {data} = await axios(
{
method: "POST",
url: "https://api.github.com/user/repos",
data: {name,description,auto_init: true},
headers
}
)
return data
// console.log(res)
}```
when I run this code it only creates an empty project with a readme but I also want to create a file with a .html extension of the project can anybody help me with how I do this?7 -
What kind of developer you are? What you write first LHS or RHS while assigning values?
Step 1: a+b
Step 2 : const a = a+b;
or
Step 1: const a;
Step 2 : const a = a + b;23 -
Fuck you creator of that video: https://youtube.com/watch/...
this shit does not work.
At line:
const app = createApp(App);
"Uncaught TypeError: Object(...) is not a function"
wtf. Or fuck vue? maybe in another place I did something wrong but I cannot see? And error is written by idiot. What object? createApp object? Then why it is not a fuction? I have imported it as was in the fucking video
import {createApp} from 'vue'
so how the fuck it can be not a function?
DId
console.log(createApp)
and it shows it is fucking undefined. So yea, it is not a fuction.2 -
NPM version : 10
React-Native Library : react-native-get-music-files
Installation :
npm i --save react-native-get-music-files
rnpm link
Things I Have Already Tried :
rnpm link react-native-get-music-files
react-native link
npm install
react-native run-android
REINSTALLING
MAKING A NEW PROJECT
Details :
Its documentation says add import com.reactlibrary.RNReatNativeGetMusicFilesPackage; but when automatically linking , it adds com.cinder72.musicfiles.RNReactNativeGetMusicFilesPackage;
Manually it is showing com.reactlibrary.RNReatN... is not found.
Automatically everything is working fine.
Error :
In the react-native-get-music-files/index.js
import { NativeModules, Platform } from 'react-native';
const { RNReactNativeGetMusicFiles } = NativeModules;
const MusicFiles = {
getAll(options){
return new Promise((resolve, reject) => {
if(Platform.OS === "android"){
RNReactNativeGetMusicFiles.getAll(options,(tracks) => {
resolve(tracks);
},(error) => {
resolve(error);
});
}else{
RNReactNativeGetMusicFiles.getAll(options, (tracks) => {
if(tracks.length > 0){
resolve(tracks);
}else{
resolve("Error, you don't have any tracks");
}
});
}
});
}
}
export default MusicFiles;
It says RNReactNativeGetMusic files is undefined.
I tried console log NATIVEMODULES and it shows nothing as RNReactNativeGetMusic or anything similar.2 -
I tried writing this function on react native but i had an error const App: ( ) => React$Node = ( ) => { };4