Skip to content

Instantly share code, notes, and snippets.

View sylvaincombes's full-sized avatar

Sylvain Combes sylvaincombes

View GitHub Profile
@sylvaincombes
sylvaincombes / regexp-find-img-no-alt-1
Last active April 8, 2024 21:07
Regular expression to find image tag in html without an alt attribute
<img(?=\s|>)(?!(?:[^>=]|=(['"])(?:(?!\1).)*\1)*?\salt=['"])[^>]*.*?\/>
@sylvaincombes
sylvaincombes / gist:355933902b3b156efcc6
Last active August 29, 2015 14:05
Regular expression to find all html link tag without an title attribute
<a(?=\s|>)(?!(?:[^>=]|=(['"])(?:(?!\1).)*\1)*?\stitle=['"])[^>]*>.*?<\/a>
@sylvaincombes
sylvaincombes / disable-foreign-key.sql
Created September 2, 2014 10:40
Mysql disable foreign key
-- disable
SET FOREIGN_KEY_CHECKS = 0;
-- truncate for example
TRUNCATE mytable;
-- enable
SET FOREIGN_KEY_CHECKS = 1;
@sylvaincombes
sylvaincombes / git-change-origin.sh
Created September 2, 2014 10:42
Git change origin of a repo
git remote set-url origin git://new.url.here
@sylvaincombes
sylvaincombes / my-external-ip.sh
Last active July 7, 2024 10:38
View your external ip from linux / unix shell
# with dig (fastest way)
dig +short myip.opendns.com @resolver1.opendns.com;
# alternative
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'"' '{ print $2}';
######################################################################################################
## Other method with curl / get and 3rd party, this choice is less judicious
######################################################################################################
# with curl
@sylvaincombes
sylvaincombes / responsive_video_embed.css
Created April 1, 2015 10:30
Responsive embedded video
/**
* Fluid embedded video via iframe / embed / object techniques
* Works fine with just these css rules, if you want accurate results you can add a pinch of javascript too
*
* @see https://css-tricks.com/NetMag/FluidWidthVideo/Article-FluidWidthVideo.php
*/
/* <RESPONSIVE IFRAME / EMBED / OBJECT VIDEOS> */
.video-container {
@sylvaincombes
sylvaincombes / visual-debug-hx.js
Created June 18, 2015 15:53
Visual Debug of titles in a html page (copy / paste code in the js console on a site with jquery)
$(':header').each(function (index) {
$(this).css('border', '2px solid red')
.css('background', '#393939')
.css('color', 'white')
.css('padding', '10px')
.append(' [' + $(this).get(0).tagName + ']');
});
@sylvaincombes
sylvaincombes / browserify + babelify + babelify-presets-2015
Created December 15, 2015 10:11
Command line to compile javascript with a browserify + babelify + babelify-presets-2015 combo
browserify ${SOURCES_JS} --debug --outfile ${DESTINATION_JS} -t [ babelify --presets [ es2015] ];
@sylvaincombes
sylvaincombes / FormHelper.php
Created April 29, 2016 12:59
Symfony get all errors on form with collections (children with form validate and errors)
<?php
namespace AppBundle\Utils;
use Symfony\Component\Form\Form;
/**
* Class FormHelper
*
* @package AppBundle\Utils
*/
@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>