IMPORTANT!

Snipt is going open source. We've toyed with this idea for quite a while, and have finally decided it's the right way to move forward.

A few things:
  • The entire Snipt source code will be released on GitHub under the 3-clause BSD License on Friday, September 10th.
  • While we'd like to think we're perfect, we realize we're only human. By open sourcing the software that runs this website, certain bugs or security flaws may be discovered that could compromise the privacy of your snipts.
  • Only the Lion Burger team will be able to push commits to the Snipt.net site. Contributors should send a pull request to add new features or submit patches.
  • By using this site, you agree not to be too angry or take any legal action against Lion Burger should this whole thing go up in flames some day.
  • Follow us on Twitter for updates.
I agree, close this message
Sign up to create your own snipts, or login.

Latest 100 public snipts » filter The latest public filter snipts.

showing 1-12 of 12 snipts for filter
  • symfony ssl redirect filter
    http://grahamc.com/blog/forcing-ssl-with-symfony-1-2
    

    copy | embed

    0 comments - tagged in  posted by manec on Mar 31, 2010 at 10:58 a.m. EDT
  • custom filter
    <?php 
    class VinoFormFilter extends BaseVinoFormFilter
    {
      public function configure()
      {
    
        $this->setWidget('nombre', new sfWidgetFormFilterInput());
        $this->setValidator('nombre', new sfValidatorPass());
    
        $this->validatorSchema->addOption('allow_extra_fields', true); 
      }
    
      public function getFields()
      {
        return array_merge(array('nombre' => 'Nombre'), parent::getFields());
      }
    
      protected function addNombreColumnCriteria(Criteria $criteria, $field, $values){
        $criteria->add(ItemPeer::NOMBRE, "%".$values['text']."%", Criteria::LIKE);
      }
    
    }
    ?>
    

    copy | embed

    0 comments - tagged in  posted by manec on Mar 20, 2010 at 10:05 p.m. EDT
  • symfony filter to check db availability
    <?php
    // symfony filter to check db availability 
    class checkAvailibilityDbFilter extends sfFilter
    {
      public function execute($filterChain)
      {
        if ($this->isFirstCall())
        {
          $context = $this->getContext();
    
          $module = sfConfig::get('app_checkdb_module', 'default');
          $action = sfConfig::get('app_checkdb_action', 'error404');
    
          if (($module != $context->getModuleName()) || ($action != $context->getActionName()))
          {
            $configuration = sfProjectConfiguration::getActive();
            $db = new sfDatabaseManager($configuration);
    
            foreach ($db->getNames() as $connection)
            {
              try
              {
                @$db->getDatabase($connection)->getConnection();
              }
              catch(Exception $e)
              {
                 $context->getController()->forward($module, $action);
                 exit;
              }
            }
          }
        }
    
        $filterChain->execute();
      }
    }
    ?>
    // in your app.yml file
    all:
      checkdb:
        module: default
        action: checkAvailibility
    
    
    // in your filters.yml file
    rendering: ~
    security:  ~
    
    # insert your own filters here
    db:
      class:  checkAvailibilityDbFilter
    
    cache:     ~
    common:    ~
    execution: ~
    

    copy | embed

    0 comments - tagged in  posted by gestadieu on Feb 26, 2010 at 9:18 p.m. EST
  • Form Filter: choice widget for text field
    <?php
    
    // sfGuardPlugin/lib/filter/sfGuardUserProfileFormFilter.class.php
    class sfGuardUserProfileFormFilter extends BasesfGuardUserProfileFormFilter
    {
      public function configure()
      {
        //drop down list for profession
        $this->widgetSchema['profession'] = new sfWidgetFormChoice(array(
                'choices'  => sfGuardUserPeer::getFilterProfessions(),
        ));
        $this->validatorSchema['profession'] = new sfValidatorChoice(array(
                'choices' => array_keys(sfGuardUserPeer::getFilterProfessions())
        ));
       
        //drop down list for access level
        $this->widgetSchema['accesslevel'] = new sfWidgetFormChoice(array(
                'choices'  => sfGuardUserPeer::getFilterLevels(),
        ));
        $this->validatorSchema['accesslevel'] = new sfValidatorChoice(array(
                'choices' => array_keys(sfGuardUserPeer::getFilterLevels())
        ));
      } //end configure()
      
      // overwrite the method convertProfessionValue(),
      // if field "profession" is not selected, 
      public function convertProfessionValue($value)
      {
        return $value != 'none' ? $value : false;
      }
      
      public function convertAccesslevelValue($value)
      {
        return $value != 'none' ? $value : false;
      }
    
      //overwrite getFields() from parent class,and change profession, accesslevel into ForeignKey
      public function getFields()
      {
        return array(
          'profession'    => 'ForeignKey',
          'accesslevel'   => 'ForeignKey',
          'categories_id' => 'ForeignKey',
        );
      }//end getFields()
    }
    
    
    <?php
    
    /**
     *
     * sfGuardUserPeer
    */
    
    class sfGuardUserPeer extends PluginsfGuardUserPeer {
      // defining the user types
      static public $theUserType = array(
              '0' => 'Technical', '1' => 'Internal', '2' => 'External'
          );
      
      static public function getFilterLevels() {
            return array_merge(array('none' => ''), self::$theUserType);
      }
    
      // defining the profession
      static public $theProfession = array(
              'lecturer'   => 'Lecturer', 
              'researcher' => 'Researcher', 
              'student'    => 'Student', 
              'other'      => 'Other'
          );
    
      static public function getFilterProfessions() {
            return array_merge(array('none' => ''), self::$theProfession);
      }
    }// endd sfGuardUserPeer
    

    copy | embed

    0 comments - tagged in  posted by toledot on Jan 24, 2010 at 1:12 p.m. EST
  • filter ANME from ANME1_Endseq
    import sys
    
    ANME = set()
    for line in sys.stdin:
    	ANME.add(line.rstrip())
    
    	
    
    input = sys.argv[1]
    f = open (input, 'r')
    printIt = False
    
    
    for line in f.readlines():
    
       if line.find ('>') != -1 and line[1:].rstrip() not in ANME:
    	print line.rstrip()
    	printIt = True
    
       if line.find ('>') == -1 and printIt == True:
    	print line
    	printIt = False
    

    copy | embed

    0 comments - tagged in  posted by dgg32 on Jan 04, 2010 at 5:45 a.m. EST
  • filter the SSAHA2 result
    #to filter the SSAHA2 result like
    #===================================================
    #Matches For Query 20489 (913 bases): b201.1e11.f.b1
    #===================================================
    #Score     Q_Name             S_Name            Q_Start    Q_End  #S_Start    S_End Direction #Bases identity
    #ALIGNMENT::00 730   b201.1e11.f.b1 SC02       15      816    288648    #289465   F     802 97.51 913
    #ALIGNMENT::00 730   b201.1e11.f.b1 SC05       15      816     34214     #35031   F     802 97.51 913
    
    cat '/megx/home/shuang/result/ANME_vs_ANME1_SSAHA2/ANME_vs_ANME1_Endseq.txt' | egrep "ALIGNMENT" | sed 's/::/:/g' | sed 's/ \+/:/g' | cut -d: -f4,12
    

    copy | embed

    0 comments - tagged in  posted by dgg32 on Jan 04, 2010 at 5:10 a.m. EST
  • PNG in IE 6 Fixes
    filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(...);
    
    Methods::::::::::::::::::::::
    
    SuperSleight Fix
    
    Twin Helix Fix
    
    Googles IE 7.js
    

    copy | embed

    0 comments - tagged in  posted by paz on Sep 07, 2009 at 8:14 a.m. EDT
  • Filter value
    $value = preg_replace("/([^a-zA-Z0-9])/", "-", $value);
    

    copy | embed

    0 comments - tagged in  posted by dominobb on Feb 15, 2009 at 8:07 p.m. EST
  • Symfony 1.2 admin generator customized filter
    <?php
      /* this code goes in your ModelNameFormFilter.class.php within your lib/filter/doctrine folder */
    
      public function configure() {
        // ...
    
        $this->widgetSchema['search'] = new sfWidgetFormFilterInput(array('with_empty' => false));
    
        $this->validatorSchema['search'] = new sfValidatorPass(array('required' => false));
      }
    
    // you can remove the following method in symfony 1.3/1.4+
      public function getFields() {
        return array_merge(array(
            'search'=> 'Text',
          ), parent::getFields()
        );
      } 
    
      protected function addSearchColumnQuery(Doctrine_Query $query, $field, $values) {
    
      // put your customized query here...
      if ($q = $values['text'])
      {
        //$query->joinLeft($this->getRootAlias()...);
        $query->addWhere($this->getRootAlias().".title LIKE '%$q%'");
      }
    }
    ?>
    

    copy | embed

    2 comments - tagged in  posted by gestadieu on Jan 15, 2009 at 8:33 p.m. EST
  • symfony 1.2 - Add a custom filter field for generated admin
    <?php
      public function configure() {
        
        $this->widgetSchema['title'] = new sfWidgetFormFilterInput();
    
        $this->validatorSchema['title'] = new sfValidatorPass(array('required' => false));
      }//configure
    
      public function getFields() {
        return array_merge(array(
            'title'=> 'Title',
          ), parent::getFields()
        );
      } //getFields
    
      protected function addTitleColumnCriteria(Criteria $criteria, $field, $values) {
    
        // $values['text'] contains the field value, use it to change $criteria object
    
        // es. $criteria->add ('column', $values['text'])
    
      }//addTitleColumnCriteria
    
    ?>
    

    copy | embed

    1 comment - tagged in  posted by Tram on Jan 14, 2009 at 12:17 p.m. EST
  • Filter FileAge
    filter FileAge($days) { if ( ($_.CreationTime -le (Get-Date).AddDays($days * -1) )) { $_ } }
    
    
    Example:
    Dir $home\*.ps1 | FileAge 10 | Del -WhatIf
    

    copy | embed

    0 comments - tagged in  posted by betahost on Jan 09, 2009 at 2:47 a.m. EST
  • Text filter for Twitterrific
    defaults write com.iconfactory.Twitterrific tweetTextFilter -string 'blip\.fm'
    

    copy | embed

    0 comments - tagged in  posted by binbasti on Dec 25, 2008 at 8:13 a.m. EST
Sign up to create your own snipts, or login.