Saturday 31 August 2019

linux - Continuously detect new file(s) with inotify-tools within multiple directories recursively


I just installed inotify-tools. I would like to continuously detect new file(s) with notify-tools within multiple directories recursively, and send an email using postfix. I can probably handle the send an email using postfix part. I'm just trying to figure out the best way to go about this when trying to detecting new file(s). Because sometimes multiple files are added at once.



Answer



inotifywait (part of inotify-tools) is the right tool to accomplish your objective, doesn't matter that several files are being created at the same time, it will detect them.


Here a sample script:


#!/bin/sh
MONITORDIR="/path/to/the/dir/to/monitor/"
inotifywait -m -r -e create --format '%w%f' "${MONITORDIR}" | while read NEWFILE
do
echo "This is the body of your mail" | mailx -s "File ${NEWFILE} has been created" "yourmail@addresshere.tld"
done


inotifywait will use these options.


-m to monitor the dir indefinitely, if you don't use this option, once it has detected a new file the script will end.


-r will monitor files recursively (if there are a lot of dirs/files it could take a while to detect the new created files)


-e create is the option to specify the event to monitor and in your case it should be create to take care about new files


--format '%w%f' will print out the file in the format /complete/path/file.name


"${MONITORDIR}" is the variable containing the path to monitor that we have defined before.


So in the event that a new file is created, inotifywait will detect it and will print the output (/complete/path/file.name) to the pipe and while will assign that output to variable NEWFILE.


Inside the while loop you will see a way to send a mail to your address using the mailx utility that should work fine with your local MTA (in your case, Postfix).



If you want to monitor several directories, inotifywait doesn't allow it but you have two options, create a script for every dir to monitor or create a function inside the script, something like this:


#!/bin/sh
MONITORDIR1="/path/to/the/dir/to/monitor1/"
MONITORDIR2="/path/to/the/dir/to/monitor2/"
MONITORDIRX="/path/to/the/dir/to/monitorx/"

monitor() {
inotifywait -m -r -e create --format "%f" "$1" | while read NEWFILE
do
echo "This is the body of your mail" | mailx -s "File ${NEWFILE} has been created" "yourmail@addresshere.tld"
done
}
monitor "$MONITORDIR1" &
monitor "$MONITORDIR2" &
monitor "$MONITORDIRX" &

gvim - How to remove this symbol "^@" with vim?


I have some files that are corrupted with this symbol:



^@



It's not part of the string; it's not searchable. How do I substitute this symbol with nothing, or how do I delete this symbol?


Here is an example line from one file:


^@F^@i^@l^@e^@n^@a^@m^@e^@ ^@ ^@ ^@ ^@ ^@ ^@ ^@ ^@ ^@ ^@:^@ ^@^M^@

Answer



You could try:




  • %s///g (on regular PCs)




  • %s///g (on Mac PCs)




where means first press down the CTRL on regular PCs, keeping it as pressed down, hit 2, release CTRL.


and means first press down the control on Mac PCs, keeping it as pressed down, press down shift on Mac PCs, keeping it as pressed down, hit 2, release control and shift.


Finally, both of the two commands should result in %s/^@//g on screen. ^@ means a single character (a NULL byte, which otherwise couldn’t be displayed), not ^ followed by @, so you can't just type ^ and @ in a row in the above command.


This command removes all the ^@.


windows 7 - How to stop ReadyBoost from rebuilding cache after every restart on SD cards and flash drives?


On my computers (running windows 7 and vista and using SD cards and flash drives) ReadyBoost rebuilds cache after every reboot. Because of this and 5400RPM HDD, it takes several minutes for computer to start working normally. I gave up on using ReadyBoost because of that. Today I read in comments on this answer that for some people, ReadyBoost does not rebuild cache after every reboot.


My question is how to make ReadyBoost keep its cache even after reboot?



Answer



Looks like this is a security feature, so I don't know if it can be bypassed:



The driver encrypts each block it writes using Advanced Encryption Standard (AES) encryption with a randomly generated per-boot session key in order to guarantee the privacy of the data in the cache if the device is removed from the system.



http://technet.microsoft.com/en-us/magazine/2007.03.vistakernel.aspx


Unfortunately, I can't think of a way to help speed up the rebuild process or avoid it (other than increasing the amount of RAM which would make ReadyBoost unnecessary).


Update: I will summarize the comments below.
SuperFetch, ReadyDrive, and ReadyBoost are all technologies that work together.


SuperFetch monitors what files are being used by the user and system and learns what is used a lot and attempts to predict that may be called for in the future. Then that can be preloaded before it is actually called upon.


ReadyDrive attempts to predict what memory pages Windows needs to take into a hibernate so when Windows wakes up, Windows will resume from hibernate faster. The data Windows will need can be stored in an internal OEM installed non-removable ReadyBoost drive. ReadyDrive needs these internal drives because Windows can trust nothing has happened to it during a hibernate session. During a shutdown, even these drive are not trusted.


ReadyBoost caches hard drive reads at the sector level. It doesn't care about file systems because it only knows where on the disk data was. SuperFetch may determine a file is used frequently, so it will store that data in a ReadyBoost cache. There is a ReadyBoost cache on the hard drive which I assume is there (rather than reading it from disk elsewhere) is because hard drives have good sequential read performance (meaning reading sector after sector after sector, rather than needing to change tracks and dealing with seek times and rotational latency). The goal of using a ReadyBoost flash device is to beat the disk in performance. This way those hard drive sectors cached using ReadyBoost can be retrieved faster, increasing the computer's performance. For removable ReadyBoost drives, the contents of the drive can't be trusted through a standby, hibernate or shutdown event because the hard drive's or ReadyBoost's cache contents could have been changed since Windows had made that cache. To prevent bad data from being used, Windows will dump the old ReadyBoost cache and begin a new cache. During this time, performance would be less because the cache hasn't warmed up with the current sector's data.


Source: Here is a good video talking about these technologies and how they interrelate. Some interesting parts are about 16m30s-19m & 34m45s-38m40s, however, the whole video may be worth seeing.


email - How to back up gmail to my computer?


I am using gmail as a part of Google Apps for Domains. I'd like to back up all my email.


I've tried setting up IMAP in Thunderbird and it works reasonably well (except it times out way too much, forcing me to help it along manually). However, I have a ton of labels, which in the IMAP land map to folders. And in Thunderbird, you have to click on each folder separately and tell it to download everything. Painful.


Is there a tool that will let me do this easier?



Answer



There are many ways to do this:



video - ffmpeg slideshow with crossfade


I just figured out how to make a slideshow with crossfade. It's a two-step process. The first step reads the pictures with framerate 0.5 (which means 2 seconds for each picture), and produces an intermediate video with framerate 2. That means each picture is repeated 4 times. The second step applies the framerate filter. The result is that each picture is shown for 1.5 seconds, followed by a 0.5 second crossfade.


ffmpeg -framerate 0.5 -i IMG_%3d.jpg -r 2 -codec:v mpeg4 temp.mp4

ffmpeg -i temp.mp4 -vf "framerate=fps=25" -codec:v mpeg4 out.mp4

This two step process works fine, but I have two questions:



  1. Is it also possible to get the same result in one step, without an intermediate video file?

  2. If the answer to the first question is no, can someone please show me how the above commands must be modified for a lossless intermediate file, for example RAWVIDEO?


Thanks, Michael



Answer



You can retime the frames before applying the filter:


ffmpeg -i IMG_%3d.jpg  -vf "setpts=N/0.5/TB,framerate=fps=25" -codec:v mpeg4 out.mp4



Update: The framerate filter appears to be tied to the input framerate at ingest, so an alt method using pipes


ffmpeg -framerate 0.5 -i IMG_%3d.jpg -vf fps=2 -f nut - | ffmpeg -f nut -i - -vf framerate=25 -c:v mpeg4 out.mp4



A single-line workaround:


ffmpeg -i IMG_%3d.jpg -vf zoompan=z=1:d=4:s=WxH:fps=2,framerate=25 -c:v mpeg4 out.mp4

where W and H are replaced with the input dimensions.


How can I view pdf meta-data in Windows Explorer?

I unsuccessfully used the "pages" feature in Windows Explorer, as well as in Directory Opus 10 and Free Commander XT (which I installed just for that reason, to try it out) to display the page count of multiple PDFs in a folder.


All my PDF's are free to edit, i.e. not write-protected. I don't understand why any PDF reader can display the (correct) page number, but none of the file explorers can? (In the "details" view of course.)


The only documents whose page count is displayed are MS Word documents.


As you know for such information a Shell Extension Handler for PDF should be installed, but is there any?


On a side-note: Did that change in Windows 8?


Initial research: Google search was unsuccessful, the only slightly related SE topic I found was "How to count pages in multiple PDF files?".


Windows 7 Home Professional 64b

macos - Remapping spacebar in Finder from windowed Quick Look to fullscreen ("slideshow")

In the Mac OS X Finder, Can I replace the standard option of a windowed preview (Quick Look) with a fullscreen view (Slideshow)?


Command + Option + Y = Fullscreen


Space = Windowed


Is there a way of making space perform the fullscreen mode instead?

How to forget/remove username in Windows 8 Store - account deleted

I deleted a Windows Live/Microsoft account (I have others) that I was using for the Windows Store on one of my PCs. Now I can't use the store at all because it wants a password for that particular account - there is no sign out option nor is there a "change username" option that I can see. When I click the "Sign in" button, the store insists on using the deleted account.


So, to summarize, Windows Store is insisting I sign into an account that no longer exists.


How do I get the store to delete it?


Steps taken so far:



  • Removing the Live account from the local Credential Manager

  • Removing mention of this account in the IdentityCRL registry folder

  • Resetting the store cache using wsreset


I think this is a bug but Microsoft Connect isn't accepting bugs or feature requests for Windows 8 right now.

Ext2 or Ext4 for bootable USB Flash-drive with Linux?

I want to install Ubuntu to a USB Flash drive (so I have my Desktop everywhere and can customize it as I want).


I'm still choosing what's the best filesystem for the USB; Ext2 with no journaling or Ext4 with journaling but performance increase? I know that journaling will probably reduce the life of the USB flash drive dramatically, so is Ext2 the obvious choice?


Or is it a bad idea to install Linux (Ubuntu probably) on a USB Flash drive? I tried running a live CD from the USB drive, but it wasn't very customizable - which is the point of carrying my OS with me.

networking - Change default gateway on windows hosted network


I used the following command to create a hosted network.


netsh wlan set hostednetwork mode=allow ssid=[ssid] key=[keyphrase]


I would like to change the default gateway and given IP ranges from 192.168.137.1 to say 192.168.10.1. I tried everyting but couldn't get it to work. Is it even possible?



Answer



Unfortunately this isn't configurable in the network settings in Windows and has to be changed in the registry editor. In the run prompt enter regedit. Next navigate to HKEY_LOCAL_MACHINE\System\CurrentControlSet\services\SharedAccess\Parameters. Change just StandaloneDhcpAddress if your only using Wireless Hosted Network but if you are sharing internet to it with ICS then also set ScopeAddress to 192.168.10.1.


You will probably have to run netsh wlan stop hostednetwork and then netsh wlan start hostednetwork for the change to take affect. If you are sharing internet to the wireless then you might need to re-share in the windows network settings as well for the changes to take affect. Depending on your setup you might have issues with IP conflicts if you have anther device giving out IP address on 192.168.10.xxx


See this superuser answer for reference.


windows 7 - How to fix task manager memory column if it shows lies


I have a problem in showing memory in task manager with memory and paging columns. Why it shows so small size usage? And maybe anyone knows how to fix it?


Here is a screenshot(working set, memory, page pool) sorted by most consuming: alt text



Answer



Check your Number format settings in control panel - regional options. The decimal symbol and the digit grouping symbol should be the different characters, e.g. . and ,. There are various glitches in some programs if they are the same.


vlc media player - how can I view milliseconds with VLC? (and why is this method not working?)


Note- This is not a duplicate. This question, as it says in its title, is specific to VLC. The other question is a general question about video playing programs generally. So, not a duplicate


I am trying get milliseconds shown in VLC.


I read that I should download this extension http://addons.videolan.org/content/show.php?content=149618


(there was a download link on that page, not sure if it's quite right, like I don't know if I downloaded some lite version that I shouldn't have but I downloaded this)


http://addons.videolan.org/CONTENT/content-files/149619-time-lite.lua


and put it in "VideoLAN\VLC\lua\extensions" creating the extensions subdirectory if it doesn't exist. I did that.


closed VLC, started it again.


It is listed under the View menu. I notice it doesn't get checked. even when I click it - I don't know if it should. The same is true for the VLSub extension below, it doesn't get checked when clicking it. Maybe that is normal and extensions are already enabled.


But my problem is, it doesn't show miliseconds, which is what i'm after.


VLCnomillisecondsscreenshot



Answer



According to mederi, the author of the Time extension, the var.add_callback( ) and var.del_callback( ) Lua functions are no longer available in VLC 2.1.


Unless VLC is patched to add the removed functions the script will not work as written.


ubuntu - Windows 10 freezes after login (dual boot with Linux)

Here is what I did: I use linux installed on my SSD. Lately I've decided to install windows 7 on another separated HDD (non-ssd) and upgrade it to windows 10. So I temporary disconnected the SSD with linux installation and installed windows 7 on the other hdd which I formatted before installation. Then I upgraded windows to the latest version. Everything worked fine until I connected the SSD with linux back to my notebook. if the ssd is connected to the computer, windows always completely freezes at random time after login process (Only thing I can do is hold power button to turn of the computer).


Note that I haven't changed sata ports on which both drives was connected at the beginning of process.
I'm sure that this is not hardware issue.
Note that I tried turn off fast startup option in power options.
The SSD on which linux system is at, is formatted to ext4. HDD with windows system has ntfs filesystem.


HDD with windows installation is set up as first boot option and is connected to sda.
With this setup computer automatically boots to windows. if I want to boot to linux I have to hold ESC key before boot time and choose the SSD as boot option. (I hate this behavior but it's only thing I could think of to help windows boot properly) This really makes me absolutely crazy! Do you have some ideas how to solve the issue?
Would it change anything if I would rollback windows 10 upgrade back to windows 7?


UPDATE:


After @Michael's answer which unfortunately did not make any difference I spent several hours with testing the behavior. I tested the following scenario multiple times in row and it always behaved in the same way:


HDD = hard drive with Windows 10 Pro 64bit (BUILD 10240) installed in it (not UEFI)
SSD = solid state drive with Xubuntu 14.04 64bit installed in it (not UEFI)


So I started with only HDD connected to the computer and as expected in this state Windows never freeze.
Then I connected SSD but again booted to the HDD with Windows in it. Windows also doesn't freeze in this state. I continued and restarted the computer and booted to the SSD with Xubuntu in it, after I logged in, I shut down the computer and tried to boot to Windows again. This time Windows always froze before or during login process and usually ended up with blue screen of death after while of waiting.
After this I followed up with trying to boot to Windows again several times.
Result was that Windows always froze AFTER login at random time (it didn't freeze immediately, it was running couple of minutes without an issue until it froze...) until I disconnected SSD then it was possible to ran Windows smoothly again.


Note that Windows doesn't freeze if logged in safe mode (at least it didn't happen to me during the time of testing).


Conclusion:


Linux edits something related to boot sequence every time I boot to the Linux which keeps Windows from booting properly after then.

windows xp - Is it possible to drive 2 monitors from a video card that's designed for one?

Here is the situation. I've been given a PC at a client site. It has a single monitor, however, I'd like to have another one since my work would go much faster.


I've been told that, no, I can't add another video card. But I can plug into the box anything external. So is there an external device that I can buy that would allow me to add the extra monitor?

productivity - Multi-monitor Usage



How many different applications do you use with a 2, 3, 4, 5 or more monitor setup? What's the most sophisticated multi-monitor setup you've seen?


To be more specific, I would like to know exactly how you use your multi-monitor setup and how can I make better use of my own.


How does someone take full advantage of a multi-monitor setup? And does having more monitors help your productivity?



Answer



The coolest multi-monitor setup I've seen, not in person, is Stefan Didak's office setup. Stefan is a computer animator, and has the SWEETEST home office:


http://www.stefandidak.com/office/


12 monitor setup


ubuntu - Linux Podcast Playback with Resume Capability


I'm asking a question similar to but distinct from this one


Is there a Linux player that can resume playback of a podcast episode where it was last left off? This is the default behavior of iTunes for example.


In particular, is there a way to achieve this capability on Banshee or other major Linux podcast clients?



Answer



Miro should do this.


text editors - `^M` in many lines in source code files. How can I remove them?


Someone recently sent me a couple of .cpp source code files. On opening the files with GNU Emacs or GVIM, I found them to have a weird character ^M near the ending of every line.


Here is a screenshot showing what I meanEditor Screenshot


When I open these same source files with Gedit, I do not see these ^M characters. What should I do? There are many files in question here, so opening and doing a search-replace operation by replaceing with an empty string looks like a back-breaking operation.


Strangely enough these files compile cleanly when I compile with GCC. What is going on here. What should I do?



Answer



In Unix, the new line character is \n and whereas in Windows it is \r\n. \r or ^M is the carriage-return character.


If the file is written in an editor in windows mode, each new line character will have a carriage return character along. If you tell your editor (and if it understands) to treat the new line characters as in windows, you would not see the ^M characters any more.


Alternately, you can run dos2unix on your codebase to fix this problem.


And as you have rightly observed, you would not see any problems in compiling because that is not any extra special character in the code but just a mismatch between newline character interpretation in windows and linux.


Friday 30 August 2019

Dynamic images served over HTTPS display broken image in word when opening an HTTP document


We have an application that produces HTML documents which the user opens in word from the web server, so they open:


https://ourserver/ourapp/somepath/generateddocument.htm


That document contains image links like:



and



The first display, the second displays the classic broken image icon.


When opening in Internet Explorer, both render.


When tracing with Fiddler, both images are correctly returned.


Changing the second example to:



It displays.


However, in SOME word installs in the office both display.


What settings where should we be looking to understand why the latest word 2003 hotfixed word install on an up to date patched windows 7 install should be different between my machine and a colleague for the display of these items?



Answer



The problem here is the way IE caches SSL content or not.


If you enable the IE option "Do Not Cache Encrypted Pages to Disk" then the problem goes away.


You can also fix programatically in your image generation page by NOT sending a Cache-Control header.


The issue is that the way IE works with SSL served pages is to create a 0byte file on disk as a pointer to the volatile memory where the actual image is stored. So IE creates the file on disk, when it fetches the image. But the memory and file are presumably torn down when the IE instance word has used to retrieve the HTML and linked assets has completed.


So when the word rendering engine then tries to display the content, it's gone.


If you don't set a Cache-Control directive, OR You set the IE option, then this is not a problem.


ocr - How can I identify fonts from an image?



Many times I come across bitmaps with nothing but text paragraphs, so I was looking for a way to identify the font used, the paragraph alignment, line spacing and color, bold, italics.


Would an OCR package allow me to do that?


If not, what other options do I have?



Answer



There are several online utilities can be used to identify fonts, including:



These utilities cannot be used to determine the formatting of the text in an image. However, you can use OCR programs such as Tesseract (open source) and Smart OCR (commercial, starting from US$99.90) to detect formatting such as paragraph alignment and line spacing as well as font styles such as bold or italic (see this Stack Overflow question). Note that some OCR programs can attempt to identify the font(s) in an image as well.


windows 7 - How do I force Excel (and other Microsoft Office products) to stop opening files in the same application?



Whenever I "double click" on an Excel file and another Excel file is open, the newly opened file automatically opens in the same application window as the previously opened Excel file. This isn't limited to just Excel, as I've seen Word do this as well. This poses a problem when wanting to compare documents side by side.


The current solution I have for this is to actually open another Excel or Word instance, and then open the file from within that application window itself. Is there a way to force Office to open a new instance of the application when double clicking on the file icons?


I'm currently using Office 2007 and Windows XP, but I've seen this on Office 2010 and Windows Vista and 7. I'm looking for an overall solution if possible.



Answer



I have Office 2010 and the only app that does this for me is Excel.


A posting on PC Review, How to open vista excel in multiple windows versus 1 window? explains how to set this up:




  1. Use the File Association Settings

  2. You have to tell Excel not to use DDE to open the worksheet.

  3. Open Windows Explorer, Tools, Options, File Types

  4. Scroll down to XLS

  5. Select Advance Button

  6. Click on OPEN in the Actions window, Then Edit

  7. On the 2nd line for application used add "%1".

  8. Make sure to put the quotes around %1.

  9. Example ...\Excel.exe" /e "%1"

  10. Write down what you see in the DDE Section.

  11. You will need this information if you want to return to the original settings.

  12. Now DeSelect Use DDE


When you double click on any XLS file a separate instance of excel will run.


Another advantage is that you can open more than one XLS file with the same name



networking - How to increase wifi speed for laptops


Now, Let me explain the situation.


I am having a query regarding Wi-Fi network. I am having PC & laptop.


I requested my Wi-Fi providers that I want connection in my PC. So that - Wi-Fi provider set up an Antenna on my building Terrace - They joined a cable to pc & that Antenna. ( I think using RJ45 connector ) - The reason behind this - my does not have a built in Wi-Fi adapter.


Now - almost laptops have built in Wi-Fi. Now - On terrace there is Wi-Fi with superb speed. But on my flat - Wi-fi comes with low speed.


So, when ever I use internet on my pc - it has great speed - but my laptop works with low speed.


The reason behind this - PC is catching wifi from terrace & laptop is catching the wifi from it's own place.


Now, My question is something like this.


Can we place an antenna or something like that & connect it to laptop for better wifi speed? ( I am not technical person - Please add comment for down vote - if any ) ( Please add comment for more explanation of my Problem )


Thanks in advance for sharing your knowledge.


Sagar



Answer



What you're looking for is an external Wi-Fi Antenna.



Directional Antennas WiFi Yagi Antenna ----- Directional antennas are used for Point-to-Point or sometimes for Multi-Point systems depending on the setup. If you are trying to go from one location (say for instance your router), to another location, this is the type of antenna we recommend. Directional antennas are Backfires, Yagi, Panel and dish type antennas.


Omni-Directional ---- This is the common “Base” antenna used for Point-to-Multi-Point or can be an omni-directional antenna for your car. An Omni-Directional antenna would serve as your main antenna to distribute the signal to other computers or devices (such as wireless printers, PDAs, etc) in your workgroup. You can use 2 Omni-Directional antennas for a point to point system, but this is usually not recommended because there is no real point to distributing your signal all over the place when you only want to going from point A to point B. Please refer to Directional antennas above. Typical Omni-Directional WiFi antennas consist of Vertical Omnis, Ceiling Domes, Rubber ducks, Small Desktops and Mobile vertical antennas.


Point-to-Point ----- Point-to-Point systems usually involve 2 different wireless points, or building to building wireless connections. But there are exceptions to every rule. If the access point is across a long valley and the owner of the system wishes to share the connection with multiple users on the other side of the valley. This would be a point to Multi-Point system but using directional antennas.



From Selecting a Wi-Fi Antenna.


There are also people who have modified their computer to accept coaxial type connections for the purpose of increasing the range of their Wi-Fi cards.


FFMPEG convert flv to mp4 without losing quality

Currently I'm converting .flv flash files to .webm and .mp4 files to be used with an HTML5 video player.


_


I use this ffmpeg command for WEBM: ffmpeg -i filename.flv -vcodec libvpx -acodec libvorbis filename.webm which works great and the file size stays relatively the same (imporatant).


_


For MP4 I'm using the following: ffmpeg -i filename.flv -sameq -ar 22050 filename.mp4


It converts to .mp4 fine and prevents any quality loss but the file size almost triples in size.


What ffmpeg formula could be used to convert to MP4 without losing too much quality and preventing a much higher file size?

microsoft excel - Compare two spreadsheets and get missing records


I have two CSV documents. The first has 10.000 rows with 50 columns, with the first column being a unique SKU (stock keeping unit). The second document with 9.500 rows using the same columns and identifiers.


I simply want to create a third document with the 500 missing records.


Is this possible with excel?



Answer




  1. First copy the second CSV (with 9500 rows) in a blank spreadsheet.

  2. Give a background color (say yellow) to the cells having content.

  3. Now copy the first CSV into the spreadsheet appending it to the bottom of the first CSV

  4. Use 'Remove Duplicates' (in 2007 you can find it in Data tab) feature on the entire spreadsheet.

  5. After remove duplicates has completed, cells not having the background color given in step (2) found at the bottom of the spreadsheet are the missing records


powershell - What is the correct syntax to exclude a folder's contents but not the folder itself


I have a powershell script that copies files from $source to $dest and it excludes some files types. It excludes my csv files and web.config files fine, but it won't exclude the Log folder contents. This is my script, what is the correct syntax to exclude the files contents but not the Log folder itself?


$exclude = @('Thumbs.db','*-Log.csv','web.config','Logs/*')

Get-ChildItem $source -Recurse -Exclude $exclude | Copy-Item -Destination {Join-Path $dest $_.FullName.Substring($source.length)}

Answer



You'll need to setup a second Array with the paths you want to avoid and then add a filter in the pipe. Here's some sample code:


$exclude = @('Thumbs.db','*-Log.csv','web.config','Logs/*')
$directory = @("C:\logs")
Get-ChildItem $source -Recurse -Exclude $exclude | where {$directory -notcontains $_.DirectoryName}

Windows 8 - 2 languages. How to lock keyboard to only one?


I have small problem with my keyboard languages.


I have 2 languages installed on my PC. I have English set as display language and Polish used for Keyboard layout, date and time. (I just don't like Polish translation).


Because of that I'm able to switch keyboard layouts just by pressing [Win] + [Space], which is annoying.


Is there any way to remove ENG as keyboard layout and only use POL?


enter image description here enter image description here enter image description here



Answer



Under Languages delete the Polski/Polish option. Then under the Options for the English display language, add Polish as an input method, after which you should be able to remove the US keyboard layout. This should give you the combination you're looking for, i.e. English as the display language and Polish as the keyboard layout.


Thursday 29 August 2019

performance - Does installing many programs really slow down Windows?


I have always heard that it's a bad idea to install lots of software on a Windows machine, and new software should always be tested in a virtual machine so as to not permanently affect the operating system. But does the actual act of installing a piece of software really slow down the Windows OS? Or is it more due to the programs themselves running a bunch of background services?


To rephrase my question, if I were to continuously install software but then remove it later, would Windows still slow down?



Answer



If you're installing, trying and uninstalling lots of software, then a VM is very useful because they can be quickly reset to allow testing of new software in a "clean" environment - so there are other advantages.


As for your question:
Possibly. It depends entirely on the software.


If a piece of software uses/installs services, registry entries, background tasks, drivers, shared DLLs, etc - then yes you could potentially get performance loss. Even more so if it doesn't remove them when you uninstall the software.


But, any well written software should entirely clean up after itself when uninstalled.


Bottom Line


If the software isn't running and doesn't install any services, registry entries, background tasks, drivers, shared DLLs, etc, it will only reduce your disk space and not affect your performance (unless you're out of disk space, but then you've wider issues).


If the software installs any services, registry entries, background tasks, drivers, shared DLLs, etc (and/or leaves it behind when uninstalled), you might get performance loss. But it also might not be noticable until you've done this with lots of software, depending on how powerful your system is.


audio - FFmpeg x264 Encode Settings

My new Canon Vixia HF G30 video camera has an option to encode directly to 35 Mbit/sec Mp4 at 1080p60 and it does a nice job. I primarily use it to record my daughter's high school basketball games.


I need to make highlights from the camera files AND I WISH TO RETAIN AS MUCH QUALITY AND CLARITY AS POSSIBLE. Here is the workflow that I have developed with my limited understanding of FFmpeg:


STEP 1.) Join the camera produced mp4 clips into one mp4 file representing one game. Here is a representative command that I use for this step from a Windows command prompt (DOS box):


ffmpeg -f concat -i "\\mylancomputer\f\Canon\2013.09.21_san_francisco_game2\gameclipsfromcamera.txt" -c copy "\\mylancomputer\f\Canon\2013.09.21_san_francisco_game2\joined_fullgame.mp4"

This joins the game clips into a game video with no transcoding (I believe), and so this is good (it is quick and no additional compression artifacts are introduced).


STEP 2.) Cut highlight clips from the game video. Here is a representative command that I use for this step:


ffmpeg -ss 00:00:06.00 -i "\\mylancomputer\f\Canon\2013.09.21_san_francisco_game2\joined_fullgame.mp4" -acodec copy -vcodec copy  -t 00:00:20.00 "\\mylancomputer\f\Canon\2013.09.21_san_francisco_game2\1.mp4"

This produces the following 20 second clip starting at 6 seconds into the game video:


Highlight Sample (85 MB)


STEP 3.) I require a 2-second pause at the beginning of each highlight clip where a text overlay identifies my daughter. To get this I make a bitmap image from the first frame of the clip :


ffmpeg -i "\\mylancomputer\f\Canon\2013.09.21_san_francisco_game2\1.mp4" -ss 00:00:00.00 -f image2 -vframes 1 -deinterlace "\\mylancomputer\f\Canon\2013.09.21_san_francisco_game2\1freezeframe.bmp"

Here is the result.


Then loop the video for 2 seconds with CRF 0 to introduce no additional artifacts:


ffmpeg -loop 1 -r 59.97 -i "\\mylancomputer\f\Canon\2013.09.21_san_francisco_game2\1freezeframe.bmp" -c:v libx264 -crf 0 -pix_fmt yuv420p  -t 2  "\\Excelhero\f\Canon\2013.09.21_san_francisco_game2\1freezeframe.mp4"

Then add the text overlay label identifying Fiona:


ffmpeg -i "\\mylancomputer\f\Canon\2013.09.21_san_francisco_game2\1freezeframe.mp4" -vf drawtext="fontfile=/Windows/Fonts/Corbelb.ttf:text='Fiona':fontsize=40:fontcolor=yellow:x=1321:y=417"  -b:v 35M -minrate 35M -maxrate 35M -bufsize 35M    -profile:v high -level:v 4.2  -refs 2  -pix_fmt yuv420p  -bf 0    -r 59.97 "\\mylancomputer\f\Canon\2013.09.21_san_francisco_game2\1freezeframeannotated.mp4"

Which produces this file: [ ehasamples.excelhero.com/video/1freezeframeannotated.mp4 ]


(SuperUser only allowed me to include 2 live links)


Now we add a silent sound stream to the clip:


ffmpeg -f lavfi -i aevalsrc=0:0:sample_rate=48000 -i "\\mylancomputer\f\Canon\2013.09.21_san_francisco_game2\1freezeframeannotated.mp4" -shortest -c:v copy -c:a aac -b:a 255k -strict -2 "\\mylancomputer\f\Canon\2013.09.21_san_francisco_game2\1freezeframeannotatedwithsilentsound.mp4"

Resulting in this: [ ehasamples.excelhero.com/video/1freezeframeannotatedwithsilentsound.mp4 ]


(SuperUser only allowed me to include 2 live links)


The above is a 2-second video with my daughter labeled in suspended animation with a blank sound stream.


STEP 4.) The final operation is to join the 2-second video to the full clip from the camera. I can easily re-render by filter producing one output file from these two input files in this fashion:


ffmpeg -i "\\mylancomputer\f\Canon\2013.09.21_san_francisco_game2\1freezeframeannotatedwithsilentsound.mp4" -i "\\Excelhero\f\Canon\2013.09.21_san_francisco_game2\1.mp4" -filter_complex "[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" -c:v libx264 -r 59.97 "\\mylancomputer\f\Canon\2013.09.21_san_francisco_game2\1done.mp4"

But this is not a great solution. It is slow because the original footage from the video camera is re-rendered with the introduction of new compression artifacts. I can choose to add " -crf 0 " to get a lossless re-rendering, but this bloats the size of the clip by well over 1000%, in this case bringing our sample clip to over a gigabyte. So this is not a practical solution.


So I want to use the concat demuxer instead of the filter:


ffmpeg -f concat -i "\\mylancomputer\f\Canon\2013.09.21_san_francisco_game2\clipfiles.txt" -c copy "\\mylancomputer\f\Canon\2013.09.21_san_francisco_game2\1doneBAD.mp4"

With this approach the operation is quick as there is no re-encoding. BUT, the resulting file does not play properly. Here it is:


[ ehasamples.excelhero.com/video/1doneBAD.mp4 ]


(SuperUser only allowed me to include 2 live links)


The 2-second image displays the entire 22 seconds. Although the video does not play properly, the sound seems to work just fine. So my guess is that the two files (the clip from the camera and the 2-second label clip) are simply too far apart on their relative encoding. I have attempted to get them as close to identical as I can in terms of encoding by using MediaInfo and by using FFProbe, and the above series of commands are my best, but apparently are not sufficient.


So the question I have is simply this: is it possible with FFmpeg to make my labeled clip enough like the encoded footage from the camera in order for the Concat demux to succeed? If so, how?


This entire workflow is driven by batch file and is really simple on my part and so I like it and hope to use this methodology to allow me to quickly edit highlights from games going forward.


Conversely, is there a better (quicker, no transcoding) workflow using FFmpeg?


Thank you kindly for your assistance.

networking - Why can't routers use MAC addresses instead of private/local IP addresses?


I understand the reason public IP addresses are necessary to be that if we only had MAC to move data between one host and another, the entire Internet would be one massively flat network. But what is the need for private IP addresses? Why can't routers just connect to local clients using their MAC address?



Answer



The answer is your software applications and operating system are designed to communicate using TCP/IP, not directly with Ethernet MAC addressing.


So regardless of whether the remote computer/node you wish to communicate with is in your local network or in some other network halfway round the globe, that logical link is established with TCP/IP. That way applications just define the destination IP address in the IP packet, fill it with data (which is actually packed into a TCP/UDP segment), and send it along the way without having to worry how the underlying layers deal with the actual transmission.


It is the operating system's networking stack that determines if the IP address is local or remote:



  1. If local network, look for MAC address corresponding to that IP address and send the IP packet direct, which is in an Ethernet frame.

  2. If remote network, look for MAC address of default gateway router to send the IP packet, also within an Ethernet frame. The router retrieves the IP packet from the frame, looks at the address and determines the next node (and its MAC address) to pass it along, and sends it that direction in another Ethernet frame.


Note: it is totally possible for IP packets to be delivered in another data link protocol other than Ethernet (guess what, your dial-up or DSL modem is not connected to your ISP via an Ethernet cable). And applications should not have to care so as long as the destination IP address is reachable. It is also totally possible to wrap other networking protocol data (that is not an IP packet) in an Ethernet frame for transmission.


matroska - How do I tell ffmpeg to transcode to a video codec supported by Windows Media player?


The command below executed without error.


ffmpeg -i thevideo.mkv outvideo.avi

Subsequent attempts to play outvideo.avi in Windows Media player threw this error


You may need an additional video decoder to play this file.

This file contains a track in an unknown format (code "ARGB") format. You may need to
install a DirectShow decoder for this video format in order to play this file.

Error detail provided by Windows Media player indicates the mpg2 codec is required to play the video. How do I tell ffmpeg to transcode to a video codec supported by Windows Media player?



Answer



You can't, since ffmpeg on its own does not know which codecs are installed on your system and accessible for Windows Media Player. This is because ffmpeg uses its own libavcodec and libavformat libraries to encode and decode. So a video generated by ffmpeg must not necessarily play in Windows Media Player..




Solution 1: Install additional codecs



You may need to install a DirectShow decoder for this video format in order to play this file.



This is what you eventually have to do since Windows does not ship with every possible codec. In fact, Windows versions up until 7 ship with almost no additional codecs at all, requiring the user to install a codec pack like K-Lite or CCCP. However, you can't assume that every PC has those installed, and you might want to ship your videos with a media player like VLC, which provides its own codecs and does not depend on Windows


Installing additional multimedia codecs is something you should probably do on every fresh Windows machine though.




Solution 2: Convert to a codec WMP plays


According to the Information about the Multimedia file types that Windows Media Player supports, there are some formats natively supported, but they aren't too specific about that. If you want to be on the safe side, you should probably convert into Windows Media Video (wmv). For everything else, well, here's what Microsoft says:



Audio content or video content that is compressed with a wide variety of codecs can be stored in an .avi file and played in Windows Media Player, if the appropriate codecs are installed on the computer. Video codecs that are frequently used in .avi files include the following codecs [...]



ffmpeg's FAQ is a bit more specific. They say:



Which codecs are supported by Windows?


The following list of video codecs should work on most Windows systems:



  • msmpeg4v2, .avi/.asf

  • msmpeg4, .asf only

  • wmv1, .asf only

  • wmv2 .asf only

  • mpeg4, Only if you have some MPEG-4 codec like ffdshow or Xvid installed.

  • mpeg1video, .mpg only


Note, ASF files often have .wmv or .wma extensions in Windows. It should also be mentioned that Microsoft claims a patent on the ASF format, and may sue or threaten users who create ASF files with non-Microsoft software. It is strongly advised to avoid ASF where possible.


The following list of audio codecs should work on most Windows systems:



  • adpcm_ima_wav

  • adpcm_ms

  • pcm_s16le, always

  • libmp3lame, If some MP3 codec like LAME is installed.



So when you convert, you can specify the codec you want to use by using the -vcodec and -acodec options for video and audio respectively.


For example:


ffmpeg -i input.mp4 -vcodec msmpeg4v2 -acodec pcm_s16le output.avi

Note that this is using uncompressed audio, since you can't be sure about which audio codec will be supported by Windows. If you're lucky, you can try MP3 (and it should work with most new machines), and use the libmp3lame option.


macos - Mac: disable the "boop" sound played when search results are not found


When you search in a page in many Mac applications (Firefox, Chrome, TextMate), a sound is played when results are not found. It's the "boop" sound that usually indicates that you are unable to perform an action (eg click a window, etc.)


I use the passive voice because I don't how this sound is played, or if each app implements this differently. In any case, it quickly gets annoying -- is there a way to disable it just for search?



Answer



This is the default "alert" sound used as the audible bell.


Disable alert sounds altogether


You can generally disable it by lowering the volume — Note that unchecking "Play user interface sound effects" is not the same but it only disables sound effects from Finder, etc. The alert will still go.


Also, as far as I'm concerned, you can't disable it just for some apps.


enter image description here


Alerts in Firefox


Firefox seems to have special settings that you can access in about:config. You can disable those, although I personally didn't hear any sounds when searching in Firefox (4.0.1), but this could be OS specific?


enter image description here


windows - How do I rename a bunch of files in the Command Prompt?


I have a problem with filenames. The stupid camera I am using resets the autonumber sequence every so often, and therefore I am getting tons of conflicts if I try and put lots of photos in a single file.


I know there is a way to rename them all to something like the following:


1.jpg, 2.jpg, 3.jpg . . . 2000.jpg, etc...


Unfortunately, I am among the generation who never really used DOS much before Windows came out with all its fake gimmicks. I have tried finding an app to do this, but they are quite pathetic, so I want to just do it in either the Windows .cmd or just a plain .bat (that's where I found some decent control over files). Can anyone help me out with the code?



Answer



I've been loving the command line since the mid 80's but I have to admit this is one area where I always rely on Rename-It! I know you want DOS but I'll leave this one just in case someone stumbles through that hasn't heard of it.


During times when I needed extreme control over individual files (usually in groups) I have used a spreadsheet to build the batch file. In this case I use DIR/B to collect file names into a text file, paste them into one column, build the renaming command in a final column (D in this case) then paste that column into a .BAT file and run it.


enter image description here


How do I prevent Linux services from auto-starting?


I have recently migrated from Windows to Linux (xubuntu)


I am a developer and have installed everything I need, LAMP. In Windows I used to turn off all unnecessary services - I don't need the Apache or MySQL service running all the time. Whenever I needed MySQL I used to use:


net start mysql

How do I do the same in Linux?



  1. Disabling not-needed daemons from auto-starting?

  2. Starting them only when I need them?



Answer



In most linux distributions you can manually start/stop services by (as root or using sudo) running the following commands:


# /etc/init.d/apache2 start
# /etc/init.d/mysqld start

# /etc/init.d/apache2 stop
# /etc/init.d/mysqld stop

Which services that are automatically started is controlled by file links in /etc/rc[runlevel].d/ . Find your current runlevel by using the command "runlevel" as root


# runlevel
N 2

Which here indicates runlevel 2 Now you just have to remove those files in /etc/rc2.d/ which you don't want started.


Removing apache and Mysql on a desktop is usually ok, but be aware of removing other services.


Excel - split view of sheet horizontally but viewing two separated sets of columns instead of rows


I have a sheet in excel 2007 which is quite long horizontally. I'd like to see the 'first' columns of the sheet at the same time as the 'last' columns. If I split the sheet horizontally (with a top and bottom windows) it only lets me see two separated sets of rows (like A1 to A10 and A100 to A110). Is there a way to split horizontally but to see A1 to L1 in the top view and M1 to Z1 in the bottom one, for instance?



Answer



Copying blatantly from jcbermu's answer to Excel - Vertical scroll columns A, B, C, D, E but F, G, H stay the same,



  • On the "View" tab, "Window" panel, click on "New Window".  This gives you two windows of the same worksheet, which you can scroll independently.


  • Click the next button over (in the "View" tab, "Window" panel): "Arrange All".  In the "Arrange Windows" pop-up, select "Horizontal".  (You may also want to check "Windows of active workbook" if you have other files open.)


                  


    This will give you the layout that you want:





You can scroll the two windows independently horizontally, which, if I understand you correctly, is what you want.  You can scroll the two windows independently vertically (i.e., the windows are not synchronized vertically).  This might be useful or an inconvenience.


How to tell if a Windows computer has a 64-bit CPU or OS


How you can check if your Windows computer



  • Has an x86 (32-bit) or x86-64 (64-bit) processor?

  • Is running a 32 bit or 64 bit operating system?



Answer



If you are on 64-bit XP, under C:\ you will see a "Program Files" as well as "Program Files (x86)" folder.


System properties will also reflect a 64-bit OS:


alt text


troubleshooting - No video output from motherboard. How to debug this?

I have assembled the following system:



  • Intel g530

  • ASUS p8h61 m lx

  • Corsair 2 GB

  • WD 250 GB

  • Raidmax 500w


The system turns on but I don't receive any video output on the screen.


I tried the following:



  • Starting without a CMOS battery.

  • Starting without RAM.

  • Starting without HDD.


All the components are brand new. I don't know which component is faulty in my case, my motherboard or the processor or both? Also, do you have other suggestions that might help me debug this problem?

Why won't PC laptop completely power off after upgrade to Windows 10?


I have recently upgraded from Windows 8.1 to Windows 10 and it appears that it mostly successful. By and large I'm pretty happy with the upgrade however there is now a problem with turning off my laptop.


When I use any of the 'off' variations (shutdown/hibernate ext.) the laptop acts like its turning off and boils down to a low hum - but never actually turns off. Moreover the button becomes unresponsive to any further presses so that I can not turn on my computer without first enforcing a 'hard' shutdown by holding the button - which is bad for my laptop and will reduce its life considerably.


How can I resolve this?


Here's some info in case it's needed


Product name:HP Pavilion 15 Notebook PC 
BIOS:F.34-12/19/2014
Keyboard revision:77.35
Total memory:8.00 GB
Processor name:Intel(R) Core(TM) i5-4288U CPU @ 2.60GHz

Answer



Please downgrade Intel Management Engine Interface driver from v11xx to v9.5xx. Sleep And Shutdown problem solved... And also disable automatic update of drivers.


external hard drive - WD My Book making odd noises (doesn't sound like Click of Death)

I have a 2TB WD MyBook connected via Firewire. It is set-up as a 2TB drive (striped) rather than a 1TB drive (mirrored). It is less than 6 months old, contains less than 1TB of data, and is used mainly to store & play video media.


Reads and writes work as expected, however reads have started making an odd clunking noise. At first I thought it might be the Click of Death, but wikipedia's article has a recording of a WD drive failing and my drive doesn't sound like it.


Should I be worried, or is this common for striped drives? Is there anything I can do to help quiet the sound?

windows 7 - How can I permanently remove a seemingly stealthy ad-ware installer?

For the past one month, there seems to have a stealth installer lingering in my computer that will automatically install malicious plugins to all my browsers. I'm not sure what installer is that and I can never seem to trace them too.


The plugins will show up in names that appear "useful", like Media Player, Video Player, BetterSurf, all sort of crap names. I've uninstalled their browser plugins numerous times, but a few days later, the stealth installer will install another one to my browsers in another name, say Media Player 2 or something.


enter image description here


So recently, after I have been disabling and removing the plugins in the browsers, they have heightened their "security". Now I cannot even uninstall or disable the plugins because, at least in Chrome, it says that the plugin is "installed by enterprise policy".


enter image description here


The most annoying part is it will throw up pop-up advertisements and embed advertisements on webpages:


enter image description here


It does not affect only Chrome, but all my other browsers including IE and Firefox.


enter image description here


I scanned my computer and AVG did find those installers. I removed all of them, but they are not really being removed. A few days later, they all came back again only in different names.


What the heck is this, and how did this come into my computer? Now, how can I remove it permanently, for real?


I'm running on Windows 7.

Live CD with good anti-virus software to scan/repair Windows?

I browsed through the archives, and it seems like there's no live CD from which to run a good, up-to-date anti-virus application, at least to check whether a Windows host has been compromised



  • The Ultimate Boot CD has only three AV applications, and their virus definition is from... 2007

  • In a report, ClamAV scored very low. It's nice that it's open-source, but if it's not as good as commercial alternatives...


Those of you into this kind of thing, do you confirm that there's just no good live CD to inspect Windows hosts, and possibly repair them? If there is, what do you recommend?


Thank you.

windows 7 - how to run a command with admin priviledges when I don't have admin account on my Win7 computer


I am trying to open cmd with admin priviledges. That's because when executing a command I received a message that I don't have sufficient priviledges to run this command (mklink).


The problem is that I don't see an admin or Administrator account on my Win7 computer. When I go to Control Panel -> Accounts -> Manage other account, there are only 3 accounts:



  • MyName

  • ASP.NET Machine Account

  • Guest


MyName account is of type Administrator, so I think it should have administrative priviledges. That's the account I am currently logged in. However, for some reason, it is not sufficient to run mklink command.


How to solve this problem?



Answer



You need to run the cmd.exe program as administrator. Find the cmd.exe program and right-click on it, select Run as administrator.


enter image description here


macos - Can't delete files in trash because they don't exist on OS X 10.6?


Something funky happened on one of my external drives and now whenever I plug it in 2 files show up in my Trash. If I empty the Trash via Finder, nothing happens. Ditto for the Option+Empty Trash method.


Listing them via Terminal shows them as there


$ sudo ls .Trashes/501
¶_|íìê<-.b?† æâù©Ã¬Ã«—‡.*?§

But attempting to rm them or get any information about them shows them as not there


$ sudo ls -F .Trashes/501/
ls: ¶_|íìê<-.b\032†: No such file or directory
ls: æâù©Ã¬Ã«—‡.*\026§: No such file or directory

$ sudo rm .Trashes/501/*
rm: .Trashes/501/¶_|íìê<-.b\032†: No such file or directory
rm: .Trashes/501/æâù©Ã¬Ã«—‡.*\026§: No such file or directory

Any thoughts? I've never seen anything like this.


Thanks in advance!



Answer



Just



sudo rm -rf .Trashes



The directory will be recreated on the external by OS X as needed.


OR


Plug the drive into something with a different OS and zap it there.


If both of these fail, time to start checking filesystems and drive sectors...


Wednesday 28 August 2019

virtualbox - How do you add more space to a Fedora (LVM) partition?


In a nutshell, i have a VM that ran out of space. I increased the size of the VM's harddrive to be 4 times bigger but the OS partition is still only using 1x the space. I need to change the LVM partition to take up the extra 4x space but I don't know how to extend the LVM partition.


(NOTE: To make the screenshots given below I had to boot from a live-cd for gnome-partition-manager (aka gparted). Very unfortunately gparted is only able to "detect LVM" and can't do any LVM operations.)


Here is what "gparted" shows. Please notice that the "resize" option is not available:


enter image description here




The Problem:


I can't find good directions<1> on how to grow the LVM partition via GUI or command-line! How do you grow a LVM partition that was created by the default Fedora install?


If you are giving command line directions. Please explain what each line of commands does.



Answer



I thought I used to do this with system-config-lvm GUI tool in CentOS, but it's not working for me today. So I had to go old school. As always, this might destroy your data, so MAKE A BACKUP!! Thanks to experts across the internet for providing these hints. Unfortunately my notes do not include attribution details. Note I performed all of these changes while the system was live.



  1. Enlarge the disk using fdisk

    1. fdisk -l (to see the partition layout, typically we're dealing with /dev/sda2)

    2. fdisk /dev/sda

    3. d (delete a partition)

    4. 2 (if the part we want to grow is /dev/sda2; note this does not delete any data on disk)

    5. n (create a new partition)

    6. p (primary partition)

    7. 2

    8. (default starting block, typically 14 since swap is first)

    9. (default ending block, full size of the partition)

    10. make sure partition type is 8e for Linux LVM

      1. t

      2. 8e



    11. w (write changes to disk)



  2. reboot to get new partition table

  3. pvresize /dev/sda2

  4. pvscan should show new larger size

  5. lvextend -l +100%FREE /dev/vg_centos6/lv_root (-L +10G to add 10GB is another option)

  6. resize2fs /dev/vg_centos6/lv_root

  7. df should show new free space


virtual machine - Is it possible to get a Virtualbox VM always start from same time, if so how?

I am trying to use VB to set up a Windows 7 VM for use in a training course. I want the virtual machine always to start up from the same conditions, in particular:



  1. The VM always starts at the same date and time

  2. The disk remains unchanged as a result of the previous exercise


I have worked out how to configure a disk as "immutable" which should take care of (2), but I can't get the VM to start at the same time. After some looking around I found this:



Once installed and started, the Virtualbox Guest Additions will try to synchronize the guest time with the host time. This can be prevented by forbidding the guest service from reading the host clock:


VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1



I tried this with the VM shut down, and with it started up, but it does not seem to do anything. On the same documentation page there is also a mention of a parameter "--timesync-set-start" however I cannot see any mention of the format for setting date and time. Help would be welcome.

linux - Rsyslog outputting to custom log file


Can anyone tell me what I did wrong here?


Here is the ultimate question:


Why when I use the logger command can I not get it to output to a custom log file in /var/log?


In my script:


logger -i -t ANM -p local7.info "This is a local 7 test"

In the rsyslog.conf I appended the following to the end of the file:


local7.* /var/log/anm.log

Also, the script has permission for the /var/log/anm.log file


* UPDATE *


So I forgot to restart the logging services. I have tried rebooting and "service rsyslog restart" Still no change. The test text does not show up in /var/log/anm.log but it does appear in /var/log/syslog


* UPDATE *


What permissions does /var/log/"yourlogfilehere" need? Owner, Group, rwx?


I have tried setting grp and own to root and to the username running the logger command. No change with either.


I have also tried creating log files inside a custom directory in /var/log. ie /var/log/anm/anm.log and setting both types of permissions for the directory.


* UPDATE *


rsyslogd is running


syslog     598  0.0  0.1  31060  1292 ?        Sl   03:02   0:02 rsyslogd -c5

and here is the output from my /etc/rsyslog.conf file


#  /etc/rsyslog.conf    Configuration file for rsyslog.
#
# For more information see
# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
#
# Default logging rules can be found in /etc/rsyslog.d/50-default.conf


#################
#### MODULES ####
#################

$ModLoad imuxsock # provides support for local system logging
$ModLoad imklog # provides kernel logging support (previously done by rklogd)
#$ModLoad immark # provides --MARK-- message capability

# provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514

# provides TCP syslog reception
#$ModLoad imtcp
#$InputTCPServerRun 514


###########################
#### GLOBAL DIRECTIVES ####
###########################

#
# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.
#
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

# Filter duplicated messages
$RepeatedMsgReduction on

#
# Set the default permissions for all log files.
#
$FileOwner syslog
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
$PrivDropToUser syslog
$PrivDropToGroup syslog

#
# Where to place spool files
#
$WorkDirectory /var/spool/rsyslog

#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf

local7.* /var/log/anm.log

I also tried putting it in /etc/rsyslog.d/50-default.conf (I am running Ubuntu 12.04 LTS)


#  Default rules for rsyslog.
#
# For more information see rsyslog.conf(5) and /etc/rsyslog.conf

#
# First some standard log files. Log by facility.
#
auth,authpriv.* /var/log/auth.log
*.*;auth,authpriv.none -/var/log/syslog
#cron.* /var/log/cron.log
#daemon.* -/var/log/daemon.log
kern.* -/var/log/kern.log
#lpr.* -/var/log/lpr.log
mail.* -/var/log/mail.log
#user.* -/var/log/user.log
local7.* /var/log/anm.log

* UPDATE *


Well I finally figured it out. I wish someone had answered this for me. Took several days to figure out what was wrong, but I guess there just aren't very many people on superuser.


The issue was with the file permissions of the custom log file as I originally theorized. I thought I had the permissions correct, but it turns out the owner needs to be syslog and the group adm. I determined this by comparing to the user.log file. Once permissions were modified and tested again, all works perfectly! I hope this helps someone else out there quicker than I was able to find answer.



Answer



Well I finally figured it out. I wish someone had answered this for me. Took several days to figure out what was wrong, but I guess there just aren't very many people on superuser.


The issue was with the file permissions of the custom log file as I originally theorized. I thought I had the permissions correct, but it turns out the owner needs to be "syslog" and the group "adm". I determined this by comparing to the user.log file. Once permissions were modified and tested again, all works perfectly! I hope this helps someone else out there quicker than I was able to find answer.


Here are the final permissions


-rw-r--r-- 1 syslog adm 0 Aug  3 05:09 anm.log

javascript - What tools can be used to download all images in a webpage?



I would like to download all images in a web page. The tool should be smart enough to examine the css and javascript files in the page source to look for the images.


Ideally, it should also replicate the folder hierarchy, saving the images in the correct folder. For example, the web page may have some images for menu items stored in images/menu/ and for background images it may be stored in images/bg/.


Is there such a tool that you know of? (preferably in Windows but Linux is still ok)


Many thanks to you all.



Answer



wGet for windows can recursively download a site. It should keep your folder structure. You may need to delete the html files after getting everything, but IMO, it's very easy to use.


http://gnuwin32.sourceforge.net/packages/wget.htm


use the "-r" flag to recursively download a site. e.g. wget -r http://example.com


Here's a brief tutorial on site downloading.


http://linuxreviews.org/quicktips/wget/


Outlook 2013 can't preview Office files?

Outlook 2013 refuses to preview Word, Excel and PowerPoint files saying "This file cannot be previewed because of an error with the following previewer"... and so on.


Even after downloading the file, it still won't open.

What are the Windows A: and B: drives used for?


In Windows you have a C-drive. Everything labeled beyond that is with the following letter.


So your second drive is D, your DVD is E and if you put in a USB stick it becomes F and the following drive G. And so on and so forth.


But then, what and where are A and B-drives?



Answer



Short Version: A: & B: are reserved by floppy disk drives, so C: is used by hard drives for backwards compatibility reasons.




Once upon a time, the early CP/M and IBM PC style computers had no hard drive. You had one floppy drive, and that was it. Unless you spent another $1k or so on a second floppy drive, then your system was smokin'! If you only had one drive it was common to boot from one disk, put in the other disk with your programs and data, then run the program. Once the program finished, the computer would request that you reinsert the boot disk so you could use the command line again. Copying data from one disk to the other was a series of


Please insert source disk into drive A:...
Please insert destination disk into drive A:...
Please insert source disk into drive A:...

By the time hard drives became cheap, the "expensive" computers typically had two floppy drives (one to boot and run common programs, one to save data and run specific programs). And so it was common for the motherboard hardware to support two floppy drives at fixed system addresses. Since it was built into the hardware, it was thought that building the same requirement into the OS was acceptable, and any hard drives added to the machine would start with disk C: and so forth.


During the transition from 5.25" disks (which were actually, physically floppy) to 3.5" disks (which were encased in a harder plastic shell) it was common to have both drives in one system, and again it was supported on the motherboard with hardware, and in the OS at fixed addresses. As very few systems ran out of drive letters, it was not thought to be important to consider making those drives re-assignable in the OS until much later when drives were abstracted along with addresses due to the plug'n'play standard.


A lot of software was developed since that time, and unfortunately much of it expected to see long-term storage on the C: drive. This includes the BIOS software that boots the computer. You can still attach two floppy drives, boot into DOS 6.1, and use it as you would have in the early 90's, with floppy drives A: and B:.


So largely the reason for starting the hard drive at C is for backwards compatibility. While the OS has abstracted data storage to some degree, it still treats A: and B: differently, in such a way that allows them to be removed from the system without altering the OS, caching them differently, and due to early viruses treating their boot sector with more caution than the hard drive's boot sector.


For Windows specifically, it's worth mentioning that you can use A: and B: as the names for volumes, be it a flash drive or an internal hard drive.


hard drive - Windows Abnormally High Disk Usage / 100% Disk Usage

I have been experiencing an abnormally high disk usage on Windows 8.1 for a couple of months now that has greatly hindered the speed of my laptop, particularly when a process is retrieving memory from the page-file.


The disk usage often reaches 100% usage and slows the system down to a halt despite only reading and writing at a very slow rate, sometimes never even reaching beyond kilobytes a second.


Solutions I've attempted:



  • Running chkdsk /r

  • Disabling prefetch and superfetch (despite not owning an SSD) via their registry keys

  • Manually setting the pagefile size

  • Disabling the pagefile (Resulting in BSODs every week or so)

  • Messing with any hard-drive related BIOS settings (there were none)

  • Defragmenting the hard-drive with a rainbow of third-party and official defragmentation software

  • Disabled notifications

  • Any combination of the above

  • Pretty much any other solution I've found searching Google and this website


I've often noticed when it hits 100% disk usage multiple processes are utilizing 0.1% of the disk usage.


Process Monitor shows nothing of value.

How can I reset windows 7 file permissions?

I looked at this post and it seemed to be close to what I want, but my case might be a little worse:


How can I reset my windows 7 file permissions to a rational state?


Basically a while back I (very stupidly) changed the permissions on all sorts of system folders, and eventually rendered my computer virtually unusable. I managed to hack administrator privileges back onto key folders and get it working, but in doing so I only modified permissions a lot more away from the natural state. I'm looking at this icacls stuff, but ultimately I need to reset EVERYTHING back to what it was in The Beginning, before I messed with it, from the C: directory all the way down. Right now application data is what's giving me problems, and I can't get it to work no matter how much I fiddle with those specific permissions.


I will be forever grateful for help on how to do this without having to reformat.


Update: I've found that it's in an odd position where I may have set the permissions for something more or less correctly, but any and all automated actions (like running batch operations from an elevated command line or trying to apply changes to subfolders) will still tell me "access denied." However if I manually navigate to those folders and simply try to open them, Windows tells me that access is denied, but that by clicking "ok" I can permanently give myself access to it, and that fixes problems. This is great except in order to fix this I have to manually open every folder affected, and there doesn't seem to be any pattern to it. How can I fix this!?


Further update: This question has gotten a lot of views but very little activity. I eventually gave up and reinstalled Windows.

Excel pivot table, difference between fields in the same column

I have table that has the same account names but for different years (sample below). I want to create a pivot item field that calculates the difference between the years for the same account name



Account Name Year Amount
Account 1 2014 15000
Account 1 2015 20000
Account 2 2014 30000
Account 2 2015 60000

So for Account 1 the difference is 5K and coount 2 the difference is 30K. How do i get the difference for the two fields when the amounts belong to the same column and can only be differentiated by year?


Sum of Amount Column Labels


 
Row Labels 2014 2015 Grand Total
Account 1 15000 20000 35000
Account 2 30000 60000 90000
Grand Total 45000 80000 125000



The output I would like to show is below:

I need the change to be part of the pivot table because I want to then get the top 40 base on change column.


Sum of Amount Column Labels



Account. 2014 2015 Change
Account 2 30000 60000 30000
Account 1 15000 20000 5000
Grand Total 45000 80000 35000


How do I mask the Firefox browser signature?


Does anyone know of a way to mask the Firefox browser signature, so that it looks like Internet Explorer to the rest of the world? I know there is a plugin to use the IE rendering engine, but that kind of defeats the purpose of using Firefox. What I'd really like to find is something that will simply replace the Firefox browser signature with something else and not affect how the browser itself renders pages, etc. Is there anything like that out there?



Answer



Try this User-Agent switcher plugin for Firefox: User Agent Switcher 0.7.2


alt text


windows xp - Microsoft Security Essentials for a business


This is 2 questions really -




  1. Am I allowed to install Microsoft Security Essentials 1.0 in a business of 200 - 300 users?




  2. Is Microsoft Security Essentials 1.0 adequate protection (real-time scanning, updates etc)?





Answer



Answer 1: Unfortunately, no. The license specifically states in the first bullet point in section 1



You may install and use any number of copies of the software on your devices in your household for use by people who reside there or for use in your home-based small business.



Answer 2: It sounds good to me, though I haven't looked at any lab comparisons yet. I have started recommending it to co-workers for their home computers -- it's a lot better than nothing!


linux - framebuffer not available. How to install the device /dev/fb/0 on Ubuntu?

I am trying to run an application that uses framebuffer on 2.6.31-14-generic #48-Ubuntu.


All I need to do is to install a framebuffer device to get rid of the following error:


/dev/fb/0: No such file or directory
framebuffer not available.
FATAL: no framebuffer available

I searched Google and found some resources indicating to do that on Grub2 - I got nothing though I followed them seamlessly.


Any ideas?

worksheet function - Check if Excel cell text is numeric using formula only


I have to find out if my cells text is a numeric value and wanted to use an elegant non VBA method that doesn't impede on its current state or value.


What I've found is that the ISNUMBER() function only works if the cells are number formatting or has no spaces if text formatting e.g.:


number as text examples


For the first three I've used =ISNUMBER(...) and my last attempt is =ISNUMBER(TRIM(...)).


The only method I've used that doesn't use VBA is to override my current values using text to columns then use the =ISNUMBER() function.


Note: I am proficient with VBA and Excel and understand I could create a user-defined function. But I don't want to as this imposes a macro required workbook or an add-in to be installed, which I can and have done in some cases.


I will appreciate any advice, thoughts (even if they tell me it can't be done) or VBA solutions (won’t be marked as answer however).



Answer



Try multiplying the cell value by 1, and then running the IsNumber and Trim functions, e.g.,:


=IsNumber(Trim(A1)*1)


wireless networking - Two SSIDs on one router

I wish to set up two networks using my router. If I create two SSIDs, can I assign them to two different channels, to keep them "physically" separate? If I cant do this, does this mean the two networks are treated the same as a single network?


EDIT: If both the SSIDs used the same encryption technique, would this affect whether they are viewed as one single network? Or is it just the channel which matters?

Tuesday 27 August 2019

import - Importing an EPS vector file to Microsoft Word without losing quality

If I import an .eps picture to Microsoft Word as normal, the quality
of the vector picture comes down (the image gets rasterised.


In this case, the EPS was produced with the pgfplot package and tikzpicture,
But it would be great to have a general way of importing PDFs, PSs or EPSs into Word.


So, how can I import .eps/.pdf/.ps to MS Word without losing quality?

windows xp - Cannot find ECS 945GCT drivers



I reinstalled windows xp sp3
In device manager I have two yellow marks:
- PCI Simple Communication Controller
- SM Bus Controller


CPU-Z says my MB is ECS 945GCT-M2 chipset i945G.


I visited so many sites to find the drivers - no success.


Any help, pls.



Answer



When you have unknown hardware which is 20 years or less old you usually can get the PCI device ID. This will help you indentify which hardware it is, rather than a generic PCI Simple Communication Controller or similar.


For unix like OS'ses such as FreeBSd, Linux or OS X use lspci or pciconf.


For windows you can use the hardware ID tab in the device manager.


To start the device manager either go to [start] [run] and type devmgmt.msc or right click on the [my computer] icon on your desktop, select "manage" and click on the device manager option.


(Screenshots from win 7. It is similar in XP).


Starting the device manager via start run devmgmt.msc


Starting the device manager via my computer and manage


From device manager:



  • Go to the device you want to find the hardware ID from.

  • Right click on it and select "properties".

  • Go to the tab "Details" and change "Device description" to "Hardware ID".


Image of the harware IDs in the device management screen


Note the value with the lines like this one: PCI\ven1002&dev_6898&subsyst_0b...


Search for that in the internet or use a site like http://www.pcidatabase.com/.


Note that these IDs have a fixed format. The first number will always indicate the manufacturer. In this case that is ATI/AMD (ATI was bought out by AMD).


enter image description here


The remaining numbers indicate all the detaiils, often down to the revision number.


memory - Can a 32-bit OS machine use up all 8GB RAM + 20GB page file?


What I understand about 32-bit OS is, the address is expressed in 32 bits, so at most the OS could use 232 = 4G memory space -- I assume the unit is bytes, so 4GB.


Does this mean if any machine with a 32-bit OS (be it Windows or Unix) has more than 4GB total of RAM + page file on hard disk, for example 8GB RAM and 20GB page file, its memory will never be "used up"?


By "used up" I mean that increasing RAM or page file won't help the performance; of course, it's always possible an application will keep requesting memory from the OS but failing.


Similarly, if this 32-bit OS machine has 2GB RAM and 2GB page file, increasing the page file size won't help the performance. Is this true?



Answer




What I understand about 32-bit OS is, the address is expressed in 32 bits, so at most the OS could use 2^32 = 4GB memory space



The most that the process can address is 4GB. You are potentially confusing memory with address space. A process can have more memory than address space. That is perfectly legal and quite common in video processing and other memory intensive applications. A process can be allocated dozens of GB of memory and swap it into and out of the address space at will. Only 2 GB can go into the user address space at a time.


If you have a four-car garage at your house, you can still own fifty cars. You just can't keep them all in your garage. You have to have auxiliary storage somewhere else to store at least 46 of them; which cars you keep in your garage and which ones you keep in the parking lot down the street is up to you.



Does this mean any 32-bit OS, be it Windows or unix, if the machine has RAM + page file on hard disk more than 4GB, for example 8GB RAM and 20GB page file, there will never be "memory used up"?



Absolutely it does not mean that. A single process could use more memory than that! Again the amount of memory a process uses is almost completely unrelated to the amount of virtual address space a process uses. Just like the number of cars you keep in your garage is completely unrelated to the number of cars you own.


Moreover, two processes can share non-private memory pages. If twenty processes all load the same DLL, the processes all share the memory pages for that code. They don't share virtual memory address space, they share memory.


My point, in case it is not clear, is that you should stop thinking of memory and address space as the same thing, because they're not the same thing at all.



if this 32-bit OS machine has 2GB RAM and 2GB page file, increasing the page file size won't help the performance. Is this true?



You have fifty cars and a four-car garage, and a 100 car parking lot down the street. You increase the size of the parking lot to 200 spots. Do any of your cars get faster as a result of you now having 150 extra parking spaces instead of 50 extra parking spaces?


Portable VirtualBox kernel driver error

I'm using PortableVirtualBox for about a year with no problems. But from two weeks now -without upgrading or updating anything on Virtualbox or anything related on my PC- after running any of my VMs for a while then I cannot start any other VM, because VB pops up this error


---------------------------
VirtualBox - Runtime Error
---------------------------
Cannot access the kernel driver!
Make sure the kernel module has been loaded successfully.
---------------------------
Abort
---------------------------

If I check the VB kernel driver with ServiWin the driver (VBoxDrv) shows up as "Stopping...", but never stops totally.



  • I tried with NET STOP VBoxDrv (as administrator), but it says that the service is starting or stopping

  • Tried the same running as System with PSEXEC -s, same result.

  • Reinstalled PortableVB and the VB runtimes, no luck

  • Try to kill the program using sc queryex vboxdrv, but the status is STOP_PENDING and the PID is 0, then I cannot find the process to kill

  • Checked memory with Memtest86 disk with MHDD, did a Prime95 torture test to find posible hardware errors: no problems there

  • If I reboot the PC, then I can use VB but the problem strikes again after starting a couple of VMs (or restarting the same VM after using it for a while)


My configuration:



  • PortableVirtualBox 3.3.6.1 (Launcher)

  • VirtualBox 4.0.10.r72479

  • VB USB and network drivers installed

  • Win7 Pro-64 Host

  • AMD Athlon II X3 450 / 8 Gby RAM


Any ideas to fix the initial error or force the VB driver to restart without rebooting?

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...