Skip to content

Instantly share code, notes, and snippets.

View sglessard's full-sized avatar
🏠
Working from home

Simon Guillem-Lessard sglessard

🏠
Working from home
View GitHub Profile
@sglessard
sglessard / sf14_get_raw_value
Created October 17, 2023 16:12 — forked from melz/sf14_get_raw_value
Obtain the raw value from an sfOutputEscaperArrayDecorator object
<?php
// 1) Escaping on; View template
$manufacturers = $sf_user->getAttribute('manufacturer_ids', array(), 'mdUser');
$user_manufacturers->getRawValue(); // returns an array()
// for variables in view template
echo $sf_data->getRaw('variable_name');
// disable escaping from class method output
@sglessard
sglessard / phpunit
Created July 3, 2023 19:31
Make phpunit works with symfony 2.7, file at ~/vendor/symfony/symfony/phpunit
#!/usr/bin/env php
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@sglessard
sglessard / semantic-commit-messages.md
Last active November 15, 2022 16:51 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@sglessard
sglessard / ip_in_range.php
Created October 29, 2021 20:06 — forked from tott/ip_in_range.php
php check if IP is in given network range
/**
* Check if a given ip is in a network
* @param string $ip IP to check in IPV4 format eg. 127.0.0.1
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed
* @return boolean true if the ip is in this range / false if not.
*/
function ip_in_range( $ip, $range ) {
if ( strpos( $range, '/' ) == false ) {
$range .= '/32';
}
@sglessard
sglessard / ddos.txt
Created January 19, 2021 13:42 — forked from bom-d-van/ddos.txt
Detecting and Mitigating DDOS Attacks
Detecting and Mitigating DDOS Attacks
#List all Finish (FIN) packets
machine1 : sudo /usr/sbin/tcpdump -Nnn -i any -s0 'tcp[13] & 1 != 0'
#List all SYN and SYN-ACK packets
machine1 : sudo /usr/sbin/tcpdump -Nnn -i any -s0 'tcp[13] & 2 != 0'
highlightClue: function() {
var clue;
$('.clues-active').removeClass('clues-active');
$('#puzzle-clues li' + '[data-position=' + activePosition + ']').addClass('clues-active');
if (mode === 'interacting') {
clue = $('#puzzle-clues li' + '[data-position=' + activePosition + ']');
activeClueIndex = $(clueLiEls).index(clue);
// If all input have been filled, strike the clue
@sglessard
sglessard / _articles.scss
Last active February 28, 2018 19:13
LeDevoir #11461497 Articles CSS : si on permet l'image de la caricature ET l'image du grincheux
// .opinions
article + section,
section + section {
margin-top:$grid-gutter-width * 3/4;
}
6&zwnj;75 Massachusetts Ave, Cambridge, MA 02139
@sglessard
sglessard / debug.php
Created July 13, 2015 19:36
Wordpress debug actions/filters (Pmc_Debug::record_action)
<?php
class Pmc_Debug
{
protected static $_threshold_to_hide = 0.1;
public static function get_threshold_to_hide() {
return static::$_threshold_to_hide;
}
public static function set_threshold_to_hide( $time ) {
@sglessard
sglessard / cookies.js
Created June 8, 2015 16:02
Mozilla : A complete cookies reader/writer framework with full unicode support.
/*\
|*|
|*| :: cookies.js ::
|*|
|*| A complete cookies reader/writer framework with full unicode support.
|*|
|*| Revision #1 - September 4, 2014
|*|
|*| https://developer.mozilla.org/en-US/docs/Web/API/document.cookie
|*| https://developer.mozilla.org/User:fusionchess