Skip to content

Instantly share code, notes, and snippets.

hedii hedii

Block or report user

Report or block hedii

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ubuntu-new-chroot-user.sh
# 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 Mar 4, 2019
php string helper functions
View php_string_helper_functions.php
<?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 Aug 29, 2015
Codeigniter MY_Model
View Codeigniter MY_Model.php
<?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 Aug 29, 2015
php string starts_with() ends_with()
View gist:b529585bc2d8f97d4471
<?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 Apr 21, 2015
Move Wordpress from localhost to a server
View gist:68eb23fe46f7510bea43
## 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 Mar 4, 2019
Php get_string_between function
View gist:320c5aa45e11ddd765e7
<?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/
You can’t perform that action at this time.