Skip to content

Instantly share code, notes, and snippets.

View Rahmon's full-sized avatar
🌎
Hello world [wide web]

Ramon Ahnert Rahmon

🌎
Hello world [wide web]
View GitHub Profile
@felipeelia
felipeelia / ngrok.php
Last active September 1, 2022 23:41
WordPress MU Plugin to have it working with ngrok.io
<?php
/**
* Place this file in the wp-content/mu-plugins directory and run ngrok with
* `ngrok http http://<local_url> --host-header=<local_url>`
*/
$ngrok_url = '<id>.ngrok.io';
define( 'WP_HOME', 'http://' . $ngrok_url );
define( 'WP_SITEURL', 'http://' . $ngrok_url );

Accessibility, IDs, and Server Rendering in React

For better or for worse, many WAI-ARIA patterns depend on ID's to connect elements together.

For example (without ARIA):

<label for="first-name">First Name</label>
<input id="first-name"/>
@maxivak
maxivak / __upload_file.md
Last active April 4, 2024 10:07
PHP upload file with curl (multipart/form-data)

We want to upload file to a server with POST HTTP request. We will use curl functions.


// data fields for POST request
$fields = array("f1"=>"value1", "another_field2"=>"anothervalue");

// files to upload
$filenames = array("/tmp/1.jpg", "/tmp/2.png");
@sirbrillig
sirbrillig / functions.php
Last active November 2, 2024 22:32 — forked from UmeshSingla/functions.php
Post file using wp_remote_post in WordPress
<?php
$local_file = 'file_path'; //path to a local file on your server
$post_fields = array(
'name' => 'value',
);
$boundary = wp_generate_password( 24 );
$headers = array(
'content-type' => 'multipart/form-data; boundary=' . $boundary,
);
@ssigwart
ssigwart / buildMultipartFormData.php
Created January 24, 2015 16:21
Build multipart/form-data in PHP
/**
* Build multipart/form-data
*
* @param array @$data Data
* @param array @$files 1-D array of files where key is field name and value if file contents
* @param string &$contentType Retun variable for content type
*
* @return string Encoded data
*/
function buildMultipartFormData(array &$data, array &$files, &$contentType)