Skip to content

Instantly share code, notes, and snippets.

View SalvadorP's full-sized avatar
🦊

Salvador P. SalvadorP

🦊
View GitHub Profile
@SalvadorP
SalvadorP / mobilePhonesRegexp.php
Created May 23, 2013 08:51
Regular expressions for checking mobile phones from spain and france.
<?php
$regexES = "/^((0034|\+34|34){1})*(?(?=6)(6){1}[0-9]{8}|(7){1}[1-9]{1}[0-9]{7})$/";
$regexFR = "/^((0033|\+33|33){1})*(?(?=0)(06|07){1}[0-9]{8}|(6|7){1}[0-9]{8})$/";
@SalvadorP
SalvadorP / mataprocesos.sh
Created July 9, 2013 11:14
Shell script to kill all processes with a known name. An example can be creating two sleeping processes. In a terminal write sleep 1234 &. sleep 1234 &. And then ./mataprocesos.sh sleep. And it will kill al processes named with sleep. Can be copied to /bin/ and used like a normal shell command.
#!/bin/bash
if [ -z "$1" ]; then
echo ERROR. Use ./mataprocesos.sh process_name
exit
fi
kill $(ps -cef | grep $1 | awk '{print $2}')
@SalvadorP
SalvadorP / backupdb.sh
Last active August 29, 2015 14:25
Bash script to backup databases, sends an email with info about the results, admits one parameter if you want to backup only one specific database
#!/bin/bash
DATABASES=(db1 db2 dbN)
DATE=$(date +"%Y-%m-%d")
USER=''
PASSWORD=''
DIR='/the/backup/route'
if [ ! -d "$DIR" ]; then
@SalvadorP
SalvadorP / backupsites.sh
Last active August 29, 2015 14:25
Bash script to backup entire sites, copies all the contents of each site directory, sends an email with info about the results, admits one parameter in case you want to backup only one site
#!/bin/bash
SITES=(site1 site2 site3)
DATE=$(date +"%Y-%m-%d")
DIR='/directory/where/sites/are'
BACKUPDIR='/directory/where/to_store/backup'
if [ ! -d "$BACKUPDIR" ]; then
mkdir $BACKUPDIR
@SalvadorP
SalvadorP / videoplayer.html
Last active August 29, 2015 14:27
Simple HTML 5 video player on demand, just paste the video URL and it will begin to play
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple HTML5 Video Player</title>
</head>
<body>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<div>
Video URL: <input type="text" id="videoUrl" name="videoUrl">
@SalvadorP
SalvadorP / l51_artisan_tinker_user_creation.sh
Last active November 19, 2020 17:11
Laravel 5.1 how to create a user using artisan tinker and the standard user model
php artisan tinker
$user = new App\User;
$user->name="Admin";
$user->email="admin@localhost.com";
$user->password=bcrypt('1234');
$user->save();
@SalvadorP
SalvadorP / clickr.html
Created March 31, 2016 14:05
JS Periodic Button Clickr
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CLICK TEST</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
</head>
<body>
@SalvadorP
SalvadorP / d7_base_install.sh
Last active April 25, 2016 14:33
Drupal 7 base installation with Bootstrap 3 theme.
drush dl drupal --drupal-project-rename="drupal"
cd drupal
drush site-install standard --account-name=admin --account-pass=admin --db-url=mysql://user:password@localhost/drupal -y
drush en features, views, date, calendar, token, pathauto, libraries, entity, admin_menu, jquery_update, webform, ckeditor, rules, colorbox, entity_reference, transliteration, field_group, captcha, recaptcha, devel, internationalization, strongarm, search_api, insert, views_data_export, print, simplenews, pathologic, webform_validation, bootstrap, tracker, syslog, statistics, date_popup, feeds_ui, feeds_import, feeds_news, rules_admin, search_api_views, views_ui -y
drush dl mailhandler -y
@SalvadorP
SalvadorP / createFolderTree.php
Created June 28, 2016 14:43
Way to create recursively a folder tree structure, and read it.
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create Folders / Read Folders</title>
</head>
<body>
@SalvadorP
SalvadorP / batchrename.sh
Created February 8, 2017 10:15
Unix CLI batch rename files
# https://stackoverflow.com/questions/3211595/renaming-files-in-a-folder-to-sequential-numbers/34153342#34153342
ls | cat -n | while read n f; do mv "$f" "$n.extension"; done