Skip to content

Instantly share code, notes, and snippets.

View AndreiTelteu's full-sized avatar

Andrei Telteu AndreiTelteu

View GitHub Profile
@AndreiTelteu
AndreiTelteu / swoole startup script for centos .sh
Last active October 3, 2018 17:04
A startup script for swooletw/laravel-swoole, in two versions, one old init.d way, and a way better one using supervisor
#!/bin/sh
#
# /etc/init.d/swoole-prod
#
# Example of init script for UNIX daemon
#
# chkconfig: 2345 20 80
# description: Example of UNIX daemon
### BEGIN INIT INFO
// ==UserScript==
// @name YouTube InstantView customization
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author Andrei Telteu
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==
@AndreiTelteu
AndreiTelteu / Remove Accent .md
Last active December 21, 2018 13:36
Remove the accent from a string or array
function remove_accent($str) {
    $a = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'Ā', 'ā', 'Ă', 'ă', 'Ą', 'ą', 'Ć', 'ć', 'Ĉ', 'ĉ', 'Ċ', 'ċ', 'Č', 'č', 'Ď', 'ď', 'Đ', 'đ', 'Ē', 'ē', 'Ĕ', 'ĕ', 'Ė', 'ė', 'Ę', 'ę', 'Ě', 'ě', 'Ĝ', 'ĝ', 'Ğ', 'ğ', 'Ġ', 'ġ', 'Ģ', 'ģ', 'Ĥ', 'ĥ', 'Ħ', 'ħ', 'Ĩ', 'ĩ', 'Ī', 'ī', 'Ĭ', 'ĭ', 'Į', 'į', 'İ', 'ı', 'IJ', 'ij', 'Ĵ', 'ĵ', 'Ķ', 'ķ', 'Ĺ', 'ĺ', 'Ļ', 'ļ', 'Ľ', 'ľ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'Ń', 'ń', 'Ņ', 'ņ', 'Ň', 'ň', 'ʼn', 'Ō', 'ō', 'Ŏ', 'ŏ', 'Ő', 'ő', 'Œ', 'œ', 'Ŕ', 'ŕ', 'Ŗ', 'ŗ', 'Ř', 'ř', 'Ś', 'ś', 'Ŝ', 'ŝ', 'Ş', 'ş', 'Š', 'š', 'Ţ', 'ţ', 'Ť', 'ť', 'Ŧ', 'ŧ', 'Ũ', 'ũ', 'Ū', 'ū', 'Ŭ', 'ŭ', 'Ů', 'ů', 'Ű', 'ű', 'Ų', 'ų', 'Ŵ', 'ŵ', 'Ŷ', 'ŷ', 'Ÿ', 'Ź', 'ź', 'Ż', 'ż', 'Ž', 'ž', 'ſ', 'ƒ', 'Ơ', 'ơ', 'Ư', 'ư', 'Ǎ', 'ǎ', 'Ǐ', 'ǐ', 'Ǒ', '
@AndreiTelteu
AndreiTelteu / replace.sql
Last active May 21, 2019 18:14
SQL Replace domain in Magento 1.x installation
UPDATE `core_config_data`
SET `value` = REPLACE(value, 'old-domain.com', 'new-domain.com')
WHERE `path` LIKE '%secure/base_url%' OR `path` = 'web/cookie/cookie_domain'
// with regex
UPDATE `subcategories` SET `name` = REGEXP_REPLACE(name,'^(.*)$','{"ro":"\\1","en":"\\1"}')
<?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('robot@laravel.com');
$keys = $rsa->createKey(4096);
@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,
@AndreiTelteu
AndreiTelteu / linux raspberry pi get system temperature .md
Last active October 28, 2020 20:17
Get CPU, GPU and HDD temperatures

Create a new file called temps in a folder that is included in PATH (example nano .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

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 / 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>
@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;