Skip to content

Instantly share code, notes, and snippets.

View clemherreman's full-sized avatar

Clement Herreman clemherreman

  • Exotec
  • Lille, France
View GitHub Profile
@clemherreman
clemherreman / actions.class.php
Created June 27, 2011 13:18
Forwarding actions in symfony
<?php
class documentActions extends autoDocumentActions
{
public function executeAttachmentInfoRequestLink(sfWebRequest $request)
{
$infoRequest = $this->getRoute()->getObject();
$this->forward404Unless($infoRequest->isValid());
$this->getUser()->setAttribute('attachmentInfoRequest.document',$infoRequest->getDocument());
<?php
class AttachmentInfoRequestForm extends BaseAttachmentInfoRequestForm
{
public function configure()
{
}
}
@clemherreman
clemherreman / file.css
Created August 5, 2011 14:32
Minified CSS example
.ui-helper-hidden-accessible{position:absolute!important;clip:rect(1px,1px,1px,1px);}.ui-helper-reset{border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none;margin:0;padding:0;}.ui-helper-clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;}* html .ui-helper-clearfix{height:1%;}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0);}.ui-state-disabled{cursor:default!important;}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat;width:16px;height:16px;background-image:url(images/ui-icons_222222_256x240.png);}.ui-widget-overlay{position:absolute;top:0;left:0;width:100%;height:100%;background:#aaa url(images/ui-bg_highlight-hard_40_aaaaaa_1x100.png) 50% top repeat-x;opacity:.30;filter:Alpha(Opacity=30);}.ui-widget{font-family:Verdana, Arial, sans-serif;font-size:1.1em;}.ui-widget .ui-widget{font-size:1em;}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget
@clemherreman
clemherreman / c.js
Created September 27, 2011 16:24
Namespaced Javascript classes, with private/public methods/attributes
(function(C, $, undefined) {
C.Personne = function(name, secret) {
//private attributes
var secret = secret || 'I enjoy perl';
//private function
function tellSecret() {
return 'I have a secret : '+secret;
}
<?php
$i = 1;
do
{
$completeName = sprintf('%s_%05d.pdf', date('Y-m-d'), $i);
}
while(file_exists(sprintf('%s%s', $dir, $completeName))); // Looks like somethign's wrong here.
return $completeName;
@clemherreman
clemherreman / example.js
Created October 25, 2011 15:00
Anonymous functions returning anonymous functions that return what you need.
var qty = parseInt(element.find('.qty').val()) || 0;
var possiblePrices = tierPrices[productId];
var tierPrice = jQuery.grep(possiblePrices , (function(qty) {
var qty = qty || 1;
return function(possiblePrice) {
return (possiblePrice.qty_min <= qty)
&& ((possiblePrice.qty_max > qty) || (possiblePrice.qty_max === 'infinity'));
}
})(qty))[0];
@clemherreman
clemherreman / pisses_me_off.js
Created October 25, 2011 15:13
I'm always lost in front of this
if (something)
{
if (somethingElse)
{
}
else
{
//code that handle part of the error
@clemherreman
clemherreman / controller.php
Created November 2, 2011 09:08
AHHHHHHHHHHHHHHHHHHHHHHHHHHHH
<?php
class Blah_Blah_Blah_Controller extends Mage_Core_Controller_Front_Action
{
public function abonneform1Action()
{
// ...
}
public function abonneform1Action()
{
@clemherreman
clemherreman / Action.class.php
Created November 3, 2011 15:25
Class action
<?php
class Action
{
}
@clemherreman
clemherreman / Action.class.php
Created November 3, 2011 15:59 — forked from n1k0/Action.class.php
Class action
<?php
class Action implements NeedThePolice
{
public function askHelp()
{
return $this->goFuckYourself();
}
private function goFuckYourself()