Skip to content

Instantly share code, notes, and snippets.

# create a new user (john for this example)
# just enter a password when asked, confirm it, and the other steps are optionals
sudo adduser john
# give root user the ownership of john's home directory
sudo chown root:root /home/john
# edit the ssh configuration file
sudo vim /etc/ssh/sshd_config
@hedii
hedii / php_string_helper_functions.php
Last active March 4, 2019 10:21
php string helper functions
<?php
/**
* Given a string $haystack, search if it contains the string $needle and return
* true or false. Return false if $haystack or $needle is empty.
*
* @param string $haystack
* @param string $needle
* @return bool
*/
@hedii
hedii / Codeigniter MY_Model.php
Last active August 29, 2015 14:20
Codeigniter MY_Model
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
* MY_Model class.
*
* @extends CI_model
*/
class MY_Model extends CI_model {
/**
@hedii
hedii / gist:b529585bc2d8f97d4471
Last active August 29, 2015 14:20
php string starts_with() ends_with()
<?php
function starts_with($haystack, $needle) {
// search backwards starting from haystack length characters from the end
return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false;
}
function ends_with($haystack, $needle) {
@hedii
hedii / gist:68eb23fe46f7510bea43
Created April 21, 2015 11:58
Move Wordpress from localhost to a server
## Paste all this SQL script in phpMyAdmin (SQL tab) ##
## WARNING: DON'T PUT ANY TRAILING SLASH AT THE END OF THE URL ##
# CHANGE WEBSITE URL
UPDATE wp_options
SET option_value = REPLACE(option_value, 'http://www.oldwebsite.fr', 'http://www.newwebsite.fr')
WHERE option_name = 'home'
OR option_name = 'siteurl';
@hedii
hedii / gist:320c5aa45e11ddd765e7
Last active March 4, 2019 10:19
Php get_string_between function
<?php
/**
* get_string_between function.
*
* Given a string ($string) and two delimiters ($start and $end), this function
* returns the substring between $start and $end. $start and $end are also
* removed.
*
* @link http://www.justin-cook.com/wp/2006/03/31/php-parse-a-string-between-two-strings/