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 / factories.yml
Created November 28, 2014 19:31
sf1.4 mailer factory
# prod/dev (all throws error)
prod:
mailer:
class: sfMailer
param:
logging: %SF_LOGGING_ENABLED%
charset: %SF_CHARSET%
delivery_strategy: realtime
transport:
class: Swift_SmtpTransport
@sglessard
sglessard / gist:fe9ad844481dc5ec6990
Last active August 29, 2015 14:09
PHP/symfony1 - Action : redirect with GET parameters (utm)
/**
* @param string $route
* @param int $statusCode
* @throws sfStopException
*/
protected function redirectWithParams($route,$statusCode=302) {
$url = $this->getController()->genUrl($route);
if (sizeof($this->getRequest()->getGetParameters()) > 0)
@sglessard
sglessard / gist:8697dc9c51a8c8e8c868
Created November 14, 2014 16:24
Temps App - composer.json
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/", "SymfonyStandard": "app/" }
},
"require": {
"php": ">=5.3.3",
@sglessard
sglessard / functions.php
Created April 1, 2014 17:01
Wordpress custom rewrite example
/**
* Custom rewrite rule
* 1) conseils-pratiques/trucs-et-astuces clienteles
*
* Note: using page_id param seems important (no luck with pagename param)
*
* @param $wp_rewrite
*/
function kw_custom_rewrite( $wp_rewrite ) {
$feed_rules = array(
@sglessard
sglessard / git-add-colorbx
Created March 25, 2014 19:58
Colorbox git add
# new file: wp-content/themes/sgl/css/colorbox.css
# new file: wp-content/themes/sgl/css/colorbox/border.png
# new file: wp-content/themes/sgl/css/colorbox/controls.png
# new file: wp-content/themes/sgl/css/colorbox/loading.gif
# new file: wp-content/themes/sgl/css/colorbox/loading_background.png
# new file: wp-content/themes/sgl/css/colorbox/overlay.png
# modified: wp-content/themes/sgl/footer.php
# modified: wp-content/themes/sgl/header.php
# new file: wp-content/themes/sgl/js/jquery.colorbox-fr.js
# new file: wp-content/themes/sgl/js/jquery.colorbox-min.js
@sglessard
sglessard / dots.php
Last active August 29, 2015 13:57
Get CSS background offset of 4 dots
function pr($l,$k,$j,$i) {
echo '<pre>';
echo $l.$k.$j.$i;
$dec = bindec($l.$k.$j.$i);
echo ' DEC: '.$dec;
echo ' CSS OFFSET: '.-($dec*36).'px';
echo '</pre>';
}
function css($l,$k,$j,$i) {
#content{
position:absolute;
left:0;
right:0;
margin-left:auto;
margin-right:auto;
}
@sglessard
sglessard / jquery.filtertable.js
Created March 10, 2014 19:12
jquery.filtertable.js modification to not reset when clicking on keyword input https://github.com/sglessard/jQuery.FilterTable/blob/master/jquery.filtertable.js
/**
* jquery.filterTable
*
* This plugin will add a search filter to tables. When typing in the filter,
* any rows that do not contain the filter will be hidden.
*
* Utilizes bindWithDelay() if available. https://github.com/bgrins/bindWithDelay
*
* @version v1.5
* @author Sunny Walker, swalker@hawaii.edu
@sglessard
sglessard / wodpress-sql-example-user-usermeta
Created February 24, 2014 19:48
Wordpress SQL with users and usermeta
SELECT wp_users.*, meta_lastname.meta_value as last_name, meta_firstname.meta_value as first_name, meta_workplace.meta_value as workplace, meta_desc.meta_value as description
FROM wp_users
INNER JOIN wp_usermeta AS meta_lastname ON (wp_users.ID = meta_lastname.user_id) AND (meta_lastname.meta_key = 'last_name')
INNER JOIN wp_usermeta AS meta_firstname ON (wp_users.ID = meta_firstname.user_id) AND (meta_firstname.meta_key = 'first_name')
INNER JOIN wp_usermeta AS meta_ulevel ON (wp_users.ID = meta_ulevel.user_id) AND (meta_ulevel.meta_key = 'wp_user_level')
INNER JOIN wp_usermeta AS meta_workplace ON (wp_users.ID = meta_workplace.user_id) AND (meta_workplace.meta_key = 'workplace')
INNER JOIN wp_usermeta AS meta_desc ON (wp_users.ID = meta_desc.user_id) AND (meta_desc.meta_key = 'description')
WHERE
CAST(meta_ulevel.meta_value AS CHAR) != '0'
AND CAST(meta_workplace.meta_value AS CHAR) LIKE '%{$workplace}%'
@sglessard
sglessard / wodpress-sql-example-post-postmeta
Created February 19, 2014 20:20
Wordpress SQL with post and postmeta (using ACF plugin to manage custom types)
global $wpdb;
$sql = "
SELECT wp_posts.*, meta1.meta_value as employee_nom, meta2.meta_value as employee_prenom, bureau.post_title
FROM {$wpdb->posts} wp_posts
INNER JOIN {$wpdb->postmeta} meta1 on meta1.post_id = wp_posts.ID and meta1.meta_key = 'employee_nom'
INNER JOIN {$wpdb->postmeta} meta2 on meta2.post_id = wp_posts.ID and meta2.meta_key = 'employee_prenom'
INNER JOIN {$wpdb->postmeta} meta3 on meta3.post_id = wp_posts.ID and meta3.meta_key = 'employee_bureau'
INNER JOIN {$wpdb->posts} bureau on bureau.ID = meta3.meta_value
WHERE