Skip to content

Instantly share code, notes, and snippets.

@rlandas
rlandas / README.md
Created November 7, 2018 13:22
Lannister React application

README

React application

@rlandas
rlandas / CastInterface.php
Last active November 7, 2018 13:18
EthicalJobs
<?php
namespace Cinema\Cast;
/**
* Family interface
*
* @author Raphael Landas
* @package MyApp
* @copyright 2018 EthicalJobs
@rlandas
rlandas / php-html-remove-leading-trailing-space.php
Created April 4, 2016 01:14
PHP - remove leading and trailing spaces in HTML
final class Html
{
static public function removeComments($content = '')
{
return preg_replace('/<!--(.|\s)*?-->/', '', $content);
}
static public function sanitize($content)
{
$search = array(
@rlandas
rlandas / git_revert_file.sh
Created February 29, 2016 23:10
GIT - Revert one deleted file
# Find the last commit that affected the given path. As the file isn't in the HEAD commit, this commit must have deleted it.
git rev-list -n 1 HEAD -- <file_path>
# Then checkout the version at the commit before, using the caret (^) symbol:
git checkout <deleting_commit>^ -- <file_path>
# Or in one command, if $file is the file in question.
git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"
@rlandas
rlandas / gitcurrentbranch.sh
Created February 25, 2016 02:55
GIT - get current branch - displays the current branch, useful for using the current branch into another command as input
git rev-parse --abbrev-ref HEAD
@rlandas
rlandas / git_cherry_pick.sh
Created February 23, 2016 00:57
GIT - Merge specific commit from one branch to current working branch
git cherry-pick <commit>
@rlandas
rlandas / testme.sh
Last active January 15, 2016 05:12
BASH: Checking if command line has arguments (@see http://linuxcommand.org/wss0130.php)
#!/bin/bash
function testMe {
message=$1;
# check if there is an argument given
if [ "$1" != "" ]; then
echo -e "Test Me: $message\n";
fi
@rlandas
rlandas / regex.php
Created January 6, 2016 03:44
REGEX : contains english and non-english characters
if(preg_match('/[^[:alpha:][:punct:][:digit:]]/u', utf8_encode($input)) {
// contains english and non-english characters
}
@rlandas
rlandas / core.php
Last active January 6, 2016 03:36
REGEX: only contains integers
// only contains integers
if(ctype_digit((string) $string)){
// only contains integers
}
@rlandas
rlandas / composer.json
Last active November 27, 2015 03:12
COMPOSER Merge composer.json from non-composer installed packages in module/package folder
"require":{
"wikimedia/composer-merge-plugin":"~1.0"
},
"extra":{
"merge-plugin":{
"include":[
"module/*/composer.json",
"module/*/*/composer.json"
],
"recurse":true,