Skip to content

Instantly share code, notes, and snippets.

@tnrn9b
tnrn9b / __upload_file.md
Created July 30, 2018 15:32 — forked from dlgg/__upload_file.md
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");;
public static function generateInvoicePDF($row)
{
self::loadLanguage();
require_once JPATH_ROOT . '/components/com_osmembership/tcpdf/tcpdf.php';
require_once JPATH_ROOT . '/components/com_osmembership/tcpdf/config/lang/eng.php';
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$config = self::getConfig();
@tnrn9b
tnrn9b / html_trim_whitespace.php
Created August 4, 2018 06:44 — forked from gskema/html_trim_whitespace.php
HTML whitespace trim RegEx (regular expression) for PHP. Useful for trimming HTML content before TCPDF processing.
<?php
// Trims whitespaces after any tags. Assumes that a tag ends with '/>', '\w>', '">'.
$html = preg_replace('#(["|\/|\w]>)(\s+)#', '$1', $html);
// Trims whitespaces before any tags. Assumes that tags start with '<\w+'
$html = preg_replace('#(\s+)(<\/?\w+)#', '$2', $html);
// Trims spaces between tags (both opening and closing).
// Assumes that a tag ends with '/>', '\w>', '">' and starts with '<\w+'
@tnrn9b
tnrn9b / submit.md
Created February 17, 2021 03:37 — forked from tanaikech/submit.md
Downloading Active Sheet in Google Spreadsheet as CSV and PDF file by Clicking Button

Downloading Active Sheet in Google Spreadsheet as CSV and PDF file by Clicking Button

This is a sample script for downloading the active sheet in Google Spreadsheet to the local PC as a CSV file and a PDF file when a button on the side bar and the dialog is clicked. This is created with Google Apps Script and HTML&Javascript. In this post, the script of the previous post was modified.

Sample script

Please create new Google Spreadsheet and copy and paste the following scripts to the script editor. And please run openSidebar(). By this, the side bar is opened to the Spreadsheet.

@tnrn9b
tnrn9b / submit.md
Created February 17, 2021 03:42 — forked from tanaikech/submit.md
Creating Multiple Buttons on Google Spreadsheet using Google Apps Script

Creating Multiple Buttons on Google Spreadsheet using Google Apps Script

This is a sample script for creating the multiple buttons on Google Spreadsheet using Google Apps Script.

Recently, I have got several contacts about this. I thought that when this is published, it might be useful for other users. So I published this sample script.

Sample script