Linux HowTo: Windows 10 disable internet in search

Original Source Link

I just installed Windows 10 Pro (version 10.0.19041) and I noticed that the “Start menu” search (the one you get when you hit the Windows button on the keyboard and start typing) searches the internet, despite me having disabled this.

What I tried before came from this question:
How to disable internet search results in start menu post Creators Update?

I updated the following in the registry:

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionSearch]
"BingSearchEnabled"=dword:00000000
"AllowSearchToUseLocation"=dword:00000000
"CortanaConsent"=dword:00000000

and I updated the following in the Local Group Policy Editor:

Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > Search

  • Allow Cortana: Disabled
  • Do not allow web search: Enabled
  • Don’t search the web or display web results in Search: Enabled

Then I restarted the computer. Although initially this did work and the search no longer connected to the internet, now (maybe since a Windows update was installed?) it is searching again, I think through Bing since that is the logo it is displaying underneath the search results.

The ellipsis-menu in the search app says Build: 2020.06.03.6245959, in case that is relevant?

Edit: The reason I ask this is because I consider this a privacy issue. I press the windows key to start applications (which I find much faster and convenient than using my touchpad), but I don’t want every keystroke to be sent to the internet.

Tagged : / /

Ubuntu HowTo: Is there any plugin available to highlight the matched search text in Terminator?

Original Source Link

I would like to search from the tail result in my current tab. Terminator provides option to search for certain text – but since it’s not highlighting the matched text not able to find it easily.

Is there any plugin available which I can include to Terminator which can help me to highlight the matched search result.

Thanks in Advance !

What you want isn’t yet a built-in feature but is slated for a future release.

From here

It is possible to search the buffer, although at this time there is a limitation that the found string is not highlighted.

and

At this time there is no highlighting of the search string. This is a historical limitation due to the manner in which the implmentation was originally done, way back when. I intend to remove the old code, replacing with the built-in libvte search function in the 2.1 release. This will then highlight searched text.

Neither this page nor this page point to the 2.1 release.

And according to this page, there doesn’t seem to be a plugin to provide the feature.


You could maybe consider using something else such as gnome-terminal if this feature is important to you.

There is an open issue on Terminator Github:

https://github.com/gnome-terminator/terminator/issues/4

Also on launchpad:

https://bugs.launchpad.net/ubuntu/+source/terminator/+bug/271487

It is supposed to be released on 2.1 milestone:

https://launchpad.net/terminator/+milestone/2.1

There is no expected release date yet 🙁

Tagged : /

Code Bug Fix: What is the difference between re.search and re.match?

Original Source Link

What is the difference between the search() and match() functions in the Python re module?

I’ve read the documentation (current documentation), but I never seem to remember it. I keep having to look it up and re-learn it. I’m hoping that someone will answer it clearly with examples so that (perhaps) it will stick in my head. Or at least I’ll have a better place to return with my question and it will take less time to re-learn it.

re.match is anchored at the beginning of the string. That has nothing to do with newlines, so it is not the same as using ^ in the pattern.

As the re.match documentation says:

If zero or more characters at the
beginning of string match the regular expression pattern, return a
corresponding MatchObject instance.
Return None if the string does not
match the pattern; note that this is
different from a zero-length match.

Note: If you want to locate a match
anywhere in string, use search()
instead.

re.search searches the entire string, as the documentation says:

Scan through string looking for a
location where the regular expression
pattern produces a match, and return a
corresponding MatchObject instance.
Return None if no position in the
string matches the pattern; note that
this is different from finding a
zero-length match at some point in the
string.

So if you need to match at the beginning of the string, or to match the entire string use match. It is faster. Otherwise use search.

The documentation has a specific section for match vs. search that also covers multiline strings:

Python offers two different primitive
operations based on regular
expressions: match checks for a match
only at the beginning of the string,
while search checks for a match
anywhere in the string (this is what
Perl does by default).

Note that match may differ from search
even when using a regular expression
beginning with '^': '^' matches only
at the start of the string, or in
MULTILINE mode also immediately
following a newline. The “match
operation succeeds only if the pattern
matches at the start of the string

regardless of mode, or at the starting
position given by the optional pos
argument regardless of whether a
newline precedes it.

Now, enough talk. Time to see some example code:

# example code:
string_with_newlines = """something
someotherthing"""

import re

print re.match('some', string_with_newlines) # matches
print re.match('someother', 
               string_with_newlines) # won't match
print re.match('^someother', string_with_newlines, 
               re.MULTILINE) # also won't match
print re.search('someother', 
                string_with_newlines) # finds something
print re.search('^someother', string_with_newlines, 
                re.MULTILINE) # also finds something

m = re.compile('thing$', re.MULTILINE)

print m.match(string_with_newlines) # no match
print m.match(string_with_newlines, pos=4) # matches
print m.search(string_with_newlines, 
               re.MULTILINE) # also matches

search ⇒ find something anywhere in the string and return a match object.

match ⇒ find something at the beginning of the string and return a match object.

match is much faster than search, so instead of doing regex.search(“word”) you can do regex.match((.*?)word(.*?)) and gain tons of performance if you are working with millions of samples.

This comment from @ivan_bilan under the accepted answer above got me thinking if such hack is actually speeding anything up, so let’s find out how many tons of performance you will really gain.

I prepared the following test suite:

import random
import re
import string
import time

LENGTH = 10
LIST_SIZE = 1000000

def generate_word():
    word = [random.choice(string.ascii_lowercase) for _ in range(LENGTH)]
    word = ''.join(word)
    return word

wordlist = [generate_word() for _ in range(LIST_SIZE)]

start = time.time()
[re.search('python', word) for word in wordlist]
print('search:', time.time() - start)

start = time.time()
[re.match('(.*?)python(.*?)', word) for word in wordlist]
print('match:', time.time() - start)

I made 10 measurements (1M, 2M, …, 10M words) which gave me the following plot:

match vs. search regex speedtest line plot

The resulting lines are surprisingly (actually not that surprisingly) straight. And the search function is (slightly) faster given this specific pattern combination. The moral of this test: Avoid overoptimizing your code.

re.search searches for the pattern throughout the string, whereas re.match does not search the pattern; if it does not, it has no other choice than to match it at start of the string.

You can refer the below example to understand the working of re.match and re.search

a = "123abc"
t = re.match("[a-z]+",a)
t = re.search("[a-z]+",a)

re.match will return none, but re.search will return abc.

The difference is, re.match() misleads anyone accustomed to Perl, grep, or sed regular expression matching, and re.search() does not. 🙂

More soberly, As John D. Cook remarks, re.match() “behaves as if every pattern has ^ prepended.” In other words, re.match('pattern') equals re.search('^pattern'). So it anchors a pattern’s left side. But it also doesn’t anchor a pattern’s right side: that still requires a terminating $.

Frankly given the above, I think re.match() should be deprecated. I would be interested to know reasons it should be retained.

re.match attempts to match a pattern at the beginning of the string. re.search attempts to match the pattern throughout the string until it finds a match.

Much shorter:

  • search scans through the whole string.

  • match scans only the beginning of the string.

Following Ex says it:

>>> a = "123abc"
>>> re.match("[a-z]+",a)
None
>>> re.search("[a-z]+",a)
abc

Tagged : / / /

Making Game: Disable Windows search history

Original Source Link

Question: how can I disable Windows search history? (Screenshot)

What I did: disabled “My device history” and “cleared my device history” from Windows Permission & History settings. All data-collection settings from Windows privacy settings are disabled. Yet, it still remembers my search history.

Update: it seems that there’s no option to disable it. Just to add more clarification to the solution, here’re the steps for scheduling a cleaning task: Task scheduler > Create task. Name it, select run with highest privileges and choose the trigger (e. g: on startup). Now, in the actions, add an action and fill in the following:

  1. Program/script: powershell.exe
  2. Add arguements: Remove-Item -Path 'HKCU:SOFTWAREMicrosoftWindowsCurrentVersionExplorerWordWheelQuery*'

Note: for me, it didn’t work without removing the asterisk at the end of the command.

Yet, it still remembers my search history.

File Explorer search history cannot be disabled but it can be cleared. After performing a search you can easily clear your search history through the UI.

enter image description here

If you are attempting to automate this functionality you will have to write a script to delete the following registry key.

HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerWordWheelQuery

I absolutely would test this script before you implement it but something as simple as the following PowerShell command.

Remove-Item -Path "HKCU:SOFTWAREMicrosoftWindowsCurrentVersionExplorerWordWheelQuery*"

The simplest solution would be to create a Scheduled Task, that runs a PowerShell script when the user logs out of the computer, this would clear the recent search history.

Source: How to Delete the Search History in Windows File Explorer

Tagged : / / /

Linux HowTo: Searching on the Chrome omnibar with “mysite.com” jumps to search on Twitter, why?

Original Source Link

Searching for content on certain site is easy on Google Chrome: you type ‘website.com‘ and hit the space bar, and a “search on website.com:‘ appears to let you type search terms.

It works with all the sites I know, but strange enough, it doesn’t work on my own blog, and I don’t know why. When I type ‘javipas.com‘ on Chrome and hit the space bar, the “Search on Twitter:” appears.

Why Twitter and not my blog? Have I something misconfigured in my blog server?

The reason is simply because your Twitter account is also ‘javipas’, and you (might?) visit that more than your blog, so Chrome attempts to be clever and helpful by guessing you’re going to be using Twitter rather than your blog.

It’s a simple fix:

  1. Go to chrome://settings/searchEngines
  2. Under ‘Other search engines’, find ‘javipas’ in the second column, and see which site(s) (in the left column) it relates to
  3. Change the left or middle columns as required

So:

  • if you saw ‘javipas’ for both Twitter and your blog, either change the keyword (middle column) to something like ‘twitter’, or if you’re never going to search Twitter, just remove it.
  • if you saw ‘javipas’ for only Twitter, either change the keyword to something like ‘twitter’ and add a new ‘javipas’ for ‘javipas.com’
  • if you saw ‘javipas’ for only your blog, something else is wrong… :/
Tagged : /

Making Game: Searching on the Chrome omnibar with “mysite.com” jumps to search on Twitter, why?

Original Source Link

Searching for content on certain site is easy on Google Chrome: you type ‘website.com‘ and hit the space bar, and a “search on website.com:‘ appears to let you type search terms.

It works with all the sites I know, but strange enough, it doesn’t work on my own blog, and I don’t know why. When I type ‘javipas.com‘ on Chrome and hit the space bar, the “Search on Twitter:” appears.

Why Twitter and not my blog? Have I something misconfigured in my blog server?

The reason is simply because your Twitter account is also ‘javipas’, and you (might?) visit that more than your blog, so Chrome attempts to be clever and helpful by guessing you’re going to be using Twitter rather than your blog.

It’s a simple fix:

  1. Go to chrome://settings/searchEngines
  2. Under ‘Other search engines’, find ‘javipas’ in the second column, and see which site(s) (in the left column) it relates to
  3. Change the left or middle columns as required

So:

  • if you saw ‘javipas’ for both Twitter and your blog, either change the keyword (middle column) to something like ‘twitter’, or if you’re never going to search Twitter, just remove it.
  • if you saw ‘javipas’ for only Twitter, either change the keyword to something like ‘twitter’ and add a new ‘javipas’ for ‘javipas.com’
  • if you saw ‘javipas’ for only your blog, something else is wrong… :/
Tagged : /

Linux HowTo: Disable Windows search history

Original Source Link

Question: how can I disable Windows search history? (Screenshot)

What I did: disabled “My device history” and “cleared my device history” from Windows Permission & History settings. All data-collection settings from Windows privacy settings are disabled. Yet, it still remembers my search history.

Update: it seems that there’s no option to disable it. Just to add more clarification to the solution, here’re the steps for scheduling a cleaning task: Task scheduler > Create task. Name it, select run with highest privileges and choose the trigger (e. g: on startup). Now, in the actions, add an action and fill in the following:

  1. Program/script: powershell.exe
  2. Add arguements: Remove-Item -Path 'HKCU:SOFTWAREMicrosoftWindowsCurrentVersionExplorerWordWheelQuery*'

Note: for me, it didn’t work without removing the asterisk at the end of the command.

Yet, it still remembers my search history.

File Explorer search history cannot be disabled but it can be cleared. After performing a search you can easily clear your search history through the UI.

enter image description here

If you are attempting to automate this functionality you will have to write a script to delete the following registry key.

HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerWordWheelQuery

I absolutely would test this script before you implement it but something as simple as the following PowerShell command.

Remove-Item -Path "HKCU:SOFTWAREMicrosoftWindowsCurrentVersionExplorerWordWheelQuery*"

The simplest solution would be to create a Scheduled Task, that runs a PowerShell script when the user logs out of the computer, this would clear the recent search history.

Source: How to Delete the Search History in Windows File Explorer

Tagged : / / /

Making Game: Windows 10 disable internet in search

Original Source Link

I just installed Windows 10 Pro (version 10.0.19041) and I noticed that the “Start menu” search (the one you get when you hit the Windows button on the keyboard and start typing) searches the internet, despite me having disabled this.

What I tried before came from this question:
How to disable internet search results in start menu post Creators Update?

I updated the following in the registry:

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionSearch]
"BingSearchEnabled"=dword:00000000
"AllowSearchToUseLocation"=dword:00000000
"CortanaConsent"=dword:00000000

and I updated the following in the Local Group Policy Editor:

Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > Search

  • Allow Cortana: Disabled
  • Do not allow web search: Enabled
  • Don’t search the web or display web results in Search: Enabled

Then I restarted the computer. Although initially this did work and the search no longer connected to the internet, now (maybe since a Windows update was installed?) it is searching again, I think through Bing since that is the logo it is displaying underneath the search results.

The ellipsis-menu in the search app says Build: 2020.06.03.6245959, in case that is relevant?

Edit: The reason I ask this is because I consider this a privacy issue. I press the windows key to start applications (which I find much faster and convenient than using my touchpad), but I don’t want every keystroke to be sent to the internet.

Tagged : / /

Code Bug Fix: Laravel Many to Many relatioships m search from database

Original Source Link

I have search problem in many to many relation models.
Let me explain :
I have online education site. And this include reservations,teachers,students. students and teachers are User’s role. I want to search past reservations from database via using name or email in search input and render to admin page.
Lets code

admin/searchpastreservation.blade.php
    <div class="form-group col-md-6">                                
      <input class="form-control pb-2" id="search" name="search" type="search" 
        placeholder="@lang('admin.search')">
     </div>
     <div class="form-group col-md-3">
         <button type="submit" class="btn btn-primary mb-2 form-control">Search</button>
      </div>

pastReservationController.php
public function searchpastreservation(Request $request)
 {
    $search = $request->input('search');
    $now = Carbon::now(0);
    $reservations = Reservation::where('start','<',$now)->get();
    //Reservations table columns i need reservation_start and reservation_lenght
    $students=User::whereRoleIs('student')->get();
    $teacher = User:whereRoleIs('teacher')->get()
//and i really dont know how can i write query here.if there was only one tale, it is very simple. But there where lots of table. users,role(for teacher and student),role_user(pivot table) and for reservation reservations,reservations_user(pivot table) 
}

so thats it. I am not master i am only avaricious person. i hope i could explain my problem and i hope anyone will help me.

i think you should use a chain of join to get where you need,

$result= Reservation::join('reservations_user','reservations.id','reservations_user.reservation_id')
->join('users','users.id','reservations_user.user_id')
->leftJoin('role_user','role_user.user_id','users.id')
->leftJoin('roles','role_user.role_id','roles.id')
->whereDate('reservations.start','<',Carbon::now())
->where(function($query)use($search)
{
$query->where('users.email',$search)
->orWhere('users.name','like', '%' .$search . '%');
})
->select('reservations.*','users.name','users.email','roles.name', ....)->get();

Tagged : / / / /

Ubuntu HowTo: Traditional search-as-you-type on newer Nautilus versions

Original Source Link

Until now I was using a “traditional” version of Nautilus: that that comes with Ubuntu 10.10. Now I’m using 3.6.3, included with Ubuntu 13.04 (most likely any recent version is equivalent for the scope of my question, anyway).

One major difference between the two is the search-as-you-type behavior: in classic versions of Nautilus, when you typed an input, the file with the closest alphabetical match would become the selected one, the eligible files/folders being restricted to the current directory.

The new behavior is to perform an optionally-global search instead.

Can one configure Nautilus to provide the previous functionality ?

Ubuntu 17.10 and later

As the type-ahead search was a Ubuntu-specific patch, it got dropped together with Unity in 17.10. However there is a package called nautilus-typeahead in the Arch repository. Someone took it, compiled for Ubuntu and made a PPA. You can install it by these three commands:

sudo add-apt-repository ppa:lubomir-brindza/nautilus-typeahead
sudo apt dist-upgrade
nautilus -r

There is an issue on Launchpad about bringing this behavior back to official Ubuntu.


Ubuntu 14.04 to 17.04

Since the Ubuntu 14.04 LTS release type-ahead-find was the default behaviour in Nautilus again.

You can use a dconf key to switch between the different search modes:

  • enable type-ahead-find:

    gsettings set org.gnome.nautilus.preferences enable-interactive-search true

  • disable type-ahead-find in favor of recursive search:

    gsettings set org.gnome.nautilus.preferences enable-interactive-search false


Ubuntu 13.04 and 13.10

Nautilus 3.6.X cuts many features from the 3.4 and older versions. Canonical decided to keep using nautilus 3.4.2 in Ubuntu 12.10 because if this even though Nautilus 3.6 was already released. I don’t think it is possible to get the old search behaviour in 3.6 but what I did was to install the SolusOS patched Nautilus (also works for Ubuntu 13.04) which includes all the features from 3.4.2 (it really is Nautilus 3.4.2) while maintaining the Nautilus 3.6 skin. I’ve tested this particular package and it works fine in Ubuntu 12.10 and 13.04.

Alternatively you could install the Nemo File Explorer which is a fork of Nautilus 3.4 that was made due to the Cinnamon dev team being disappointed with Nautilus 3.6, you can get the install instructions here.

Making it your default file browser is a bit more tricky, this blog post worked for me in Ubuntu 12.10 but some users reported the method not to work properly.

There are alternative methods however. See the following question:

Ubuntu 18.04 and newer

Well, this issue has motivated me enough to finally check out Ubuntu’s PPA submission process; you can find Nautilus packages with the Arch community patch applied here: https://launchpad.net/~lubomir-brindza/+archive/ubuntu/nautilus-typeahead
and install it by running:

sudo add-apt-repository ppa:lubomir-brindza/nautilus-typeahead
sudo apt dist-upgrade

ed: PPA now contains package for focal fossa (20.04)

In Ubuntu Gnome 14.04, open dconf-editor. Go to
org>gnome>nautilus>preferences.

Check the box next to enable-interactive-search. Restart nautilus

There is actually a way to get this in Nautilus 3.26 (the current version in Ubuntu 17.10). Which is building your own version from source, using a patch provided by the awesome arch-linux community. Luckily, the great build system in Ubuntu makes this quite easy. Here’s the steps. I’ll assume you’ll be working in ~/bld-nautilus-typeahead. Start a console and do the following:

# install some necessary tools
sudo apt-get install git

# Create your work directory and go there
mkdir bld-nautilus-typeahead ; cd bld-nautilus-typeahead

# Clone the repository holding the needed patch: 
git clone https://aur.archlinux.org/nautilus-typeahead.git

# Make sure the source repositories for the main archives are available:
sudo nano /etc/apt/sources.list

# If the deb-src line for the main repository (usually around line 6) is commented out (starts with a #), un-comment it (remove the #) and save the file
sudo apt-get update

# Install the build dependencies
sudo apt-get build-dep nautilus

# Retrieve the sources for Nautilus
apt-get source nautilus

# Source should now be in the 'nautilus-3.26.0/' folder. Go there
cd nautilus-3.26.0/

# and Apply the patch from arch-linux
patch -p0 < ../nautilus-typeahead/nautilus-restore-typeahead.patch

# Build the package from source
dpkg-buildpackage -rfakeroot -uc -b

# This will take a little time. If everything goes well, the related packages will end up in the parent directory. Go there
cd ..

# and install the required packages
sudo dpkg -i nautilus_3.26.0-0ubuntu1_amd64.deb nautilus-data_3.26.0-0ubuntu1_all.deb

Start a new Nautilus. Type some letters. Experience that feeling of joy that happens whem the file you intended gets selected.

Ubuntu 18.04+, Nautilus native solution

You can get a close behavior to search-as-you-type if you change the following options in the Nautilus Menu -> File -> Preferences -> Search & Preview:

  • Change “Search in subfolders” to “Never
  • Uncheck the “Full Text Search“: “Set as default” option

Now the visual interface will still be as the new Nautilus (tested with v3.26.4), while the functionality will be similar to the search-as-you-type as in the older Nautilus.

Ubuntu has updated the Nautilus repository, as a result the accepted answer no longer works. Use the command below to get the correct version of PPA Nautilus.

sudo add-apt-repository ppa:lubomir-brindza/nautilus-typeahead
sudo apt-get install nautilus=1:3.26.4-0~ubuntu18.04.4.ppa1 libnautilus-extension1a=1:3.26.4-0~ubuntu18.04.4.ppa1 nautilus-data=1:3.26.4-0~ubuntu18.04.4.ppa1
sudo apt-mark hold nautilus libnautilus-extension1a nautilus-data
nautilus -q

This works on Ubuntu 18.04, if you are using another version use the apt-cache policy nautilus to find the correct version of PPA.

The answer for Nautilus 3.25 and above is it’s gone & not coming back unless someone totally rewrites the ubuntu patch & odds of that are extremely slim to none.

It is not something that can be configured in nautilus itself.

Not quite what I wanted but the following limits the search to the current directory and is a very lightweight compromise:

# Get the previous setting in case I want to revert.
gsettings get org.gnome.nautilus.preferences recursive-search &&

# Only search the current directory. Do not go deeper.
gsettings set org.gnome.nautilus.preferences recursive-search 'never'

Tested on Ubuntu v18.10.

Tagged : /