Skip to content

Instantly share code, notes, and snippets.

View johanjanssens's full-sized avatar
💭
Crunching code, one line at a time.

Johan Janssens johanjanssens

💭
Crunching code, one line at a time.
View GitHub Profile

Libuv and libev, two I/O libraries with similar names, recently had the privilege to use both libraries to write something. Now let's talk about my own subjective expression of common and different points.

The topic of high-performance network programming has been discussed. Asynchronous, asynchronous, or asynchronous. Whether it is epoll or kqueue, it is always indispensable to the asynchronous topic.

Libuv is asynchronous, and libev is synchronous multiplexing IO multiplexing.

Libev is a simple encapsulation of system I/O reuse. Basically, it solves the problem of different APIs between epoll and kqueuq. Ensure that programs written using livev's API can run on most *nix platforms. However, the disadvantages of libev are also obvious. Because it basically just encapsulates the Event Library, it is inconvenient to use. For example, accept(3) requires manual setnonblocking after connection. EAGAIN, EWOULDBLOCK, and EINTER need to be detected when reading from a socket. This is a

@mgol
mgol / ie11-only.md
Last active March 25, 2025 00:51
How to easily not serve JS and/or CSS to IE<11

Here's how to make your site not load CSS and/or JS in IE older than 11:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=8,9,11">
        <title>Page title</title>
        <!--[if !IE]>-->
 
@kochen
kochen / DOCman 2.0 Stable - get list of documents.php
Last active November 2, 2015 19:34
DOCman 2.0 Stable - get list of documents
<?
$catid = 2; //could also be an array(1,2,3,4)
/**
* returns a KModelEntityRowset, where each item is a KModelEntityRow.
* in the case of documents it returns a special document entity (the Rowset is filtered by the requested category.
*
* the document entity has (among other things):
* - $document->title (text)
* - $document->category (category entity object)
@kochen
kochen / DOCman 2.0 Stable - add new document.php
Last active November 2, 2015 19:34
DOCman 2.0 Stable - add new document
<?
$catid = 2; // the number of the specific category to assign the document to.
$fileinfo = array( /* an array of file info, including BASENAME and FILENAME */ );
$datetime = date("Y-m-d H:i:s"); // current datetime
$user = KObjectMAnager::getInstance()->getObject('user'); // the Joomla user object
$controller = KObjectMAnager::getInstance()->getObject('com://admin/docman.controller.document');
$controller->add(array(
docman_category_id => $catid,
storage_path => $fileinfo['filename'],