Skip to content

Instantly share code, notes, and snippets.

View AndreiTelteu's full-sized avatar

Andrei Telteu AndreiTelteu

View GitHub Profile

Keybase proof

I hereby claim:

  • I am AndreiTelteu on github.
  • I am andreitelteu (https://keybase.io/andreitelteu) on keybase.
  • I have a public key whose fingerprint is 6D38 3885 8AB5 904A 4933 C7BA 101C E7AA 653C DAB7

To claim this, I am signing this object:

@AndreiTelteu
AndreiTelteu / Ajenti Web Install Ubuntu .md
Last active August 29, 2015 14:17
Install Ajenti Web Ubuntu Install

Instead of searching on the ajenti.org website every time i want to install it, i copy and paste the code from this page.

wget -O- https://raw.github.com/Eugeny/ajenti/master/scripts/install-ubuntu.sh | sudo sh

You may need apt-get remove apache2, and finaly

apt-get install ajenti-v ajenti-v-nginx ajenti-v-mysql ajenti-v-php-fpm php5-mysql

service ajenti restart

@AndreiTelteu
AndreiTelteu / CakePHP function for calling WP-API .md
Last active August 29, 2015 14:17
Protected function for calling WP REST API plugin
  1. Install the json rest api wordpress plugin.

  2. Include the following function in app/Controller/AppController.php in your CakePHP instalation.

    	protected function _wpAPI($method='get', $url='/', $data=null)
    	{
    		App::uses('HttpSocket', 'Network/Http');
    		$http = new HttpSocket();
    		
    		$http->configAuth('Basic', 'admin', 'password');
@AndreiTelteu
AndreiTelteu / MySQLdump hook on git commit .md
Last active October 12, 2015 22:47
Dumping the structure of a database on each commit, and staging that modification for the next commit.

Create or open the file .git/hooks/pre-commit and paste the following code inside it:

#!/bin/sh

mysqldump \
	--no-data \
	--dump-date=false \
	--result-file=$PWD/dbdump.sql \
	--log-error='/dev/null' \

--user='username' \

filter: #{'invert()'}
@AndreiTelteu
AndreiTelteu / PHP htmlentities recursive .php
Last active July 6, 2016 13:39
Small PHP function to apply htmlentities function to an array recursively
<?php
function htmlentities_recursive($code) {
if (is_array($code))
{
foreach ($code as &$c) $c = htmlentities_recursive($c);
return $code;
}
return htmlentities($code);
}
@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
<?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 / 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
{
@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)