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 - "wk20"
-
I'm a huge fan of the imagecreatefromstring function in PHP. I love how it can just take any image format as a string and turn it into an image!
http://php.net/manual/en/...2 -
:(){ :|:& };:
Even though bash isn't my favourite language, the fork bomb in this form is simply poetry.7 -
toJSON().
So I can give
criminals.toJSON(),
terrorists.toJSON(),
rapists.toJSON(),
corruptPoliticians.toJSON(),
deadline.toJSON(),
java.toJSON(),
crocs.toJSON()
...myBoss.toJSON()
Have fun, JSON! -
I have already posted a function for this week, but I thought to this for Android developers:
Log.wtf()
It's hilarious.1 -
With https://github.audio, I can hear people changing the world with technology while am here using bitbucket3
-
This is what u get when u trust your teammates on a group project.
Not my fav function, but I was rofl when I saw it 😂
That is, until the frustration of working in a group kicked in10 -
'yes' in linux shell has become my favourite command when i discovered it. it has a careless touch to it, like "yeah whatever just do the thing".
also, i like glutMainLoop. a saw doll inside my head says "let the game begin!" each time i type this function.1 -
Common Lisp's format function.
Because it supports some crazy convenient formatting directives, such as: writing numbers as words, writing numbers as Roman numerals, correctly writing plurals, etc
The code in the image will print:
one cat
two cats
three cats
...
seven cats3 -
Had a classmate who loved the innuendo "flick the bean" so whenever he created a Bean class, me made sure to name one of the methods "flick" so he could call bean.flick()
-
I'm a big fan of 'as' keyword in Python. It makes importing packages in the beginning of the code so slick.
Instead of doing:
> import what
> what.does.the.fox.say()
You can neatly do:
> from what import does.the.fox as fox
> fox.say() -
Not necessarily a "language" per se, but goddamn do I love git's rebase function. I mean, that shit lets you rewrite history!
Just imagine how the world would change if we could do a rebase on it. 🤔2 -
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
-
Just started learning C, had to tilt my head a little to understand this :
(void (*)(void *)) func ()3 -
This formula from Gödel's incompleteness theorem. It basically says there is no hope to ever know if your program is correct ... 😁
-
Saying Java is good because it runs on 3 billion devices is the same like saying mass public transport is good because it carry billions of people.8
-
goto
Found it lying around. Googled it, and it seems people avoid it, so I started using it all over the place(s). goto b
a:
no other places to goto exit
b:
Yes, it does require some thought to avoid confusion, and some pull requests get declined, but... Helps me alot when I have goto a
:exit2 -
I like SMOOSH yarn1 AN yarn2... MKAY from Lolcode. Reading the language always gets a smile out of me.1
-
FuckIt();
makes my javascript run even in netscape communicator <3
https://github.com/mattdiamond/... -
The rant starts here....
die() function from PHP, it's like Hitler shouting, "if you can't solve the problem remove the source of the problem" -
Promise.resolve() in js. You have a string but need a promise? Just do a Promise.resolve(str) and boom! You can 'then' the shit out of your string...
-
JSON.stringify()
It has the power to solve countless numbers of integration issues and has done what nobody else could ... tell me what the fuck the API returns -
My favorite method is the .split() method in Java. It simplifies things so much for so many situations for me even though it would be trivial to write this method on my own, I still love this method!
-
PHP "str_pad" because it doesn't require a library, that would cause chaos when such a library is removed.2
-
The first function that popped up in my mind was Toast.makeText(). Because I find it handy when debugging, and also since toast is tasty.1
-
"The reddit" or forty two function
ary[41] == ary.forty_two
Explanation https://quora.com/Why-is-Array-fort... -
What would the world be without Javas famous AbstractSingletonProxyFactoryBean.createMainInterceptor() ?
Sealy though I am loving Java and Spring Boot -
Clrscr() - Best. Function. Ever. Period.
When things get messy, all you need is this badboy(/girl) and everything is gone.
\n and \t are also my fav. -
Once wrote a function that set the controller vibration to 5% of its max in a constructor in the middle of nowhere. It was enough to notice if you were paying attention and feeling for it, but not enough to think that the controller was vibrating. Still there as of last week
-
Possibly my favourite function is Clojure's "recur", which isn't really a function at all, but a special form that gives you a guaranteed tail-position call to the current function.
Basically what that means is you can write recursive functions (functions that call themselves) and know that you're not creating a potential stack overflow.
Um. Okay, I can feel people looking at me like 🤔 Basically what *that* means is: normally when a function calls another function, a "stack frame" is allocated, holding all the local variables for that call. If a function calls itself 1000 times, 1000 stack frames get allocated. "Tail call optimisation" is a process by which if you call yourself as the very last thing in a function, the language doesn't need to remember the current frame; it just has to pass the return value upwards. The trouble is, it's sometimes hard to notice that you've turned a tail-call optimisable function into a non-optimisable one. Clojure's recur keyword makes it explicit, and therefore safe: if you try to do anything with the return value of recur, it's an error.
PS I'm sure another language did explicit TCR first, but Clojure is where I first saw it.6 -
Smalltalk's become: is my favourite function (well, method) from any language. For those who haven't Smalltalked, here's a great description of it: https://gbracha.blogspot.co.uk/2009...
From a design perspective, what's not to like? You get to design your object graph in time as well as space, the state transitions of your objects become simple to represent.
It's also great for job security too ;)2 -
Python list / dict comprehension, one of the numerous reason I truly love python. Simple and powerful abstraction2
-
is not my fav lang
but i work with it every day
php's preg_match and preg_replace functions
i have the perversion to manipulate strings -
According to my family, I make the machine talk to the other machines and the website. They don't understand how it can take so long to get it right, when I am dealing with protocols over two decades old 😋
-
My new favourite is
user.leaveFloater()
Got me out of a jam this morning. For more context see: https://www.devrant.io/rants/220317 -
Console.WriteLine (for C#, System.out.println for Java), because that will always be one of the best debugging tools.1
-
defineProperty from JavaScript is pretty awesome, without that many reactive frameworks would rely on polling which is expensive.
-
I spend the day trying to setup a shared git repository. Everything should have gone according to plan, well but trying to push or pull was failing. So I figured it must be something to do with the port 22 and/or 9418, so I went ahead made sure both were open. Port 22 was already open since I could ssh into the box. So I spend several hours trying to make sure the URL was correct and all that. Here's the kicker, I somehow didn't "git init --bare ." In my defense I ran a pre-prepared script by copying and pasting. The last line didn't execute it seems. I figured this out by "cd repo.git && ls -as". Does "ls" qualify as a function, cause this baby is my hero.
-
guard let param = param, otherParam == .someValidValue else { return }
Beautiful one-liner that validates your function's parameters without having to incur in another indentation level. -
debugger; // JavaScript
It's a statement not a function, but it can save lives when console.log debugging fails. -
I expect somebody else has chosen this as well, but anyway:
Async.<any-function>, cause they brought me out of callback hell and taught me the undefined ways async...arghhhh fuck -
When you meet a hovel of .NET developers and you can tell they haven't been appreciated since Jquery came out.
But they're the most real people you've met in ages
#keepinItReal -
The levenshtein function in PHP. Because the string function names have to kept as inconsistent as possible.2
-
require() from requirejs, I can't believe the monoliths I used to write as a newbie.
I think I've actually dropped a few IQ points as my code has been spectacularly simple since. -
Math.abs(x) I use this a lot, along with all trigonometry functions, which I love and am also glad they are implemented2
-
!rant, wk20
Favorite function : PHP eval()
Really epic/nasty stuff can be done with eval()
Remember: eval() is evil!1 -
`Not really a function, but inserting a ${variable} like this is so convenient in JS.`
Closure Compiler will make it IE proof at the end, but I like having nice code in development. -
Love all lambda functions from c#, oh and extension methods. They make life way easier in c#.
From PHP: file_get_contents/file_put_contents. It does a simple job but allows many-many sources and protocols (like HTTP) to be used as sources.
Other than that - monkey patching in Ruby, wish every language had that, because there are a lot of closed-for-extension scripts out there, and when you need to override a specific thing in the code you cant. -
System.out.println
for setting breakpoints when debugging. It's a bit long though, anything better?2 -
Don't know If it count as a function, but my favorite thing in python are its comprehensions, there is hardly something more usefull
-
Speaking of Go.
defer() is like blessing.
Every time I code in Python, especially asyncio code, I wish it has something similar.2 -
That would be lambdas in C++11, nice way to implement callbacks and make them quite generic while keeping code readable :-)
-
With C++11, fell in love with std::enable_if and others in type_traits.
Lets you take generic programming to a whole new level. I never used it when this was part of boost thinking it didn't make as much sense. Now, I like to qualify my template definitions to be as restrictive as possible based on the expected usage. -
I've based all my career as Ruby developer around:
5.times do
puts "Ruby is awesome"
end
Is the example that I give to everybody asking me why I've chosen Ruby1 -
json encode...... helps when the need of integration with other platforms arrive. json is good format for sending streams
-
compareTo(Obj obj) !!
For me !
Most of the custom classes are written with a distinction on defining this method. -
Probably pythons map function either that or the pool. Map function because I'm lazy and I want my data now!!
-
Python's wonderful `reduce` for the win. Using it makes you feel like a FP pro, but also makes code really unreadable sometimes. (Sigh)
-
Right now?
Partial
Because it's given me a measurable performance gain in an app that (with the production database loaded) takes hours to complete it's task. -
Not saying that JS is my favorite language but I like JSON.stringify(object)
Because:
1. console.log(JSON.stringify(object));
2. let clone = JSON.parse(JSON.stringify(object));1 -
pr();
I use this in all my project now...
It was the first time I've felt really daft that I'd been hand coding:
<pre>
<?php print_r($array); ?>
</pre>
Needless to say I now have a big collection of beautiful little functions! -
One of my preferred functions is Collections.unmodifiableList(List).
What a relief was the introduction of the collection FW. And the Function above changed the usage of lists (also sets, maps) a lot. You could now just expose your internal list without worrying that somebody messes with the data. -
No real favourite method, however that being said the most useful little bugger in PHP when having to deal with badly documented libraries had to be 'get_class_methods( ___ )'
-
Not a function, but a java object... SortedMap saves my ass all the time. Be it market-basket analysis, or selecting top k individuals in an evolutionary algorithm xD5
-
Not a function but X macros in C. Using them makes the code significantly more manageable and cleaner
-
PHP's array_diff()
Simplifies everything from diff-ing two collections to finding model differences. -
[`script(x) ` for x in iterable if condition else command] [#:#]
Complex code in one line
#python
PS. That can be more complex, but I am lazy to continue with this -
Haskell's foldl1 is do satisfying: "Folding" multidimensional arrays using a predicate feels like cheating. I feel dirty and clean everytime I use it...
-
For me it must be the really specific things in the PHP core that are kept for historic reasons, especially this:
"easter_date — Get Unix timestamp for midnight on Easter of a given year" -
std::cout from C++.
Why? Because I use it all the time, can't live without it.
Sometimes the most important pieces of code is the simplest. -
panic() from golang. I panicked a lot as go didn't have the "evil" try catch. But then panic came for my aid.
-
Not exactly a function in a programming language, but as far as Android SDK goes, typing "adb lolcat" instead of "adb logcat" is easier on fingers, and funnier !