Showing posts with label Computers. Show all posts
Showing posts with label Computers. Show all posts

Thursday, January 26, 2023

How to recover an off-screen window in Windows

 Recover an off-screen window:

  1. Select the window's tab in the task bar
  2. Press Alt+Spacebar to open the window's context menu
  3. Press M to select Move in the context menu
  4. Press an arrow key to snap the mouse pointer to the window
  5. Move your mouse around until it drags the window back into view

Tuesday, February 22, 2022

Canadians! How to turn off that annoying "Control-Shift" Keyboard Switch

No offense to mon copains Quebecois (did I say that right?), but a particular quirk affects PCs for a unilinguist Anglo like me when the Region setting in Windows is set to Canada (or I suppose any bilingual country). 

I've had the annoying experience of holding down "Control-Shift" for more than a couple of seconds, say while I'm trying to decide if I want to paste plain text into a Google Chrome field (using Ctrl-Shift-V), then suddenly I'm getting accented characters all over the place. 

This is Windows being helpful to us Canucks, by switching the keyboard layout from Canadian English to Canadian French, which would be great, if a) I had a Canadian French keyboard, and b) I knew how to write in Canadian French on that keyboard, and c) I actually wanted to write in Canadian French!

Well, I discovered how to turn off that 'helpful' keyboard shift:

  1. Open Settings and search for "advanced keyboard settings":


  2. In the Advanced Keyboard Settings panel, click on Language bar options:
  3. In the Text Services and Input Languages control panel, select the "Advanced Key Settings" tab and click the "Change Key Sequence" button:


  4. Finally we are there: click the "Not Assigned" radio buttons for either or both "Switch Input Language" or "Switch Keyboard Layout" options:
And that I think is it!

Tuesday, January 5, 2010

How to run SQL*Plus one liners on Windows

Suppose you have a simple one line query to run on your Oracle database. Oddly, SQL*Plus doesn't take SQL statements as a command line parameter.

For a simple one liner, it's often too much work to start up sqlplus, logon, type in the SQL statement, then exit. It may also be too trivial to save the SQL statement to a file that you then call from sqlplus, e.g. C:\>sqlplus user/pass @myfile.sql.

To do it all in one line on the command prompt, echo the statement into sqlplus:

echo select count(*) from mytable; | sqlplus user/pass

This technique would probably also work on a Unix box, but I don't have an Oracle db installed on a Unix box to test it out.

Wednesday, December 9, 2009

Peak Prices?

I've had Oil 101 in my Amazon.ca cart for a few weeks. Just not ready to read it yet. When I checked my cart today, I was unpleasantly surprised to read this note:

Please note that the price of Oil 101 has increased from CDN$ 23.20 to CDN$ 36.97 since you placed it in your Shopping Cart. Items in your cart will always reflect the most recent price displayed on their product detail pages.

How does Amazon justify boosting the price by almost 60% in just a couple of months? Perhaps, like the book's subject, we've reached "Peak Books"...

Tuesday, May 5, 2009

gnu find and grep: using path patterns to match more than one file extension

Example using Cygwin gnu find, xargs and grep to search for a typo in XSLT and XML files. Note that -iregex matches a pattern in the whole path, and the pattern is a POSIX basic regex:

C:\>find ./ -iregex '.*\.\(xslt\^|xml\)' -type f -print | xargs grep -i "staus"


When find matches a file path, the path is piped to xargs, which hands it off to grep to search for the string "staus" - which I want to replace with "status" (but not here :).

Monday, May 4, 2009

Cygwin setup.exe fails during upgrade

Like Ruben, who provided the clues, I discovered that a corrupt/incompatible alternatives.lst.bz file in the C:\cygwin\etc\setup directory caused Cywin setup.exe to fail.

A few clues pointed to this file as the culprit:


  1. First time through, the installer complained that some other Cygwin process had locked the readme file

  2. the installer just looped indefinitely on extracting the README file from alternatives.lst.bz until I killed it

  3. The only .bz file in C:\cygwin\etc\setup with today's date was alternatives.lst.bz.



Here's what the log file recorded, for several thousand lines:


2009/05/04 11:01:23 io_stream_cygfile:
fopen(/etc/alternatives/README) failed 13 Permission denied
2009/05/04 11:01:23 Failed to open
cygfile:///etc/alternatives/README for writing.


I renamed the file to alternatives.lst.bz.bak , then reran setup.exe to successfully upgrade Cygwin.

Now I suppose I should log a bug report...

How to fix apropos for Cygwin

If the apropos command in Cygwin doesn't find anything expected, run /usr/sbin/makewhatis from your Cygwin bash prompt to rebuild the whatis database.

Thanks to Mike and Igor for their tips.

Friday, May 1, 2009

How to make Windows %path% readable

If like me your Windows %path% looks something like this:

PATH=c:rubybin;C:Perlsitebin;C:Perlbin;C:Oracle
OraHome817bin;C:oracleproduct10.2.0gpdbin;C:Program 
FilesOraclejre1.1.7bin;C:Python26;C:Python26scripts;C:
Python26Libidlelib;C:cygwinbin;C:Program FilesWindows 
Resource KitsTools;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWS
Downloaded ProgramFiles;C:Program FilesIBMDirectorbin;C:
Program FilesDiskeeper CorporationDiskeeper;c:Program 
FilesMicrosoft SQL Server90Toolsbinn;C:Program Files
Rationalcommon;c:scripts;C:Program FilesjEdit;C:Program 
FilesQuickTimeQTSystem;C:Program FilesTortoiseSVNbin;C:
ipdsdevaxis2axis2c-rel-1.3.0lib;C:Program FilesJava
jdk1.5.0_16bin;C:jruby-1.2.0bin


Then save this to "road.bat" somewhere on your path:

@echo off
rem source: http://www.perlmonks.org/?node_id=757655
for %%i in ("%path:;=" "%") do @echo %%i


When you run C:\>road all those paths are nicely split and one-lined:
C:>road
"c:rubybin"
"C:Perlsitebin"
"C:Perlbin"
"C:OracleOraHome817bin"
"C:oracleproduct10.2.0gpdbin"
...


and you can do cool things like C:\>road | find /i "Perl" to find out where Perl is hiding.

To paraphrase the (brilliant) author VinsWorldcom, this one-liner

wraps the %PATH% ENV var in double quotes and then replaces all the semicolon separators with a double-quote, space, double quote. This effectively puts double quotes around all the paths (so spaces won't give any troubles) then use the for loop to list each newly double-quoted string.

Wednesday, April 29, 2009

Thursday, March 5, 2009

How to make an empty file on Windows

To makes an "empty" file,  containing only a single newline, type this in a Windows command prompt:
c:\>echo. > somefile.txt

The dot immediately after the echo command outputs just a blank line to the file. I think this technique works for Windows NT and better.

Apparently you can also use the fsutil command to make a file of any size filled with zeros:
c:\>fsutil file createnew filename length

Tuesday, December 16, 2008

Using caret '^' in Windows batch files

The caret '^' character serves two purposes in Windows batch files:

1. line continuations:
~~~
@echo off

dir ^
/ad ^
c:\temp
~~~~
results in dir /ad c:\temp, which lists only the directories in C:\temp. (Thanks to SteveGTR for that example.)

2. Escaping reserved shell characters & | ( < > ^. Use a preceding caret to escape and print the character:



echo this pipe will print ^| but this one won't |
echo and this will print one caret ^^

Tuesday, December 2, 2008

Monotype font for Wordpress "Write Post" text area

I like to use a monotype font (e.g. Courier) when I edit my blog posts in HTML mode. Wordpress seems to default to a proportional font. Try as I might, I couldn't find an easy way to change this from the WP admin pages, so I resorted to hacking the responsible stylesheet, /wp-admin/wp-admin.css, adding the font-family declaration for the #content text area:


editorcontainer #content {
font-family: Courier New, Courier, sans-serif;
padding: 0;
line-height: 150%;
border: 0 none;
outline: none;
}

Friday, September 12, 2008

Using an STL list with current and next iterators

General algorithm for using a "current" and a "next" iterator on an STL list, which doesn't provide a convenient next() method (random-access containers such as vector do):


std::list<Foo>::iterator currIter, nextIter;

currIter = list.begin();

while(currIter != list.end())
{
currIter->doStuff(); // do something with the curr item

nextIter = ++currIter; //advance the iter and set it to next
if(nextIter != list.end()) // still safe to use next item
{
nextIter->doStuff(); // do something with the next item
}
}

Saturday, August 2, 2008

Ruby on Rails 2.1.x Tutorial

Found a "to the point" tutorial over on Tutorialspoint.com that covers just enough Ruby on Rails 2.1.x to get (re)started.

Saturday, May 17, 2008

How to get Vista to show the "Command Prompt Here" on a Folder List

For many years, on many PCs running various versions of Windows NT, 2000 and XP, applying the "Command Prompt Here" Powertoy was one of the first things I would do to customize the vanilla Windows environment (i.e. make it usable). Right-click a folder, select "DOS Prompt Here" or "Command Prompt Here" from the context menu, and voila, a DOS box opens, set to the folder you clicked on:



I was happy to find the same feature already baked into Windows Vista: hold down the shift key, right-mouse click on any folder in the view pane, then select "Open Command Window Here" from the context menu:



But try the same trick on a folder in the Folder Tree, sorry, the command's not there:


For some reason, in their wisdom the Microsoft UI engineers chose to omit the command from this particular menu.

Quite by chance, I discovered that the choice is available on the File menu in Vista, but it's not invoked in the same way: instead, select a folder in folder list, hold down the shift key then left-click (i.e. normal click) the File menu:



Vista then displays "Open Command Window Here" at the top of the menu. Okay, happy to have it back, even if it's in a place I didn't expect...

Thursday, May 1, 2008

What did I just edit?

I checked out some code files from Razor (don't ask, we use an old CM system), created a couple of new ones, now I want to quickly double-check which of the thousands of files in our source tree are the ones I checked out or created (don't ask, we use an old CM system), so I can check the changes back in and introduce the new files (if I forget, guess who gets the wooden spoon for breaking the build):



So fire up a DOS prompt and type in:


C:\path to my code\>dir *.cpp *.h *.vcproj
/b /s /a:-r &gt; \usafipd\updated_files.txt



This says "list all of the code files and Visual Studio project files from here on down that are writeable (i.e. not locked by Razor), then dump the results to a file in case there are hundreds of filenames to review.


This gives me a file, updated_files.txt, containing a nice list of all the .cpp, .h and .vcproj (Visual Studio project) files I checked out (i.e. made writeable).

Sunday, April 13, 2008

Pylons stuff

John Brennan brings us a short Pylons intro Zero to 60 with Pylons… in just minutes (Part 1). Can hardly wait for Part 2!

Also noticed The Definitive Guide to Pylons from Pylons lead developer James Gardner is slated to arrive in July 2008.

Friday, April 11, 2008

Another evaluation of Google AppEngine

Todd Hoff explains how distributed web apps can leverage the much-maligned CGI interface in Google AppEngine - A First Look

Thursday, April 10, 2008

osalt.com

Came across a useful link: www.osalt.com Open Source Alternative - Find Open Source Alternatives to commercial software. Thanks to Jimmy, who made note of osalt.com in his comment to Jeff Atwood's post on the value of open source vs. commercial software on Jeff's always thoughtful blog, Coding Horror.