Skip to content

Instantly share code, notes, and snippets.

@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");
@luckydev
luckydev / gist:b2a6ebe793aeacf50ff15331fb3b519d
Last active October 22, 2022 14:03
Increate max no of open files limit in Ubuntu 16.04/18.04 for Nginx
# maximum capability of system
user@ubuntu:~$ cat /proc/sys/fs/file-max
708444
# available limit
user@ubuntu:~$ ulimit -n
1024
# To increase the available limit to say 200000
user@ubuntu:~$ sudo vim /etc/sysctl.conf
@joni
joni / STRINGDECODE.sql
Created June 19, 2012 19:35
STRINGDECODE: MySQL function to decode unicode escapes to utf8
CREATE FUNCTION STRINGDECODE(str TEXT CHARSET utf8)
RETURNS text CHARSET utf8 DETERMINISTIC
BEGIN
declare pos int;
declare escape char(6) charset utf8;
declare unescape char(3) charset utf8;
set pos = locate('\\u', str);
while pos > 0 do
set escape = substring(str, pos, 6);
set unescape = char(conv(substring(escape,3),16,10) using ucs2);