Tag Archive for search

Optionally Serve Statically Compressed CSS & JS

# no weird non-ASCII quotes! Arg! They wasted an hour of time!
# info: <a href="http://www.bluehostforum.com/showthread.php?t=11402" >http://www.bluehostforum.com/showthread.php?t=11402</a>

Options +followsymlinks

<FilesMatch ".js.gz$">
ForceType text/javascript
Header set Content-Encoding: gzip
</FilesMatch>
<FilesMatch ".js$">
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} !".*Safari.*"
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule (.*).js$ $1.js.gz [L]
ForceType text/javascript
</FilesMatch>

<FilesMatch ".css.gz$">
ForceType text/css
Header set Content-Encoding: gzip
</FilesMatch>
<FilesMatch ".css$">
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} !".*Safari.*"
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule (.*).css$ $1.css.gz [L]
ForceType text/css
</FilesMatch>

source

Grep for files that do not match a pattern

grep -L "the pattern" *

# to recurse into subdirectories

grep -RL "the pattern" *

source

Perl Keyword Search (One Liner)

#!/bin/sh

tail -n5000 somefile | perl -ne "print $_ if /$1/i && /$2/i && /$3/i && /$4/i && /$5/i;"

source

Search form with onblur and onfocus text

<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
<input type="text" onblur="if (this.value == '') {this.value = 'To search, type and hit enter';}" onfocus="if (this.value == 'To search, type and hit enter') {this.value = '';}" value="<?php if ($_REQUEST['s']) { the_search_query(); } else { echo 'To search, type and hit enter'; } ?>" name="s" id="s" />
</form>

source

Code Igniter Search for multiple words

/**
* SearchEntries
*
* Options: Values
* ---------------
* words
*
* @param array $options
* @return bool
*/
function SearchEntries($options = array())
{

$search_result = array();

$words = explode(" ", $options['words']);

foreach($words as $word){
if(isset($options['limit']) && isset($options['offset'])) $search_result = array_merge($search_result,$this->GetEntries(array('word' => $word, 'sortBy' => $options['sortBy'], 'sortDirection' => $options['sortDirection'], 'limit' => $options['limit'], 'offset' => $options['offset'])));
else $search_result = array_merge($search_result, $this->GetEntries(array('word' => $word)));
}

// unique multidimential array for entryid
$new = array();
$exclude = array("");
for ($i = 0; $i<=count($search_result)-1; $i++) {
if (!in_array(trim($search_result[$i]->entryId) ,$exclude)) {
$new[] = $search_result[$i];

// key and value goes into array for testing
$exclude[] = trim($search_result[$i]->entryId);
}
}

//print_r($new);
return $new;
}

source

GNU search plugin for Firefox

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>GNU</ShortName>
<Description>Search GNU.org</Description>
<InputEncoding>UTF-8</InputEncoding>
<Tags>gnu</Tags>
<Image width="16" height="16">data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAADe0lEQVRIx+WTXUjTURjGnzP/f/yay+XXhsYMFKXcTHH8QzIVgyTLUohEImjqxUokAq/yI6gu8kYqFPMDo4z0okEQxEKtiR/o5gfJqDBiU0T8mM7ZZtL07WIMvWgag676XR3Oe3ie933OOYAPBgaGh6emiF686Ol5944IfqLV3r7d0ECUkZGbe/36PjpW69zcwgJRSYlGU1Pjv+FBCMKZM+Xlf9Dv6dHpensPNm5re/78zRui0tKKivr63fONje3tfX1EGk1l5YMHvnWqq+vqnjzZrYuGh0dHP30ievtWrx8c9G3c2/vxo9FINDJiNJrNwMbGzo5cDmi1tbU6HVFHR3e3wQDMzs7Pr6wAmZlnz1ZUECUnq9VXruwaZmScOJGcvKsryswUBJWKsdDQkJDgYODYMUEoKSHq6xsYMJmI9Pr+/rExoubm7u7paSAlJS0tOxvQaq9dy8sDwsLE4uBg4NKlgoKsLCAgQCJJSgJWVmw2ux2Qy2WyyEggJ+f8+Rs3iAyGoaGpqT0NeBepqUplYiJQWHju3OnTgNVqtS4sAGVlVVUNDUB6ulJ59CjgdLpcP38CLS1dXQYDwPMcxxjQ2dnR0d4OzMyYzSMjgEQSE5OSAgjCqVP5+UBgYGAgzwOjoxMTZvMfGtBqNZriYsZcLo/B/fuNjS9fAmFhUqlMBkRFHT4sFgMyWXR0eDjw+fP09NgYsLm5tbWzA9TV1dRUVwNut9u9vQ2sr6+uLi0BRUX5+WlpgF7/+vWjR4yNj3/48OwZY15fBh/Ex6enX71KVFBQWHj5MtDUdPfuxYuM6XTv33/5QjQ/v7i4vg6EhAQF8TywvLy66nQCk5Nms9UKhIcfOhQaCjx9eu9eURHz6SPyVbBYJia6uhjzGnv3OS4ggDFgaMho/PYNWFtzODY3AaUyKUkmAyQSz5tQq1UqheKgP7VPAr54+LC1dXCQiOc5TiTyTDw3B5hMJpPJBHCcZ39jw25fXAQslvHxvZH/dQK+WFqy2RwOgOd5nuOAO3du3szLA06eFAS1GpBKIyLkckAuVyiUyn+QgJfS0lu3Xr0i+vp1Zub7d8BuX162WIDtbbf71y/PFe43ud8JeImMjIgQiwGHw2abnQUUioQElQqQSmNiEhL+XsfvBh4/rq29cIGx2Nj4+OPHgR8/nE6XCzhyJC4uOtpf1f+R3+pKe58Lih1gAAAAAElFTkSuQmCC</Image>
<Url type="text/html" method="GET" template="http://www.google.com/search?q=site:www.gnu.org+info+{searchTerms}"/>
</OpenSearchDescription>

source

Upload File Filter

*.aspx, *.ascx, *.asmx, *.htm, *.dll, *.rpt, *.js, *.jpg, *.jpeg, *.bmp, *.gif, *.css, *.png, *.exe, *.xls, *.doc, *.cab, *.doc

source

Create a textfile listing all paths to a certain file or wildcard.

Function writeAllPaths([string]$fromFolder,[string]$filter,[string]$printfile) {
Get-ChildItem -Path $fromFolder -Recurse $filter | Select-Object -Property FullName > $printfile
}

source

Jquery advanced search

$("div.ukn-search-advanced-button").click(function() {
$("div.ukn-search-advanced-button").toggleClass('ukn-active');
$("div.ukn-search-advanced").slideToggle(300);
/* .ukn-search-advanced-cat */
$("div.ukn-search-advanced ul.ukn-search-advanced-cat li:not(.ukn-list-title)").click(function() {
$('div.ukn-search-advanced ul.ukn-search-advanced-cat li.ukn-selected').removeClass('ukn-selected');
$(this).addClass('ukn-selected');
var text = $(this).text();
$(".ukn-form-hidden-cat").val(text);
//$(".ukn-form-searchbox").val(text);
});
/* .ukn-search-advanced-sort */
$("div.ukn-search-advanced ul.ukn-search-advanced-sort li:not(.ukn-list-title)").click(function() {
$('div.ukn-search-advanced ul.ukn-search-advanced-sort li.ukn-selected').removeClass('ukn-selected');
$(this).addClass('ukn-selected');
var text = $(this).text();
$(".ukn-form-hidden-sort").val(text);
});
return false;
});

source

Linux Command for Listing all files which contains the word ‘abc’

find / -type f -exec grep -H 'abc' {} ;

source