Skip to content

Instantly share code, notes, and snippets.

View sylvaincombes's full-sized avatar

Sylvain Combes sylvaincombes

View GitHub Profile
@sylvaincombes
sylvaincombes / Redirecting *.localhost to localhost
Last active September 28, 2020 14:53
redirecting all sites with domain .localhost to localhost - dev tip
sudo apt-get install dnsmasq;
sudo nano /etc/dnsmasq.conf;
# Add the content showed below ( dnsmasq.conf )
sudo apt-get install resolvconf;
sudo nano /etc/resolvconf/resolv.conf.d/base;
# Add the content showed below ( base )
# now all whatever.localhost should resole to your localhost
@sylvaincombes
sylvaincombes / mysql-charset-collation-change.sql
Created September 5, 2018 15:55
Generate alter table queries for charset and collation changes
# Generate alter table queries for charset and collation changes - change $DBNAME$ / $CHARSET$ / $COLLATION$
# Tables
SELECT CONCAT('ALTER TABLE ', table_name, ' CHARACTER SET $CHARSET$ COLLATE $COLLATION$;')
FROM information_schema.TABLES AS T, information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` AS C
WHERE C.collation_name = T.table_collation
AND T.table_schema = '$DBNAME$'
AND
(
C.CHARACTER_SET_NAME != '$CHARSET$'
@sylvaincombes
sylvaincombes / temp-git-pull-on-one-file.sh
Created February 20, 2018 09:32
temp git pull on one file
#!/usr/bin/env bash
git fetch --all # read distant git datas
git checkout origin/master -- composer.lock # get only the composer.lock file from origin/master
# [do your things]
git reset HEAD composer.lock # cancel operations on composer.lock file
git checkout composer.lock # reset composer.lock file to the previous state (back to a clean git status)
@sylvaincombes
sylvaincombes / for-each-directory-exec.sh
Created October 23, 2017 10:29
Bash, go in each directory to launch a command, one liner style
# One liner style
# find all directory with name "*myDirectoryCommonName*", go in the directory, launch commands, repeat
for D in `find . -maxdepth 1 -type d | grep myDirectoryCommonName`; do cd "${D}" && git pull && ./app/bin/2017-06-migration.sh && cd ..; done
@sylvaincombes
sylvaincombes / mysql_charset.sh
Created October 16, 2017 08:32
script to convert MySQL/MariaDB charset and collation on one database, all tables and columns
#!/usr/bin/env bash
usage="
script to convert MySQL/MariaDB charset and collation on one database, all tables and columns
/!\ Use at your own risk, data loss can occur !
USAGE
$(basename "$0") [options] [action] db_name db_user db_password
@sylvaincombes
sylvaincombes / keybase.md
Created October 6, 2017 07:56
keybase.md

Keybase proof

I hereby claim:

  • I am sylvaincombes on github.
  • I am sylvaincombes (https://keybase.io/sylvaincombes) on keybase.
  • I have a public key ASCWLu-veKq9Kc4RZuBz3i8-m5PhA8ASQzyZT2DMpsH2xAo

To claim this, I am signing this object:

@sylvaincombes
sylvaincombes / OSX - Selenium server standalone + drivers - quick version with brew.sh
Last active August 29, 2017 14:03
OSX - Selenium server standalone + drivers - quick version with brew
brew install selenium-server-standalone chromedriver geckodriver;
selenium-server -port 4444;
@sylvaincombes
sylvaincombes / .htaccess
Created July 7, 2017 13:17
Http Auth on host condition
<IfVersion >= 2.4>
<If "%{HTTP_HOST} == 'recette.myproject.company.com'">
AuthName "My project"
AuthType Basic
AuthUserFile "/home/www/recette.myproject.company.com/.htpasswd"
Require valid-user
</If>
</IfVersion>
@sylvaincombes
sylvaincombes / config.yml
Last active March 30, 2018 08:51
Symfony Ivory CkEditor protect twig syntax protectedSource
ivory_ck_editor:
configs:
default:
# ...
# protect twig syntax
entities: false
protectedSource: ["/\{\{[\s\S]*?\}\}/g", "/\{\%%[\s\S]*?\%%\}/g", "/\{\#[\s\S]*?\#\}/g"]
# @see http://ckeditor.com/addon/showprotected for a plugin with a visual indicator / editor of protected source if needed
@sylvaincombes
sylvaincombes / index.html
Last active February 7, 2020 14:53
Ckeditor : Allow and preserve twig syntax
<script type="text/javascript">
// Allow and preserve twig syntax @see http://stackoverflow.com/questions/20977910/editing-twig-templates-in-ckeditor
// Can also be coupled with this plugin : http://ckeditor.com/addon/showprotected
CKEDITOR.config.protectedSource.push(/\{\{[\s\S]*?\}\}/g);
CKEDITOR.config.protectedSource.push(/\{\%[\s\S]*?%\}/g);
CKEDITOR.config.protectedSource.push(/\{\#[\s\S]*?#\}/g);
</script>