cuTile Rust provides a safe, tile-based kernel programming DSL for the Rust programming language. It features a safe host-side API for passing tensors to asynchronously executed kernel functions.
100 result(s) for “function”
🔡 Portable ASCII library - performance optimized (ascii) string functions for PHP.
In the last post we learned all about how scoping works with JavaScript let, const and var variables. We now know that var is function scope, and now we know that let and const are block scope, which means any time you’ve got a set of curly brackets you have block scope. N…
Hey Folks! React 16.3 has a new Context API which makes accessing data and functions anywhere in your application a snap. If you ever find yourself passing data down via props 4-5 levels deep, context might be what you are looking for. Enjoy! Code Examples available at https://g…
One feature that comes along with template literals, or template strings, is the ability to tag them. That means is that we can run a template string through a function, and rather than have the browser immediately assign that value to a variable, we can have control over how th…
ES6 has introduced arrow functions which have three main benefits. First, they have a concise syntax. Secondly, they have implicit returns, which allows us to write these nifty one-liners. Thirdly, they don’t rebind the value of this when you use a arrow function inside of…
Before you start going absolutely bananas on using arrow functions everywhere, we need to chat. Arrow functions don’t replace regular functions. Just like Flexbox and floats, pixels and rems and anything else new that comes along, the older thing still retains lots of util…
For decades MySQL has considered BLOB a sink for data junk that didn’t fit the strictly typed SQL bill. As the outside world began voting for JavaScript, JSON and key-value/key-document stores, TEXT/BLOB was rediscovered as the only way to store JSON inside MySQL. But havi…
Default function arguments in JavaScript are here. This is one of those features that’s going to make your life much easier, and make your code much more readable and maintainable. Let’s say we have a function called calculateBill which is going to take in three thin…
PHP has several built-in ways of serializing/unserializing data. The most cross-platform is json_encode; pretty much every programming stack can JSON decode data that has been encoded by any other stack. There's also PHP's native serialize function, which is not as cross-platfor…
I am currently participating in the Neo4j-Heroku Challenge. My entry is a -- as yet, unfinished -- beer rating and recommendation service called FrostyMug. All the major functionality is complete, except for the actual recommendations, which I am currently working on. I wanted t…
We’ve learned about the concise syntax of arrow functions. We’ve learned about the implicit return of arrow functions. The last thing we’re going to learn about and probably the most important is that the fact that this keyword does not get rebound. What does t…
Back in 2009 and 2010 I wrote about a PHPUnit patch I wrote to automatically verify parameter types in function calls. The feature never made it into PHPUnit and honestly it didn’t really fit into the feature set either. Although I still plan on releasing it as a PHPUnit e…
Whether it’s twisting a function or taking advantage of side effects and flexible language constructs, it’s no secret I occasionally take joy in writing bastard PHP code. The other day I was in an evil mood and used array_reduce() to construct an array. If you’re not familiar wi…
Довольно частой задачей на PHP является склонение слов, которые идут после какого-либо числа, например, 1 день, 2 дня, 5 дней или 1 раз, 2 раза, 5 раз или 1 год, 2 года, 5 лет. Данную задачу решить довольно легко, используя специальную функция и массив слов. function plural_type…
Read the full post on https://stitcher.io/blog/php-86-partial-function-application
Affected versions Symfony UX Icons versions >=2.17.0<2.36.1, >=3.0.0<3.2.0 are affected by this security issue. The issue has been fixed in Symfony UX Icons 2.36.1, 3.2.0. Description The ux_icon() Twig function is marked is_safe=['html'], so Twig never escapes its o…
A simple method to return the first weekdsay of a given month and year getFirstWeekdayInMonth private function _getFirstWeekdayInMonth($month, $year, $day = 1) { $dateData = getdate(mktime(null, null, null, $month, $day, $year)); if (in_array($dateData['wday'], range(1, 5))) { r…
I have two machines running Ubuntu 12.04. One of them is very stable. And hardly ever gets rebooted. The other machine is displaying some odd behavior every now and then. And with odd behavior i mean. It just completely freezing up. The only thing functioning at that moment is t…
PHP Internals News: Episode 89: Partial Function Applications Thursday, June 17th 2021, 09:17 BST London, UK In this episode of "PHP Internals News" I chat with Larry Garfield (Twitter) and Joe Watkins (Twitter, GitHub, Blog about the "Partial Function Applications" RFC. The RSS…
PHP Internals News: Episode 77: fsync: Buffers All The Way Down Thursday, February 25th 2021, 09:05 GMT London, UK In this episode of "PHP Internals News" I chat with David Gebler (GitHub) about his suggestion to add the fsync() function to PHP, as well as file and output buffer…
PHP Internals News: Episode 69: Short Functions Thursday, November 5th 2020, 09:32 GMT London, UK In this episode of "PHP Internals News" I talk with Larry Garfield (Twitter, Website, GitHub) about a new RFC that's he proposing related to Short Functions. The RSS feed for this p…
~ Early 2000s’ Pixel Perfection If you, like me, were building websites back in the early 2000s, you’ll undoubtedly remember the absolute headache that was cross-browser compatibility. What didn’t help back then in this era of Internet Explorer, Netscape, and Firefox was the stu…
At CSS Day, “YouTube guy” Kevin Powell showed a lot of demos that relied on the advanced attr() function. In one of the examples he used attr() to set view-transition-name values — a technique I covered in my article on advanced attr() function. But then during the Q&A, Cyd …
Screenshot of the View Transitions Toolkit homepage ~ In my work with View Transitions over the last several years, I’ve published everything from deep-dive articles, demos, and announcement videos at Google I/O. I’ve also done some more experimental things with it, such as opti…
This is a guest article by NK. You can view the original article Consistent hashing explained on systemdesign.one website. How does consistent hashing work? At a high level, consistent hashing performs the following operations: The output of the hash function is plac…
I am a long term tmux + neovim enthusiast, and for the last 10 or so years, I’ve been using vim-plug to manage my vim dependencies. I recently learned that very similar functionality was added to neovim core. The vim.pack interface provides a built-in package manager for vim plu…
by Pream Totaram I started to read about clean coding practices and started to wonder how they can apply to JavaScript where it is common to define a function within a function. What I started to think is, how could it be possible for a block of code to obey the Single Responsib…
User notifications are a feature that came as an afterthought, but turned out to be rather easy to implement - without touching (read: breaking) existing functionality - thanks to having an immutable event log. In the domain I’m working in at the moment, we will often give…
Visualizing some data earlier this week I had to compute the running total of a sequence of numbers. For example, if the input sequence was [ 100; 50; 25 ] the result of the computation would be a new sequence of [ 100; 150; 175 ]. Muscle memory made me take a procedural approac…
Coming from C#, I’m used to the compiler warning me about unused variables. Relying on the compiler to help me with checked exceptions in F#, I noticed that unused values (and functions) would go unnoticed. Having accidentally read earlier that Haskell has a compiler flag …
The previous post defined a basic set of data structures and functions to spin a wheel of fortune in F#. There was very little mystery to that implementation though. The physical wheel had four pockets and spinning the wheel would land you a win one out of four spins. As a casin…
In this post, I’ll define a basic set of data structures and functions to spin a wheel of fortune. In the next post, I’ll show you the simple model casinos use to build a bigger, more attractive pot, without touching the physical wheel and without losing money. Final…
@agiroLoki Show Notes php_trie extension Trie article Functional Programming in PHP Audio This episode is sponsored by RingCentral Developers The post Interview with Michael Lochemem appeared first on Voices of the ElePHPant.
@crell Show Notes Thinking Functionally in PHP PHP RFC: Pipe Operator v2 PHP RFC: Partial Function Application PHP RFC: PHP Namespace Policy Audio This episode is sponsored by RingCentral Developers The post Interview with Larry Garfield appeared first on Voices of the ElePHPant.
Quick one here but today, thanks to Tez on Stack Overflow, I discovered that PHP's null coalescing operator (the double question mark operator) can fail when you use a function at any part of the statement.
If you've ever written a test in golang, chances are you've used the testify package to make writing tests a breeze. An immensely useful extension of that is the mockery package, which gives you the ability to autogenerate testify mocks for interfaces with ease.
There's a bug with Eloquent's firstOrCreate() function where it doesn't work with the $casts attribute on the model; it will always either insert a new instance into the database or give a MySQL duplicate entry error.
The Jupyter notebooks for python-oracledb have been updated with the latest and greatest functionality to teach you how to use Python to connect to Oracle Database.The notebooks are at github.com/oracle/python-oracledb/tree/main/samples/notebooksPython-oracledb ResourcesPython-o…
Let’s look at a couple more JavaScript arrow function examples. This is something that comes up often where I’m building an application, and I don’t necessary have the data in the right format that I need. I’m building a website for a bunch of racers, whe…
I’m crying. Literally crying. Actual tears in my eyes. Salty. They sting. PHP is physically hurting me. All of these freaking ridiculous function names we’ve been stuck with for twenty years are because of a POORLY CHOSEN HASH FUNCTION ON A DATASET OF ONE HUNDRED SHORT STRINGS. …
isset — Determine if a variable is set and is not NULL We’re not even through the first sentence of this manual page and I am already wondering why we’re conflating two completely different definitions of a variable being “set” in one function. This funct…
Implementing powerful search functionality in Drupal requires more than the default search module. Search API provides flexible search capabilities with support for multiple backends, faceted filtering, and advanced content indexing. In the video above, you'll learn how to insta…
Today I want to share a quick tip for Symfony users ✌️. When you use the ExpressionLanguage component you get a context: some variables and some functions. Those functions are not the same everywhere.…
Stale While Revalidate (SWR) is a strategy to first return the data from the cache (stale), then send the fetch request (revalidate), and finally come up with the up-to-date data.
Spatie's Browsershot is a wonderful package that uses puppeteer to render a web page to transform it into an image or PDF. Having this functionality covered by tests generally requires you to install puppeteer in your CI environment and can slow down your tests a lot.
Over the past couple of years I’ve grown my interest in image and data compression — it’s a very interesting field, with a lot of interesting solutions to important and lucrative problems (think Dropbox). Over the past few days I was running some experiments an…
Privacy controls — systems that enforce retention, access, allowed-purpose, downstream-sharing, or anonymization policies — require a reliable understanding of data to function. Before such a control can operate effectively, it must know exactly what it is looking at. This can …
Laravel 13 starter kits have a new feature of Teams! In this 14-minute video, I will show exactly how it works, and how to create functionality with Eloquent models scoped by team.
At this point, I'll take a break from Faktory-focused functionality to address the shortcomings I raised at the end of the last part. Specifically, I...
ed: If you want to run the containers right now, jump ahead to How to Use the Images. For several months now I have been working on PuPHPet.com’s replacement. It is a Docker-based GUI functionally similar to PuPHPet. Docker, like Vagrant, allows sharing directories and files fro…
It turns out that Handlers provide a nice way to create a chain of HTTP middleware. There's more than one way to go about this, but they all use http.Handler. If you google it, you'll come across examples that have you nest function calls in a way that gets grim pretty quicly. f…
When we use Symfony's Console component to write CLI commands in PHP (and you should!), we're almost always writing any output to "stdout". There's a few ways to get general output from a CLI command using Console: // Run the command (Laravelish) public function fire()…
Functional Library: Null Tony Hoare famously described the invention of null references as a Billion Dollar Mistake. Nulls are something we need to deal with in almost any language. Any value that can be null must be null checked. An example of a very common error that will aris…
Functional Library: Traversal Traversing associative data structures in PHP is fun. Said no one ever. The problem is a common one if you’re processing any kind of data, for example a response from a JSON API. You need to access some nested structure, but you don’t know if what y…
Functional Library: Iteration Welcome to the functional library. This series will explore the state of functional programming in PHP and highlight some libraries for common tasks. This post will look at iteration and lazy operations based on a sequential abstraction. Sequence Ye…
S-expressions: Macros (sexpr lexer reader eval forms special-forms macros walker meta-eval) The interpreter is functioning, it is able to calculate the fibonacci sequence recursively. And probably almost anything else you would want to. So what is the next step? We have …
S-expressions: Forms (sexpr lexer reader eval forms special-forms macros walker meta-eval) The previous post introduced a basic implementation of evaluation that is lacking on many fronts. It currently only supports s-expressions which are function applications. The obje…
Introduction With modular programming, concerns are separated such that modules perform logically discrete functions, interacting through well-defined interfaces. The module / package concept is formally supported by wide range of programming languages but many of them support p…
Presenting concept of array operator which repacks array by keys to newly created array. I’ve called it Array Repacking because such functionality will produce new array based on original array just with some few improvements. Syntax Proposed syntax doesn’t break any…
Following the raging success of PHP 7.0 additions scalar type hints and return types, there is also place for object typehint and return type. That feature can replace double is_object() validation inside function/method. I decided to write an RFC:Object-typehint. Why do we need…
I realized that I am very strict about the use of PHPs empty function in code review. There isn't really any reason to use it in my opinion: it tests both for the existance and the non-falsy value and as a reader the writers intent is not clear. it does not communicate what type…
Security considerations when parsing user-provided INI strings and files using `parse_ini_string` and `parse_ini_file` functions.
Read about the highlights of PHP 8.2: Major new features, changes, and deprecated functionality.
In this tutorial, we are going to discuss about how to implement the functional testing in Symfony 4 with Kahlan 4. In IT world, whenever we are creating an application/website, we need to test the application/website thouroghly. To perform the functional testing we have a bundl…
TZ Portfolio works on database of comcontent, sothat you do not have to worry about importing or exporting data from your system (which already works with comcontent). TZ Portfolio inherits all current functions of com_content, in addition, we develop two new data interfaces: Po…
There are usability practitioners who completely dismiss the importance of aesthetics, often citing unattractive but popular websites such as Craigslist. However, aesthetics do have a function. Attractive things work better. Studies show that emotions play an important role in t…
On a website, people usually scan for trigger words first and only use the search function when they’re unable to find a good enough navigational link. This holds true for most websites, though people habitually search by default for books, DVDs and CDs, computer games; th…
Overview of PHP internals related with disable_functions and how common exploits works
Article describing how we used LIEF to isolate target functions and kaitai to describe the protocol.
Some ideas about how to extract hidden parameters in PHP functions and how to find potential bypasses
PHP 8.5 shipped with a feature that functional programming enthusiasts have been requesting for years: the pipe operator (|>). If you’ve used pipes in Unix shells, Elixir, F#, or even JavaScript proposals, the concept will feel immediately familiar. If you haven’t…
For a long time, I have been trying to include tests in every project in which I've worked on. There are several types of automated tests (or what should actually be called automated checks). From unit tests, integration and functional tests, to end-to-end tests. Each one of the…
Consider the following code: class Animal { protected $what = "nothing"; function sound() { echo get_class($this)." says {$this->what}"; } } class Cow extends Animal { protected $what = "moo"; protected $owner; public function __construct($owner)…
with no AWS Lambda function required A co-worker at Archer asked if there was a way to schedule messages published to an Amazon SNS topic. I know that scheduling messages to SQS queues is possible to some extent using the DelaySeconds message timer, which allows postponing visib…
In my first post, I explained how Dependency Injection (DI) enhances developer experience. If you already know what DI is and you are not convinced that it is worth using in JavaScript, I really encourage you to read it first. In the second post, I discussed why DI is uncommon i…
In this post, we are going to implement a simple router functionality so we can handle HTTP GET requests and render different information based on the page we are currently in. The post Simple PHP Routing for Invoice Management System first appeared on Max Pronko.
The era of AI-assisted coding has arrived—and 2026 is the year it goes mainstream. From writing full functions to debugging and documenting complex projects, today’s AI coding tools are reshaping how developers work. Whether you’re a beginner building your first app or a seasone…
سپهر محمودی
Photo by Ben Griffiths on UnsplashIf you want to become a good PHP developer, you must learn to work with arrays. Arrays are used a lot in PHP: temporarily store, organize, and process data before it’s saved in a database. Knowing how to work with them efficiently will help you …
Creating dynamic PDF documents, such as invoices or reports, is a common task in modern application development. Whether it’s to meet administrative needs, automate processes, or simply provide essential functionality to users, choosing the right tool for generating these docume…
$counter = 0; \DB::listen(function() use (&$counter) {$counter++;}); // Do stuff dd($counter);
Codeception Testing Framework from its roots was a plugin of symfony 1 framework. Today Codeception is powered by Symfony components and can be used to run functional tests for practically any popular PHP framework. Why would you someone ever choose Codeception if Symfony alread…
An example on how we added extra rules to the switch user functionality of the Symfony security component.
When unit testing real-world code, there are many situations that make tests hard to write. How do you check if a function was called? How do you test an Ajax call? Or code using setTimeout? That’s when you use test doubles — replacement code that makes hard to test things easy …
Everyone loves a good if-else tower! What could be simpler than nesting a few conditionals? if(stuff) { if(more stuff) { haha(); } else { cool(); } } Ok - that isn’t the most amazing thing in the world. In a simple example like this, it isn’t too bad. But we all know real code i…
Organizing test code in PHP You are working on a PHP application or a package. You have decided that you want to use: infection/infection for running mutation tests phpbench/phpbench for running performance tests phpunit/phpunit for running unit, integration, functional, and end…
Pretty-printing JSON with custom indentation PHP 5.4 added the JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, and JSON_UNESCAPED_UNICODE constants for use with the json_encode() function. For example, you can use the JSON_PRETTY_PRINT constant to encode a value to a JSON string with…
I recently released a new version of my Cloudflare Turnstile package for Laravel. One of the features I added was the ability to test your Turnstile integrations using a fake implementation of the Turnstile client. it('validates data', function () { Turnstile::fake(); [code! foc…
To get a random element from an array, you can use a couple of Math functions to generate a random index and retrieve a value. function random(items) { return items[Math.floor(Math.random() * items.length)] } How it works Math.random() generates a random float between 0 and 1. T…
With this PHP function, you can fade directly from one image to another with jQuery, and even make a looping slideshow. Super easy.
This JavaScript function takes a string, converts it to lowercase, then capitalizes the first letter of each word.
Quick functions that will let you both get data from the query string in JavaScript, and also to update that query string.
A more secure alternative to using PHP's mail() function that will help keep your messages out of the spam filters.
This function follows redirects (even multiple redirects) and returns the final destination URL as a string.
I came across a subtle Octane but last week. We needed to disable Inertia’s history encryption in some places in the app. By default, it’s enabled everywhere. So we added a route check to the middleware to turn it off. class HandleInertiaRequests { public function ha…
When I experimented with Elixir a few years ago, I fell in love with the pipe operator |>. Since then, I’ve always dreamt of a similar tool in PHP. Last year, we finally got it! Unfortunately, the standard array & string manipulation functions in PHP aren’t ex…
Earlier on in my programming career, I got pretty heavy into Object-Oriented Programming and all the various design patterns around it (there are a lot). I used to worship at the alter of Martin Fowler and zealously look for opportunities to implement all of the various Gang of …