Skip to content

Instantly share code, notes, and snippets.

View AndreiTelteu's full-sized avatar

Andrei Telteu AndreiTelteu

View GitHub Profile
// ==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 / 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
@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 / 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 / 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 / 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 / Linux-prompt-git-status.md
Last active February 10, 2018 18:06
My git prompt script

Run command:

$ bash <(curl -L -s https://goo.gl/eax5A8)
@AndreiTelteu
AndreiTelteu / Custom bread field type .md
Last active February 26, 2024 09:37
Custom bread field type stored in json format. For Laravel + Voyager admin panel

1. A new file: /app/Admin/FormFields/CustomFieldHandler.php

<?php
namespace App\Admin\FormFields;

use TCG\Voyager\FormFields\AbstractHandler;

class CustomFieldHandler extends AbstractHandler
{
<?php
function caesar_cipher_smart($shift, $input) {
$a = str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
$p = str_split($input);
foreach ($p as &$v)
if (($k = array_search($v, $a)) !== false) {
$t = $k+$shift;
if ($t < 0) $t = count($a)+$t;
$v = $a[$t];
@AndreiTelteu
AndreiTelteu / Laravel MongoDB User Following Relationships .md
Last active November 23, 2017 12:45
User following relationships for Laravel 5.2 with jenssegers/laravel-mongodb database driver