Latest 100 public
snipts » filter
showing 1-12 of 12 snipts for filter
-
∞ symfony ssl redirect filter
http://grahamc.com/blog/forcing-ssl-with-symfony-1-2 -
∞ 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); } } ?>
-
∞ 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: ~
-
∞ 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
-
∞ 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
-
∞ 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
-
∞ PNG in IE 6 Fixes
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(...); Methods:::::::::::::::::::::: SuperSleight Fix Twin Helix Fix Google’s IE 7.js
-
∞ Filter value
$value = preg_replace("/([^a-zA-Z0-9])/", "-", $value); -
∞ 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%'"); } } ?>
-
∞ 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 ?>
-
∞ Filter FileAge
filter FileAge($days) { if ( ($_.CreationTime -le (Get-Date).AddDays($days * -1) )) { $_ } } Example: Dir $home\*.ps1 | FileAge 10 | Del -WhatIf -
∞ Text filter for Twitterrific
defaults write com.iconfactory.Twitterrific tweetTextFilter -string 'blip\.fm'


