Python IMAP search using a subject encoded with utf-8

import imaplib import getpass email = “[email protected]” sock = imaplib.IMAP4_SSL(“imap.gmail.com”, 993) sock.login(email, getpass.getpass()) # select the correct mailbox… sock.select() # turn on debugging if you like sock.debug = 4 then: # use the undocumented IMAP4.literal attribute sock.literal = “réception” sock.uid(‘SEARCH’, ‘CHARSET’, ‘UTF-8’, ‘SUBJECT’)

Find a file within all possible folders?

This code fragment retrieves a list of all logical drives on the machine and then searches all folders on the drive for files that match the filename “Cheese.exe”. Once the loop has completed, the List “files” contains the var files = new List<string>(); //@Stan R. suggested an improvement to handle floppy drives… //foreach (DriveInfo d … Read more

Ruby on Rails: Advanced search

You can create a new controller called search. Your search form: <%= form_tag search_index_path, method: :get do %> <%= text_field_tag :project, params[:project] %> <%= text_field_tag :client, params[:client] %> <%= submit_tag “Search”, name: nil %> <% end %> incude in your routes.rb: get “search/index” your search controller: def index #store all the projects that match the … Read more

Lucene: Multi-word phrases as search terms

The reason why you don’t get your documents back is that while indexing you’re using StandardAnalyzer, which converts tokens to lowercase and removes stop words. So the only term that gets indexed for your example is ‘crescent’. However, wildcard queries are not analyzed, so ‘the’ is included as mandatory part of the query. The same … Read more

Recursive array_search

You can change your recursive function like this, which should give you the solution: function recursive_array_search($needle, $haystack, $currentKey = ”) { foreach($haystack as $key=>$value) { if (is_array($value)) { $nextKey = recursive_array_search($needle,$value, $currentKey . ‘[‘ . $key . ‘]’); if ($nextKey) { return $nextKey; } } else if($value==$needle) { return is_numeric($key) ? $currentKey . ‘[‘ .$key … Read more

How to search for a string in files with Ant (make sure certain string isn’t found in source files)

You might consider using fileset selectors to do this. Selectors allow you to choose files based on content, size, editability and so on. You can combine selectors with name-based includes and excludes, or patternsets. Below is an example. The second fileset is derived from the first, with a selector that simply matches on file content. … Read more