Skip to content

Instantly share code, notes, and snippets.

View gelinger777's full-sized avatar

gelinger777 gelinger777

  • gelinger777
  • World
View GitHub Profile

Server side printing with Google Cloud Print API from a PHP application

It took me quite some time to figure out how to print properly from a web application. I will explain here how I did it, so you don't have to spend the same time.

Authorization

Google Cloud Print API uses OAuth 2.0 for authorization.

As explained [here][1] on the Google Developer page, the best way to use OAuth with the Google API is with a Google service account. Create a service account as explained on the Google Developer page.

To use OAuth a library is required. Google has published the [Google API PHP client library][2]. If you want to use the examples from the Developer pages, you need to use version 1 of the library. In this article I use version 2 of the library.

@gelinger777
gelinger777 / gist:528792110b226a6d7cc565307acf0650
Created January 30, 2019 12:23
Format Money Amount depending on decimals for Stripe and Adyen
<?
/*
*/
@gelinger777
gelinger777 / User.php
Created July 1, 2019 02:21
Voyager + Spark updated User.php model
namespace App;
use Laravel\Spark\User as SparkUser;
use Carbon\Carbon;
use Illuminate\Foundation\Auth\User as Authenticatable;
use TCG\Voyager\Contracts\User as UserContract;
use TCG\Voyager\Traits\VoyagerUser;
class User extends SparkUser implements UserContract
php artisan cache:clear
php artisan config:clear
php artisan config:cache
php artisan route:clear
php artisan route:cache
# GNU nano 2.5.3 File: badIpBan.sh
@gelinger777
gelinger777 / gist:2b9bec11451b34e4362669007a25fa07
Created November 8, 2019 10:49
Fix Wordpress Theme Broken Serialized Strings After Moving the Domain
<?php
//Enter your string , then get the fixed one enjoy!
$string='YToyOntzOjg6InNpZGViYXJzIjthOjIwOntzOjc6InNpZGViYXIiO2E6Njp7aTowO3M6ODoic2VhcmNoLTIiO2k6MTtzOjEyOiJjYXRlZ29yaWVzLTIiO2k6MjtzOjExOiJ0YWdfY2xvdWQtMiI7aTozO3M6MTM6Im1lZGlhX2ltYWdlLTUiO2k6NDtzOjc6InRleHQtMTgiO2k6NTtzOjc6InRleHQtMTciO31zOjE4OiJzaWRlLW9wZW5lci13aWRnZXQiO2E6MTp7aTowO3M6MjM6Im1rZGZfc2lkZV9hcmVhX29wZW5lci05Ijt9czoxOToiZm9vdGVyX3RvcF9jb2x1bW5fMSI7YTozOntpOjA7czo2OiJ0ZXh0LTIiO2k6MTtzOjIzOiJta2RmX3NlcGFyYXRvcl93aWRnZXQtNCI7aToyO3M6NzoidGV4dC0xMCI7fXM6MTk6ImZvb3Rlcl90b3BfY29sdW1uXzIiO2E6MDp7fXM6MTk6ImZvb3Rlcl90b3BfY29sdW1uXzMiO2E6MTp7aTowO3M6NjoidGV4dC03Ijt9czoxOToiZm9vdGVyX3RvcF9jb2x1bW5fNCI7YToyOntpOjA7czo2OiJ0ZXh0LTgiO2k6MTtzOjI0OiJta2RmX3NlcGFyYXRvcl93aWRnZXQtMjYiO31zOjI3OiJta2RmLWhlYWRlci13aWRnZXQtYXJlYS1vbmUiO2E6Mjp7aTowO3M6MjA6Im1rZGZfc2VhcmNoX29wZW5lci0yIjtpOjE7czoyMzoibWtkZl9zaWRlX2FyZWFfb3BlbmVyLTIiO31zOjI3OiJta2RmLWhlYWRlci13aWRnZXQtYXJlYS10d28iO2E6MDp7fXM6ODoic2lkZWFyZWEiO2E6MTI6e2k6MDtzOjEzOiJtZWRpYV9pbWFnZS0yIjtpO
@gelinger777
gelinger777 / gist:ecf0e5fbbc879990b174a86b1cea40aa
Created June 6, 2020 13:46
GroceryCrudEnterpriseArmenianPart1.php
<?php
return [
'subject' => 'Տվյալ',
'subject_plural' => 'Տվյալներ',
'add_item' => 'Ավելացնել {subject}ը',
'edit_item' => 'Խմբագրել {subject}ը',
'view_item' => 'Բացել {subject}ը',
'edit' => 'Խմբագրել',
'view' => 'Բացել',
@gelinger777
gelinger777 / influx_schema.sql
Created November 8, 2020 10:28 — forked from bbc4468/influx_schema.sql
Influx DB Schema for OHLC
create database price_history_db
CREATE CONTINUOUS QUERY "cq_1m" ON "price_history_db" BEGIN SELECT MIN(price) as low, MAX(price) as high, FIRST(price) as open, LAST(price) as close, SUM(size) as volume INTO "price_1m" FROM "trade" GROUP BY time(1m), symbol END
CREATE CONTINUOUS QUERY "cq_5m" ON "price_history_db" BEGIN SELECT MIN(low) as low, MAX(high) as high, FIRST(open) as open, LAST(close) as close, SUM(volume) as volume INTO "price_5m" FROM "price_1m" GROUP BY time(5m), symbol END
CREATE CONTINUOUS QUERY "cq_15m" ON "price_history_db" BEGIN SELECT MIN(low) as low, MAX(high) as high, FIRST(open) as open, LAST(close) as close, SUM(volume) as volume INTO "price_15m" FROM "price_5m" GROUP BY time(15m), symbol END
CREATE CONTINUOUS QUERY "cq_1h" ON "price_history_db" BEGIN SELECT MIN(low) as low, MAX(high) as high, FIRST(open) as open, LAST(close) as close, SUM(volume) as volume INTO "price_1h" FROM "price_15m" GROUP BY time(1h), symbol END
CREATE CONTINUOUS QUERY "cq_6h" ON "price_history_db" BEGIN SELECT
@gelinger777
gelinger777 / gasp.py
Created December 3, 2020 21:36 — forked from iUmarov/gasp.py
# This is my implmentation of calculating Global Average Symmetric Price (GASP) as it's mentioned in this video: https://www.youtube.com/watch?v=wpmTuNvGQjQ
# Presenter in the video doesn't explain briefly how to calculate the GASP, but, I kinda figured it out myself
order_book = {
'bids': [
[97, 0.1],
[96, 0.2],
[95, 6]
],
@gelinger777
gelinger777 / gist:f81e026d3040116a23caecd460add8d9
Last active October 28, 2021 20:10
AppsFlyer Ionic AppDelegate v3 (Only for SDK > 6.2.30) Works for Ionic Cordova >= 4
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0