Skip to content

Instantly share code, notes, and snippets.

View gelinger777's full-sized avatar

Gelinger Media gelinger777

  • www.gelinger.at
  • Vienna
View GitHub Profile
@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
# GNU nano 2.5.3 File: badIpBan.sh
php artisan cache:clear
php artisan config:clear
php artisan config:cache
php artisan route:clear
php artisan route:cache
@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
@gelinger777
gelinger777 / gist:528792110b226a6d7cc565307acf0650
Created January 30, 2019 12:23
Format Money Amount depending on decimals for Stripe and Adyen
<?
/*
*/

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.

public static function isEmail($email)
{
$parsed=explode("@",$email);
if(count($parsed)<2){
return false;
@gelinger777
gelinger777 / cloudflare-prestashop
Created July 25, 2018 13:49
sudo nano /override/classes/Tools
/**
* Get the server variable REMOTE_ADDR, or the first ip of HTTP_X_FORWARDED_FOR (when using proxy)
*
* @return string $remote_addr ip of client
*/
public static function getRemoteAddr()
{
if (function_exists('apache_request_headers')) {
$headers = apache_request_headers();
} else {
@gelinger777
gelinger777 / gist:82ff77bb755f4912e3c0450de349da44
Created July 12, 2018 15:14
nginx_pagespeed params for ubuntu
--prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail
select * from INFORMATION_SCHEMA.COLUMNS
where COLUMN_NAME like '%email%' and TABLE_SCHEMA='cloner'
order by TABLE_NAME