Sign up to create your own snipts, or login.

Public snipts » filter The latest public filter snipts.

showing 1-10 of 10 snipts for filter
  • 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 = ereg_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.