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 - "function"
-
Interviewing a junior dev.
> Make this function return false.
> junior: deleted all code in function replaces it with return false;
Literally no words.........20 -
Manager: This code you wrote violates the single responsibility principle!!
Dev: How so?
Manager: You have one function that you call in *MULTIPLE* places. That’s too much responsibility for one function! Functions should only have one responsibility!! Creeping the scope of a function beyond that is a TERRIBLE way to write code!
Dev: But why spin up multiple functions that all perform the same thing?
Manager: Well if a function has a bug in it and you use that function multiple places then that bug exists everywhere you use that function. If a function only has one responsibility then if it has a bug that bug will only exist in the single place it is called! You really should think first before asking questions like that.
Dev: …26 -
*Reads dokumentation*
"Function A returns a float, see Function B for more information."
- Alright! *Scroll*
"Function B returns a float, see Function A for more information."7 -
New JS arrow functions:
⇶ (“the gun rack”) – executes three times
↝ (“wiggly boi”) – finds the least efficient solution possible
⟳ (“the self-monch”) – executes forever
⍆ (“🤷”) – adds random side effects
⍅ (“the total and complete s**t”) – undoes the only useful and expected part of its execution
Absolutely hilarious 😆
https://medium.com/@Heydon/...3 -
Got assigned to fix a bug in a validation function that would always return true even if the data is invalid.
I looked at the code from the function and noticed that the only line of code in the function was "return true;"
Apparently, the programmer who wrote this function a few years ago got fired and no one ever finished his work.
Now it amazes me that no one ever has looked at the problem and just assumed it would be a complicated bug.7 -
Just spent 30 minutes trying to figure out why a function wasn't working when I realized I hadn't called it. This is what happens when I forget my coffee.
-
WTF your function takes in 12 parameters!!! Then it checks one and pass the rest to another function!!12
-
While implementing a new feature I got “error in function A”.
I spent one day trying to figure out what was wrong.
At the end I found that someone copy/paste “function A” debug comments in “function B”.
I almost went to jail.4 -
Scratching my head for an hour because a function wasn't being called. Checked my backend server and all the logs.
Then I realised I commented out the function call. 😠😭😭😞4 -
Function definition in various programming languages
//JavaScript/PHP
function myfunc()
{
}
//Swift
func myfunc()
{
}
//Kotlin
fun myfunc()
{
}
//Rust
fn myfunc()
{
}
//Next...
f myfunc()
{
}25 -
React-Redux's connect() function inspired me to create the coolest way to add numbers in JS:
<script>
function add(num) {
return function(otherNum) {
return num + otherNum
};
};
console.log( add(2)(3) ); // Outputs 5
</script>
I didn't know you could do that. Just found it out!12 -
Why the hell would someone name their function printSomething?
I literally just got a message from an old Sololearn user needing help with yet another thing.
The moment I saw that function name was the moment I logged out. Stop using shit function names.21 -
We are currently doing procedural programming in an OOP language. "Only write code inside the main function" Here, have my bubble-sort function in your face.2
-
// I can't be the only one...
public static void p(String inpt) {
System.out.println(inpt);
}
...
p("That much typing is unjustified.");13 -
define every function like this:
def function ( arg ) :
instead of
def function(arg):
bit of a nitpick I know. but when I asked her about it she said "convention" and when I asked which convention she replied with "the only one in existence"
so I was triggered by that for sure28 -
My first year of computer science.
Programming exam
1) we had to write c++ code on PAPER in 2013
2) I couldn't remember how the string comparison function worked so I asked the professor if he could tell me what the function gave as output. He said he could not 😡 i wrote the comparison function by hand
It's 2018 and I'm still mad about it12 -
About 18 months ago my non-technical Manager of Applications Development asked me to do the technical interviews for a .NET web developer position that needed to be filled. Because I don't believe in white board interviewing (that's another rant), but I do need to see if the prospective dev can actually code, for the initial interview I prepare a couple of coding problems on paper and ask that they solve them using any language or pseudo code they want. I tell them that after they're done we'll discuss their thought process. While they work the other interviewing dev and I silently do our own stuff.
About half way through the first round of technical interviews the aforementioned manager insisted we interview a dev from his previous company. This guy was top notch. Excellent. Will fit right in.
The manager's applicant comes in to interview and after some initial questions about his resume and experience I give him the first programming problem: a straightforward fizzbuzz (http://wiki.c2.com/?FizzBuzzTest). He looked as if the gamesters of Triskelion had dropped him into the arena. He demurs. Comments on the unexpectedness of the request. Explains that he has a little book he usually refers to to help him with such problems (can't make this stuff up). I again offer that he could use any language or pseudo code. We just want to see how he thinks. He decides he will do the fizzbuzz problem in SQL. My co-interviewer and I are surprised at this choice, but recover quickly and tell him to go ahead. Twenty minutes later he hands me a blank piece of paper. Of the 18 or so candidates we interview, he is the only one who cannot write a single line of code or pseudo code.
I receive an email from this applicant a couple of weeks after his interview. He has given the fizzbuzz problem some more thought. He writes that it occurs to him that the code could be placed into a function. That is the culmination of his cogitation over two weeks. We shake our heads and shortly thereafter attend the scheduled meeting to discuss the applicants.
At the meeting the manager asks about his former co-worker. I inartfully, though accurately, tell him that his candidate does not know how to code. He calls me irrational. After the requisite shocked silence of five people not knowing how to respond to this outburst we all sing Kumbaya and elect to hire someone else.
Interviews are fraught for both sides of the table. I use Fizzbuzz because if the applicant knows how to code it's an early win in the process and we all need that. And if the applicant can't solve it, cut bait and go home.
Fizzbuzz. Best. Interview. Question. Ever.6 -
There are two types of coders: those who shorten function to fun, and those who shorten function to func.17
-
When you search rbf on Google for radial basis function(for data mining) and it answers with 'R'esting 'B'itch 'F'ace!
-
12:30pm - I can't code any more, what does this function even do?
12:45pm - What's a function?
12:59pm - I still don't know what a function is
01:00pm - *Eats Lunch*
01:05pm - My code makes perfect sense6 -
Guy needs to read some excel data...
Decides to write his function like this:
function readCell(){
fopen('filename.csv');
//some more code
fclose();
return cellValue;
}
This function was called multiple times per row of data...
Multiple hundreds of rows...
WHY5 -
Pass by reference, do not wrap needlessly
// Bad
takesCallback(function (data) {
// Literally all this function does
processData(data)
}
// Good
takesCallback(processData)
I see this all the time, especially with jr devs.8 -
Intern: "Hey Awlex, this function I'm using doesn't work. Can you help me?"
Me: "This function doesn't do what you are expecting. Did you even look at the docs for this function?"
Intern: "No."
Me: "... then start with that"11 -
So I've got a recursive function that calls a recursive function that has a nested recursive function inside it.2
-
I just wrote this stub function for my test and thought it was a bit ridiculous and had to share.
A function that returns a function that returns an object with just one function6 -
Am I the only one who doesn't judge a programmers contributions by commits or change history?
Frequently I'm always near the bottom of contributors, because I don't make a million commits when it's broken. And I don't commit lines that will likely disappear in later commits. I like to finish a function, test it, check it, rework, and then make a "made function()" commit, as apposed to:
"Wrote function()"
"Wrote unit tests for function()"
"Fixed error"
"Code cleanup"
"Style guide compliance"
"Reworked function()"
etc.
Sorry that I keep my commit history clean and ensure it builds.7 -
I’m new to C# and Visual Studio gave me an option to change the way I wrote the main function.
It gave me this.
Does this remind you of fat arrow function in JavaScript?7 -
Look honey! I optimized the code in such a way only a few lines are needed, I'm so happy with this efficiency. Her reply: "Ooooh, that's nice!! <blankstare>". Yeah, uh, we'll talk later.8
-
When I realize that the incredible smart function I just programmed already exists
Credit: http://thecodinglove.com/post/...4 -
I have a co-worker who negative-indents his function bodies. Minus four spaces. Every function. Not an IDE thing either, he does it intentionally.
I've never seen anything like it.9 -
God damnit!
i recently inspected the c# sourcecode of a webservice, our webservice develop references to.
As i discovered a particular function in it, my face went instantly pale.
This golden-hammer function consists of ~2000 lines of code.
In the first line there is "try {".
On the last lines is "catch (Exception e) { throw new SomethingWentWrongException ("special function"); }"
At least, he "tried" xD
I don't want to develop on that planet anymore...7 -
Syntax for my proposed "unsure" programming language.
Variable declaration:
let's just say that <variable name> = <value>
Function declaration:
hypothetically, we could <function name> (<args>){}
Try/ catch:
it's possible that
{
}
...or not (<ex>)
{
}3 -
You know what?
No you don't!
PHP decided 'in time memorial' to deprecate their 'split' function for another function called 'explode' that splits, oh sorry, that explodes a string.
Now you know something!8 -
Found this on Quora today :
Programming isn't sexy at all. In a club, try picking up a girl by telling her your heroic tale of saving an entire department by rewriting a recursive function to take advantage of a feature in the new server Intel chips to scale up their online orders.
Then tell me how it goes.4 -
I love Test-Driven Development!
And because of that fact, my heart shatters into thousands of pieces, when I recognize error events on our production nodes which are pointing onto a golden hammer function in a legacy project.
This particular function has about 300 lines with a bunch of subfunction calls and instantiations of helper-classes returning information for workflow.
Refactoring this code to apply proper unit-tests requires a way bigger investment than simply deal with 30 eventlogs a day, because this kind of payment is barely used by customers of our webshop.
This fact is a little itch each day of my work.
Guess it will make me go insane one day
¯\_(ツ)_/¯
xD1 -
That felling when you can't find the name of an function but you can remember the name of a similar function in another language.3
-
Few days ago I wrote function that finds occurrence of value in array:
function findOccurrence(value, array) {
for (var i = 0; i < array.length; i++) {
if (value === array[I]) return true;
}
return false;
}
But there's already [].includes() function in JavaScript.5 -
Have you noticed that many core Linux C programs use "die" as the error-and-exit method name?
Just shows how much these devs think of Linux processes as living people.
Now one of us just has to create a Skynet without the die() function.1 -
Python is GREAT 😊😊
makes you feel happy (😊) when fix a datetime problem just in 14 lines...
(36 lines in javascript ☺️)13 -
Friend: PHP is trash.
Me: PHP is the most beautiful thing men created. And you're trash.
Friend: it's function(){
}
Me: it's
function()
{
}18 -
Hundreds of PHP files with same name and _# at the end to differentiate them - each containing hundreds of
$(document).ready(function() {
$(some_slector).on(some_event, function() {
//one line of code
}
}1 -
It might be a stupid question, but:
Do the full-stack devs of you actually have that function in the job contract or does it just say "(junior/senior) software developer"?
Mine says just "Software Developer" and in my opinion it sounds just too generic and undervalued for what I'm actually doing...22 -
Function bool NewSpeedTestingStandard()
{
AskUserToLoadAPage();
return UserUsesPhoneWhileLoad()
? "Fail" : "Pass";
}8 -
Started learning Javascript. Came across many weird things. Like 'this' refers to the object in which the function is but when it is used inside a function which is inside another function it starts referring to the Global Object???Seriously?? I don't get it😕😵😢
But still I am starting to love Javascript along with its weird parts😁2 -
function Life(crap):void
{
crap = Lemons;
Return crap;
}
function Solution(liquid)
{
liquid = Tequila;
Return liquid;
}
function whatYaGonnaDo():void
{
Life = null;
Liquid = null;
life (Life);
if (life="Lemons")
{
solution(liquid);
}
}
//sorry i was bored. (not sorry)4 -
did you know, that in PHP, you can do:
if ( ! function_exists('function_name'))
{
function function_name()
{
//code of the function
}
}
which apparently means you can do
if($var == 'something'){
function functionName(){
//some code
}
} else if($var == 'something else'){
function functionName(){
//some completely different code
}
}
so now, apparently:
1. before this code executes, the function doesn't exist at all (okay, i can live with that)
2. after this code executes, any call to that function can result in any of those two completely different bodies of the same-name function executing, depending on what the $var was set at that time?
...so... now not only the same call to the same(name) function can do two completely different things, *but if you change the value of $var afterwards, you can't even properly find out which version of that function is in effect for the remainder of the run of the script*...?????
WHAT.
THE.
...i mean... I can't help but think that the idea of conditional function declaration like this is... kind of cool (have I been warped by JavaScript too much?), but at the same time... WHAT THE FUCK.18 -
I've made the json protocol. It's a protocol containing only json. No http or anything.
To parse an json object from a stream, you need a function that returns the length of the first object/array of all your received data. The result of that function is to get the right chunk of the json to deserialize.
For such function, json needs to be parsed, so I wrote that function in C to be used with my C server and Python client. I finally implemented a C function into python function that has a real benefit / use case. Else you had to validate but by bit by the python json parser and that's slow while streaming. Some messages are quite big.
Advantage of this protocol is that it's full duplex.
I'm very happy!36 -
"Did you know that if you put two exclamation marks at the end of a function, server will prioritize that function and make it work faster?"3
-
Just 2 days spend on debuging a function !
Definition:
int func (int x, int y) {
...
}
Call :
int c = func (y, x);
I checked 1000 line for debuging this :-\
Plz remember that check your function args while debuging1 -
When you spend 20 min trying to find out why your function wasn't working in your angular2 app and find you put an extra t in your function name than what you were trying to call...
-
Feel free to make fun of me on this one.
> be me.
> Write a function that calls a second function to get a returned value and continue work.
> That second function always returns null no matter what changes are made.
> Spend half hour scratching head.
> That second function has this written at the end
return null;
//return $returnVal;
> fml.13 -
I'm mainly a Java guy but JS ability to pass a function has a parameter to another function makes me feel like god.5
-
I always use this quick redirect function on my projects:
function go($location){
header("location: ".$location);
}7 -
Just found this awesome function in the old commits.
def clean_cache():
'''
This function cleans the stored cache in every update. Make sure to call it before every feature addition.
'''
print 'Cache is cleared. '
return2 -
There is a function in this program I’m working on for getting related documents and a function for getting unrelated documents. I suppose if you call them both you get all the documents in the universe!
-
I'm trying to deploy an Azure Function via Visual Studio. VS gives me this error:
Publish has encountered an error.
Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details.
A diagnostic log has been written to the following location:
"C:\Users\myusername\AppData\Local\Temp\tmp16F8.tmp"
Let's check the log then!
"Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. "
Fucking piece of crap1 -
I once wrote a php function to convert newline in a textarea to br, never knew of the pre-built nl2br function!!
-
Comment banners, urgh! >:(
/******************************/
/* Initialize */
/******************************/
Write a FUNCTION you lazy piece of ****!2 -
This happened today... Not my finest hour...
$.ajax({
url: "someurl",
type: "GET",
success: function(data) {
//do something
},
error: function() {
console.log(error);
}
});
...
Browser Exception:
Error: "error" is not defined
FML1 -
just found a build in function in a certain framework.
that function has a parameter named
"fail_silently".
func(fail_silently=False)
made me laugh.
and my laugh function was like.
laugh_func(laugh_silently=False)
😆😁3 -
Big plays...
function collapseView(element){
/**
*it doesnt work at the first time, the function needs to be called again
*/
element.collapse();
element.collapse();
}
Literally copy and paste this code..1 -
Typescript: All of your javascript code is valid typescript
Installs Typescript
runs typescript
Typescript: line x in function y has an error
Checking the function for error and the code is fine
After wasting an hour comment out all the linez in function y
Run typescript
Typescript: you have an error on line x which is commented in function y
ERROR IN A COMMENTED LINE :(4 -
My former senior developer thought that including script tags for each JavaScript function you write is efficient. For example: contact function will have contact.js, vacancy function will have vacancy.js. FYI he doesn't merge them in production. What's more shocking was that my project manager thought was the same.
This also applies to CSS when using media queries.3 -
The signs as programming brackets
Scorpio, Aries, Sagittarius, Libra, Pisces, Cancer:
function () {
// code
}
Taurus, Virgo, Leo, Gemini, Aquarius, Capricorn:
function ()
{
// code
}
Ophiuchus:
function () { // code }9 -
This kind of stuff is what causes developer's to loss their mind. If you have to write a comment saying do not use a function, REMOVE IT!1
-
Just came across a function with a typo (this is in TypeScript) - let's call the function slightlyComplicaedName - see the typo? t is missing. Wanted to refactor the function name to fix the typo. Next thing I know, the project doesn't compile anymore. There was already a function called slightlyComplicatedName in that file and it was doing something completely different.
I get that naming is hard, but using typos to differentiate between functions seems too much :)2 -
function myLife(time){
if(time.current() < time.alarm1)
sleep();
if(time.current() = time.alarm1){
wakeUp();
if(tired || hungover){
snooze();
sleep();
} else{
getReady(speed.Normal);
goTo(work, speed.Normal);
doMyJob(function(){
goTo(home);
});
}
}
if(time.current() = time.alarm2){
wakeUp();
if(tired || hungover){
snooze();
sleep();
} else{
getReady(speed.Fast);
goTo(work, speed.Normal);
doMyJob(function(){
goTo(home);
});
}
}
if(time.current() >= time.alarm3){
wakeUp();
if(tired || hungover){
workFromHome();
} else{
goTo(work, speed.Fast);
doMyJob(function(){
goTo(home);
});
}
}
}3 -
On thursday i spent 5 hours on a function. It was about to include in production build which was due on friday.
On friday PM informed me that we are dropping this function from application. It will not be included in any build now. So just prepare the build without that function.
So, instead of commenting it out or make it hidden i deleted the source code for the function entirely.
Today morning it has been decided that we are including that function in our next build.
I am fucked. I am very bad Developer i guess.. i am laughing on my mistake. It will not happen again though.9 -
A recursive function walks into a bar and says to the bartender,”A recursive function walks into a bar and says to the bartender,”A recursive function walks into a bar and says to the bartender…..3
-
Here's my new function:
/**
* Output Debugging information and Die
*
* @return hopefully
*/
public function odd()
{
//stuff here
}
Hopefully, you don't have to ODD too much when you write code... like I have to do right now
fuck sakes1 -
*while writing a function, sees mistake in another function unrelated to the one I'm writing* eh, can't be bothered to fix that right now, I'll wait for someone to file a bug
-
when you're tryna create a function in C and u start typing "funct"... and then u realise it's "C" so u backspace your code of shame.
-
I hate the overuse of arrow function everywhere even for super long expression. that `function` should fit to them more comfortably .
writer of code should aware that it take three time more to read expiration with arrow function inside5 -
So, today I revisited my 5 months old code and was like "What? Did I really wrote this horrible code?" 😐️ 🙂️ 😃️🔫️
```js
setState((initVal) => {
initVal.food = 'burger';
return initVal;
});
```
The function above change its argument's value, which is terrible thing to do, since it will also change the original value passed to the function. A variable's value for example. Making it an impure function.6 -
worst documentation ever => Samsung TV app documentation.
it is so rare that you find a function that actually works. sometimes you find a description about the function but it is in korean language. -
@dfox, is there a "@everyone" sort of function that mentions everyone who commented on a particular rant?13
-
PHP is such an absolute shit.
`array_map` takes function first param, array second param
`array_walk`, which is similar for associate arrays, takes array first param, function second param
and at the same time, the function of `array_walk` takes parameters in `value, key` order
what the crazy fuck this is.2 -
Ok.. this is what happens every day..
Isn't it?
Bugs.foreach(function(bug){
tryToSolve(bug);
})
function tryToSolve(bug){
// try to solve the bug...
If(bug.solved){
Bugs.push(bug,bug,bug,bug,bug)
}
}2 -
A comment on a handler function that simply says //WTF IS THIS?!
this might be because the last line of the function is:
return @"CHUCK TESTA";1 -
function toCodeOrNotToCode() {
if (!isset($coffeeOrRedbull)) {
die('No work can be done');
} else {
return true;
}
}
// I don't drink Redbull daily4 -
Question PHP folks. Is it a standard to write:
public function hair()?
Writing only:
function hair() is just the same thing to the above. It will default to "public" hair right? 🤔 maybe just a PSR-2 standard or for readability? Thanks!3 -
I saw this piece of code, one of my colleagues at work wrote it.
The content in in the function also had 0 comments.
Sorry for posting this here co-worker but it sincerely bothered me.
// Delete all
function deleteAllFunction(){
...
}6 -
Client ask me today: what's the function of this function??
After along he realise how fool he sounded even though it was valid sentence. -
PyCharm's Warning: "Function name should be lowercase for PEP8 naming conventions."
Do Python developers not like camel case function names?4 -
'Undefined' is not a function
that moment at work when your boss asks you do something that has not been defined as your 'function' -
I wrote a complex function in my source code, Visual Studio stop working and i lost the function. I'm so furios!!!!7
-
Boss comes, asks that I make a function in the site. Tell him it's impossible / forbidden, he says okay and goes back. Comes back a week later, asks for the exact same function he asked earlier.
-
Today I saw a 200-line function named Apply and a 200-line function with different code, but does the same, named TryAgain...1
-
HELP ME I used to conduct Java interviews for junior dev candidates, but since changing jobs three years ago, I've barely had to look at Java at all, and now I've forgotten everything.
Am I stuck in a never-ending loop of learning and relearning everything over and over again for eternity???8 -
Class components, although verbose at times, are still far superior than functional components in React. The more I work with React, the more I believe that: Hooks are plain shit.
-
Silly question: what is the main difference between a procedural programming paradigm and a functional paradigm?7
-
The ability to sudo kill all the idiots that point a deprecated function to another deprecated funtion that points to a deprecated function. Smh.
-
So if you’re awaiting a promise and the async function returning the promise calls another async function and doesn’t await it could this counterintuitively cause the whole thing to freeZe ?14
-
As a developer with adhd, some days are just wasted and ends with the brain getting stack overflow from to much unorganized code and infinite callbacks 😂
$brain = new adhdBrain;
while($brain.energy > 0) {
$brain->checkSocialMedia();
$brain->work();
$brain->readNews();
$brain->getAngryWithSoundsInTheOffice();
$brain.energy--;
}
public function work() {
$brain->getAngryWithSoundsInTheOffice();
$brain->readNews();
$brain->code();
$brain->readEmail();
$brain.energy--;
}
public function getAngryWithSoundsInTheOffice() {
$brain->readEmail();
$brain->angry++;
$brain.energy--;
}
public function readEmail() {
$brain->work();
$brain->readNews();
$brain.energy--;
}
public function readNews() {
$brain->work();
$brain->getAngryWithSoundsInTheOffice();
$brain.energy--;
} -
Making a function pointer in C and typedef-ing it.
Done wrong. Every single time.
Look up in the internet.
Copy a typdef-d function pointer.
It works.
Check it's syntax.
THE SAME FCKIN SYNTAX AS DONE FIRST!
And that's why I hate function pointers.2 -
Greetings my good people.
I'm currently making a Calculator app. Is there any suggestions you can give me.
I've already added, Square Root function, Factorial, Area of Circle, Volume of Cone, Decimal to Binary function, temperature convertor, and BMI function.8 -
An actual function definition spotted in a plugin to migrate a membership DB from a spreadsheet into Wordpress:
private function insert_member() { ... }1 -
Say the world's source code was opened for anyone to edit, which function would you change?
// js land
function conception(e) {
e.preventDefault();
return;
// original code here
}8 -
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 -
When I say "error in an async function" you say "no stack trace"!
"Error in an async function"!
"No stack trace"!
"No stack trace"!
"Error in an async function"!
"Unhandled promise rejection DEPRECATION WARNING Unhandled promise rejections will be shoved up your ass in node v7.coffee.9.10.666."3 -
Function works() {
Try {
HorriblyDyingCode();
Return true;
} catch (Exception e) {
Return false;
}
} -
What in the holy hell is a pointer to function and function pointer.I guess they have a purpose, I hate their existence. It's solely because it is complicated13
-
After the fun I had with the XEN Orchestrator UI ( https://devrant.com/rants/2554182/ ) I build an exporter that normalizes XEN / Proxmox API output and writes it into a nice spreadsheet.
Took PHP 7.4 for a spin. Sweet jesus, lot of nice stuff.
Been nearly a year since I did something larger than small scripts in PHP, but felt really at home again.
The type hinting and arrow functions made writing the exporter a breeze.
DTOs with typed properties spared me quite a bit of headache when normalizing the different APIs...
Utilizing *sort with fn arrow function is a pretty nice and concise one liner with the spaceship operator.
And I have now a nice spreadsheet...
Thanks at the PHP folks.1 -
*writes function*
*doesn't work*
*adds more shit to function*
*now can't think of what more you would need to add for it to work*
*changes random signs around for 30 minutes*4 -
I shall delay your PR with my giant egotistical scrotum by:
- Use less words for your function name
- Use this obscure pattern you have not learnt in your outdated compsci degree
- Each loop should get their own function
- Your function has too many parameters
- You must name every instance of magic numbers / strings
- Here, have another obscure test case to write9 -
When you go to create a function only to discover that you have already created that function with the same name you just thought of.... Am I in the matrix? 😯1
-
fuck php and fuck it's whitespace header not sent bullshit, apparently there a bazillion ways the header function may just refuse to work, all for a function javascript does way better13
-
Write a function that shows off a cool stuff about your favorite programming language
Me:
function coolstuff(){
echo "I can always google and reffer everything and stack overflow got my back";
}2 -
Today, I used a curry function for the first time outside the context of a classroom/assignment, to solve a real-world problem. boy do I love functional programming.
-
fyi: Neither getProductPrice, nor getProductPrice1 exist.
Btw why was it needed to create this alias function only for calling the other one.
Also, getProductPrice2 is 1.2 KLOC long. -
An utility function longer than 100 lines shouldn't even be a single function. Shit, it shouldn't even BE inside the "utils" file9
-
So basically after using arrow functions for 6 months I discovered just now that it also passes it's enclosing scope. The more you know7
-
new Promise(function (resolve, reject) {
self.getPaid(function (err, money) {
if(err) {
reject(err);
console.log("fml");
} else {
resolve(money);
console.log("fuck yeah!") ;
});
})
.then(resolve)
.catch(reject); -
>selects function to see output in console on chrome
>oh yes obj1 very good
>selects another function that does minor validation (return obj if it exists)
>ok alright
>what was that property from obj1 again?
>selects same function, breakpoint didnt move an inch
>obj2
>whatthefuck.jpg -
Just found this:
jQuery(document).ready(function($){$(window).load(function(){ /* do stuff here */ }
Nothing else?2 -
There's a function a previous employee wrote called isNullOrEmpty.
... It's a JavaScript function.
We're a .NET shop, if you couldn't guess. -
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 -
PLEASE. Help me to find a good name for my function.
My function returns json or XML based on the accept header parameter.
🤔🤔🤔🤔🤔10 -
Alright, WHO WROTE THIS:
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function putStore()
... This is in UserController.php. It's the function for creating new users. #smh1 -
Why in gods name does compiling for windows change the name of a function?? this is a function in *my* library and it doesn't have the text `erom_text` anywhere in the library???2
-
When you create a middleware function and title it gtfo // no comments need to explain this function
-
"Form follows function – that has been misunderstood. Form and function should be one, joined in a spiritual union. " - Frank Lloyd Wright
-
‘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 -
function stressBall(previousPost){
post = makePostAboutWinningStressBall(previousPost);
return stressBall (post);
}2 -
Way back in university, I was trying to do an assignment for an OOP class and it had to be written in C++. I was writing a simple function since I was a beginner at it and I couldn't understand why my program wasn't working. I spent an entire practical class lesson trying to work out what the hell was wrong and in the end, I got my friend to look at it. After only 2 minutes of looking, he asked if I had declared my functions. Obviously I had not.
-
What is the gist of a function point analysis of a mobile app? I need to do one and have 2 days to learn what it is
-
!rant
Maybe a usefull function for the fellow developers here, in case you need default Avatars for your users. "UI-Avatars". Just 'discovered' this beautiful API today and it really is easy and helpful! :D It even has a PHP package if you would like to generate them yourself.. This is not an ad or anything, it's just a usefull API, like 'placehold.it' etc that could be useful for anyone out there! -
JS ♥️
Wasted almost 2h on this, wondering why Chrome wasn't hitting the breakpoint:
$.ajax({
url: "/Controller/Endpoint",
type: "GET",
sucess: function(data) {
debug;
},
error: function(error) {
console.log(error);
}
});3 -
stop using arrow function everywhere!!!!!!!
what that is mean ?
fns.reduce( (prev, fn) => fn(prev), input)
Are this is `fns.reduce` with two parameters
Or arrow function that return `input` variable.
take your time to visual parsing this crap4 -
First, I propose an alternative to "form follows function": form follows *intent*
Second, the following article is absolutely worth reading if you are a designer of any sort:
https://borism.medium.com/forget-fo...4 -
Implemented a function to a Drupal syst3m to link to a reference page with preselected filters. After days of struggling I noticed that this function already exists. It already were implemented with one of our modules...
-
Rust noob Q:
Given x a variable on the heap, e.g.
let x = String::from("Hello, devRant!");
Then, given some function that I didn't write (from a library) that takes ownership of its argument:
fn some_function(y: String) -> bool { ... }
How would you handle this situation:
if some_function(x) {
another_function(x); // not ok, because x has gone out of scope in the line before
}
Is it idiomatic to just clone() x in the first call? That seems bad practice, because it's the second (or some other additional) call that needs x. What should I be doing instead?8 -
Built the most generic file importer.
So a customer had his SAP system giving us some 5 million barcodes in a csv which we needed to parse. But as there could be different file types and I thought the handling would always include the same steps I made them configurable through function pointers. - Did not want to make it as spooky as the rest of the code base where the function pointers were buried deep in some shared memory configs, which might even change at run time, but rather I statically used the member functions of my class. Just to poke fun on the ugly C++ syntax of member function pointers. I still shudder at the thought some poor soul now has to maintain that code.
(For the actual parsing I actually used a one liner in awk which was churning through the records in one minute which was faster than the SAP guys seemed to be accustomed to.) -
What is everyone's preferred formatting for functions/if statements. Does the first curly brace go on the same line or a new line?
function 1() {
}
or
function 2()
{
}14 -
My first function which I wrote 3 years ago..
Adding two numbers in JavaScript.
add = function ( a, b ) {
Return a + b;
}
What's yours ?22 -
Why the pointer of member function so special.
trying make a non-template class that like std::function but simpler:
1. wrap static function pointer.
2. wrap class member function pointer and the class object pointer.
3. WITHOUT ALLOCATE MEMORY.
I can't store member function pointer because the size is undefined?! -
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 -
Fuck javascript, pice of shit can't be learned without reading 50 shades of books and even SO solution don't work.
why for fuck sake there is no easy way to create module in another pice of shit vue js
And fuck devRant for not being able to paste images directly. I'm done! bullet in the head!
trial 1: is not a function
trial 2: is not a function
trial 3: is not a function
trial 4: is not a function
trial 5: is not a function
trial 6: is not a function
is not a function
is not a function
is not a function
is not a function6 -
I just found this in the code I'm working on:
function checkDateValidity() {
function checkDateValidity() {
...
}
}
Obviously a bad copy/paste. Not even sure how it was working before; it probably wasn't.1 -
Trying to write some JavaScript (still learning it)
Why does the fucking
(function() {
})();
not work for starting a function below it?
Or above... I tried to fiddle with it too much, I'm just gonna leave it for now18 -
Added new function to my Android app, tested for an hour. It was ok --> git push.
After some time the function doesn't work anymore... -
The levenshtein function in PHP. Because the string function names have to kept as inconsistent as possible.2
-
The difference in arrow function and traditional function? Yes. What? This is the difference. What?4
-
Colleague who removed a function saying "maybe it would make the layout look better", days later asked me how the function works. 😐
-
Does anybody else dislike paranthesis less function call in ruby?
> a = something
How do I understand 'something' is a variable or a function?8 -
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 -
How I create the function of delta? The function have to return to me the formula of this.
Obs: Javascript please :32 -
Probably pythons map function either that or the pool. Map function because I'm lazy and I want my data now!!
-
Learning ES6 arrow functions from Kyle Simpson's workshop video. Amazing how something that was designed to be a syntactic sugar turned out to be a code readability nightmare :(1
-
function pmAsksForMore(work) {
return iDoIt(work);
}
function iDoIt(work) {
return pmAsksForMore(work);
} -
The fact that pandas has a function called .isnull() to find nans, but the function to get rid of them is called .dropna(), will never stop bothering me.1
-
When people write functions/methods with bodies smaller that the call header (-_- ).
Function calls are not free people! Just Inline that shit manually (or at least make sure the compiler does so)!
double degree_to_radians(double degree){
....return (degree / 180.0) * M_PI;
}8 -
Rustfmt doesn't support inline function calls with a block last argument unless the last argument is an array literal or lambda. Dedicated support for arrays is obviously intended for XML-like trees where a factory takes a number of arguments and then a list of children, and the use cases for block last lambda argument don't need explanation, but what I don't get is how did no one catch on that this is a useful pattern that should perhaps be generalized? Why can't I produce the same behaviour for a function call in the last position.3
-
In JS/Node, is there a performance and memory cost to nested functions?
I.e.
function handle(req, res)
{
var x = 5, y = 10;
function add() { return x + y; }
function multi() { return x*y; }
res.send(add() + multi());
}
As opposed to taking out the 2 functions and making them accept x,y as parameters.6 -
Looking into some javascript. Which function should I use... guess I have to start the day refactoring. What the f*ck, is good naming so hard:
...
function removeColumn(column) {
selectedColumns.remove(column);
};
function columnRemove(column) {
appliedColumns.remove(column);
}; -
Hi
maybe a stupid question :) I have two Django apps, I need one of them to use the functions of the other one without importing them. as if I am requesting them using API, is there a way I can get an instance of a function and use it, I don't want to do the following:
response = requests.get('HTTP://URL/example/', data)
data = response.json()
I want instead to do something like this
function = requests.get('HTTP://URL/example/')
and execute the function as follows
data = function()
thanks4 -
So many years of web dev and I still google the "jQuery $" function every time...
(function (window, $, undefined) {
}(window, jQuery));4 -
!Rant
Add the function below to your .bashrc
function doGit() {
git add .
git commit -a -m ".."
git push
}
Next time just use doGit "bug fixes" ☺
What will you name your function?? -
tfw you're learning a new library and a function gives an error suggesting xyz in data. You assume you're using the function wrong. 5 hours later...turns out there is xyz in data ya big dummy!
-
There's two types of developer.
Type 1 :
def function() {
// code
}
Type 2 :
def function()
{
//code
}
So, which one are you? I won't judge if you're not type 1.4 -
Yes but you see this function everywhere so why is it so hard for us to implement?
Next time i’m gonna say that this function is everywhere, but why is it so difficult to design? -
When you want to investigate what a function does, you read the name and say "ok, seems reasonable what it should be doing" ... and then you encounter an adventure of if-else's, nested if's and else's, some promises here and there (with more nested if's and else's) and also a bunch of dispatches sprinkled all over the place. You want to refactor it into tinier functions but can't because you don't know what happens where ... help ... 🙄😩
-
Just realized a member function pointer can be a template parameter as non-type, gonna try to use it do no dynamic memory allocation trick with std::function.
-
I have a function that receives 2 parameters: a string and a max numer of characters.
It returns an array with the partitioned string.
Example:
function name("hi, I love devRant", 10);
//return:
array(2){
[0] ->"hi, I love"
[1] ->" devRant"
}
Now.... what would be the appropriate name for that function?10 -
Why doesn't Java have a functional interface that supports throwable exceptions?
Seems silly to have to define my own wrappers around the Function<> interface. -
I created a few helper functions in bash sometime ago, maybe someone might find it useful
https://github.com/zombieleet/... -
{
regular: function () { return this }, // ok
arrow: () => { return this } // you mean undefined?
}3