Skip to content

Instantly share code, notes, and snippets.

Avatar

Ravenna Ravenna

View GitHub Profile
View push file
$headers = [
'Authorization' => 'Token token='.env('PSPDFKIT_TOKEN'),
'Content-Type' => "application/pdf",
//"Content-Length" => filesize($request->file('attachment'))
];
$body = [
'file' => $request->file('attachment'),
'document_id' => substr(str_shuffle($permitted_chars), 0, 10)
];
$client = new \GuzzleHttp\Client(['base_uri' => 'http://localhost:5000/api/']);
View ActiveCampaign.php
function httpRequest($url, $body) {
$method = "POST";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
if ($body) {
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($body));
View simplifying curl
public $base_url = "https://spaceangelsnetwork.api-us1.com";
public $secure_token;
public $debug = false;
function __construct($secure_token = NULL) {
$this->secure_token = config('services.active_campaign.key');
if($secure_token) $this->secure_token = $secure_token;
}
View config.js
window.addEventListener('viewerLoaded', () => {
const docViewer = readerControl.docViewer;
// Add customization here
docViewer.setMargin(20);
readerControl.disableElements([
'searchButton',
'stickyToolButton',
View export.php
<?php
header("HTTP/1.1 200 OK"); // Forcing the 200 OK header as WP can return 404 otherwise
$orders = get_orders_ids_by_product_id(498);
$output = array();
foreach($orders as $o){
View spinner js
$('form').submit(function(e){
var button = $(this).find('button[type="submit"]');
var text = button.text();
var loader = '../images/spinner.gif';
button.attr("disabled", true);
button.text('').append('<img src="/static/images/spinner-solid.svg" class="spinner" alt="loader">')
});
View error from push
remote: -----> Installing dependencies...
remote: Composer version 1.9.0 2019-08-02 20:55:32
remote: Loading composer repositories with package information
remote: Installing dependencies from lock file
remote: Package operations: 2 installs, 0 updates, 0 removals
remote: - Installing setasign/setapdf-core (2.32.0.1371): Downloading (75%)
remote:
remote: [Composer\Downloader\TransportException]
remote: The 'https://www.setasign.com/downloads/2298773/SetaPDF-Core_2.32.0.1371-without-demos.zip' URL required authentication.
remote: You must be using the interactive console to authenticate
View gist:116f8c229e3cd7ed6e337076f22eb568
//config/queue.php
<?php
return [
'default' => env('QUEUE_CONNECTION', 'database'),
'connections' => [
'sync' => [
'driver' => 'redis',
],
View Saving pdf
$fit = true;
$path = base_path().'/public';
$file = $path .'/forms/doc-27.pdf';
$docDeal = str_replace(' ', '-', strtolower($deal->name));
$docInvestor = str_replace(' ', '-', strtolower($user->name));
$date = date('m-d-Y');
$signature = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $request->base64_signature));
View pdf merge and stamp
<?php
require 'vendor/autoload.php';
$writer = new SetaPDF_Core_Writer_Http('output.pdf', true);
$document = SetaPDF_Core_Document::loadByFilename('test.pdf', $writer);
$formFiller = new SetaPDF_FormFiller($document);
$fields = $formFiller->getFields();
$stamper = new SetaPDF_Stamper($document);