Skip to content

Instantly share code, notes, and snippets.

View AndreiTelteu's full-sized avatar

Andrei Telteu AndreiTelteu

View GitHub Profile
@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"}')
@AndreiTelteu
AndreiTelteu / Google Maps Marker as AngularJS 1.x directive .html
Last active April 12, 2018 10:19
I extracted the svg icon of the markers shown by Google Maps directions display, and i use it as a directive. Demo: https://codepen.io/AndreiTelteu/pen/GxLdKK
<div ng-app="GoogleMapsMarkerDemo">
<!-- Usage -->
<div ng-repeat="marker in ['marker1', 'marker2', 'marker3']">
<google-marker label="$index | indexToAlphabet"></google-marker>
</div>
<!-- You can have this svg as a separate file -->
<script type="text/ng-template" id="google-marker-template">
<svg version="1.1" width="27px" height="43px" viewBox="0 0 27 43" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
@AndreiTelteu
AndreiTelteu / cPanel WHM change documentroot .md
Created September 17, 2018 15:59
cPanel/WHM change documentroot
  1. Edit this files:
/var/cpanel/userdata/username/domain.tld
/var/cpanel/userdata/username/domain.tld_SSL

Change documentroot and scriptalias for cgi-bin

  1. (optional) Remove cache files:
@AndreiTelteu
AndreiTelteu / disable bad inline code .html
Created September 19, 2018 13:31
disable some bad inline code that ruins websites
<script>
function disableBadInlineCode() {
$('style:contains("display: none!important")').each(function (i) { this.disabled = true; });
};
document.addEventListener('DOMContentLoaded', disableBadInlineCode, false);
setInterval(disableBadInlineCode, 1000);
</script>
@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==
<?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);
@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 / 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 / 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