Skip to content

Instantly share code, notes, and snippets.

View AndreiTelteu's full-sized avatar

Andrei Telteu AndreiTelteu

View GitHub Profile
useIpInProxyHeader 2
accessControl {
allow ALL, 173.245.48.0/20T, 103.21.244.0/22T, 103.22.200.0/22T, 103.31.4.0/22T, 141.101.64.0/18T, 108.162.192.0/18T, 190.93.240.0/20T, 188.114.96.0/20T, 197.234.240.0/22T, 198.41.128.0/17T, 162.158.0.0/15T, 104.16.0.0/13T, 104.24.0.0/14T, 172.64.0.0/13T, 131.0.72.0/22T
}
@AndreiTelteu
AndreiTelteu / WooCommerce make cart session functional inside an iframe .md
Last active March 5, 2025 18:28
WooCommerce make cart session functional inside an iframe .md

If you need your woocommerce cart functions to work while inside an iframe, you have to add this code in your theme's functions file (or plugin's function file):

function iframe_cookies_samesite_filter_wc_session($enabled, $name, $value, $expire, $secure)
{
    if ( ! headers_sent() ) {
        setcookie($name, $value, [
            'secure'   => true,
            'httponly' => apply_filters( 'woocommerce_cookie_httponly', $httponly, $name, $value, $expire, $secure ),
@AndreiTelteu
AndreiTelteu / Docker exec yarn commands from fnm .md
Created July 27, 2021 10:50
If you have fnm inside a docker container and you want to run a node/npm/yarn command using a specific version of node, fron the host, using docker exec

Example of how to run yarn run prod using yarn package from fnm:

docker exec -i -w /home/of/your/project docker-container-name bash -c "/root/.fnm/fnm exec --using 12 yarn run production"
@AndreiTelteu
AndreiTelteu / PHP image cut split in parts stack on top .php
Created July 19, 2021 21:59
With this script you can split a super long image in how many parts you want, and stack them. Like a long ecg chart: https://i.imgur.com/ZlwMNRz.png
<?php
$source_path = 'super-long-image.png';
$destination_path = 'new-image.png';
$parts = 3; // in how many parts you want to split the image
$source = imagecreatefrompng($source_path);
$width = imagesx($source);
$height = imagesy($source);
$newWidth = $width / $parts;
$newHeight = $height * $parts;
@AndreiTelteu
AndreiTelteu / react js laravel mix loading screen with progressbar .blade.php
Last active July 14, 2021 12:24
Saves the laravel mix versioned url in localstorage and compares it with current version url in order to activate browser cache if version is the same
<div id="app">
{{-- this loader gets automatically replaced by the react app after loading --}}
<div style="background:#1C9EF2; width:100vw; height:100vh;">
<div id="loading" style="position: absolute; top:46%; left:50%; transform: translateX(-50%) translateY(-50%); text-align: center;">
<img src="/images/logo-white.png"><br>
<div style="display: inline-block; width: 80px; height: 80px; border-radius: 100%; background: white; display: flex; margin: auto; align-items: center; justify-content: center; margin-top: 20px;">
<img src="/images/loader.svg" style="width: 50px; height: 50px; margin-bottom: 10px;">
</div>

In your theme's functions.php file, or in a custom plugin insert this code:

<?php

add_filter( 'rank_math/frontend/title', function( $title ) {
    $translatepress_translation = custom_get_translatepress_translation($title);
    if ($translatepress_translation != null) {
        $title = $translatepress_translation;
@AndreiTelteu
AndreiTelteu / linux raspberry pi get system temperature .md
Last active February 6, 2025 00:53
Get CPU, GPU and HDD temperatures

Create a new file called temps in a folder that is included in PATH (example sudo nano /usr/local/bin/temps)

#!/bin/bash
# Purpose: Display the ARM CPU and GPU  temperature of Raspberry Pi 2/3
# Author: Vivek Gite <www.cyberciti.biz> under GPL v2.x+
# source: https://www.cyberciti.biz/faq/linux-find-out-raspberry-pi-gpu-and-arm-cpu-temperature-command/
# modified by: Andrei Telteu https://gist.github.com/AndreiTelteu/11dae86616b48578a8e8649802414aaa
# -------------------------------------------------------
cpu=$(</sys/class/thermal/thermal_zone0/temp)
hdd=/dev/sda    # lsblk -d to see all
@AndreiTelteu
AndreiTelteu / ProxyController.php
Created August 3, 2020 11:53
Laravel Simple Proxy Gateway with Guzzle
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use GuzzleHttp\Client;
class ProxyController extends Controller
{
@AndreiTelteu
AndreiTelteu / roots-sage dev proxy with SSL .md
Created January 31, 2020 12:55
Add ssl certificate to your roots/sage based wordpress theme's brpwsersync dev proxy

If you are developing with the wordpress theme starter kit roots/sage, and you want to specify a custom ssl certificate for the dev proxy when you run yarn start, add the ssl certs this way:

Open \wp-content\themes\your-sage-theme\resources\assets\build\webpack.config.watch.js

Add the advanced.browserSync config after delay:

    new BrowserSyncPlugin({
      target,
 open: config.open,
<?php
// install composer require phpseclib/phpseclib:~2.0
// https://github.com/phpseclib/phpseclib
$rsa = new \phpseclib\Crypt\RSA();
$rsa->setPassword($password);
$rsa->setPrivateKeyFormat(\phpseclib\Crypt\RSA::PUBLIC_FORMAT_OPENSSH);
$rsa->setPublicKeyFormat(\phpseclib\Crypt\RSA::PUBLIC_FORMAT_OPENSSH);
$rsa->setComment('[email protected]');
$keys = $rsa->createKey(4096);