Thursday 31 May 2018

Is there any practical reason to dual-boot Linux alongside Windows?

I am planning on getting an extra hard drive for my Windows tower, and am thinking about trying out Linux again as a dual-boot.


However, I can't really think of any pros to this, only cons:



  • More complicated to switch OSes. (Edit: because I have to shut down every time!)

  • Less storage space. (Edit: because the Linux partition will take up space)

  • I can already run Unix programs on Windows via Cygwin.

  • I have to store data on FAT32 instead of NTFS. (Edit: FAT32 is the only platform supported enough by Windows and Linux, yet is less reliable then NTFS.)


Is there any practical reason to do this, or should I just format the hard drive as 100% non-bootable NTFS for storage?


Now a community wiki.

linux - Upgrade to ubuntu 13.04 from 12.04 with iso image

I have ubuntu 12.04 installed on my system. I want to upgrade it to ubuntu 13.04. I want to do this upgrade using an iso image of ubuntu 13.04.


I tried this Solution


But it didn't work for me.


After running these command I didn't get any alerts about updating. Also I don't understand the gksu part of the solution.


Here are the steps I tried:


sudo mount -t iso9660 -o loop PATH/TO/ISO /cdrom

then


sudo /cdrom/cdromupgrade

Read more: http://linuxpoison.blogspot.tw/2011/06/how-to-upgrade-ubuntu-using-alternate.html#ixzz2SFMqlOPx


I also wanted to know, If I can do this using a networked computer. By this I mean the iso file is on some other computer.


Thank you.

linux - Is there a way to limit maxdepth for ls -Rhal?

Is there a way to limit maxdepth in a ls -Rhal command? I am aware of find . -maxdepth, but I want to be able to get the file information that comes with ls -Rhal.

microsoft office - How can I change the language of a OneNote section (or page/notebook)


I have a OneNote section in a notebook named "Personal" and some pages in this section. I can't change the section (or page or notebook) language. I tried changing the Office default language from the language settings but that didn't help.


Is there a way to change the language of an OneNote section, page or notebook. It's really annoying because every time I start typing something new, it sets the proofing & spelling language back to the old default language.


It appears that it might be tied to the input language I've chosen from the windows control panel. In that case, is it possible to decouple the OneNote section/page language from my input language because I really don't want to change my input language and keyboard layout.



Answer



After some testing I can confirm that OneNote always uses the input language set in the Region and Language control panel.


However, you can combine any input language with any keyboard layout (at least in Windows 7), so the (hopefully temporary) fix is to add a new input language combined with the original keyboard layout.


Copy UNC network path (not drive letter) for paths on mapped drives from Windows Explorer


I frequently want to share Windows network paths to files with other folks on my team via email or chat. We have a lot of mapped drives here, both ones we set up ourselves and ones set up by our IT overlords. What I'd like to be able to do is to copy the full real path (not the drive letter) from Windows Explorer to send to folks.


Example: I have a file in my "Q:" drive, \\cartman\users\emueller, and I want to send a link to the file foo.doc therein to coworkers. When I copy the file path (shift+right click, "copy as path") it gets the file name "Q:\foo.doc" in the clipboard. This is unhelpful to others, who would need to see \\cartman\users\emueller\foo.doc to be able to consume the link.


In Explorer it clearly knows the full path - in the address bar I see "Computer -> emueller (\\cartman\users) (Q:) ->". Is there a way to say "hey man copy that path as text with the \\cartman\users\emueller not the Q: in it?"


I know I could just set up mapped network locations instead of the mapped drives for the ones that I set up personally and avoid this problem, but most of the mapped drives like the "users" share come from our corporate IT policy and can't be overridden. I could just make a separate network location and then ignore my Q: drive but that's inconvenient (and they do it so they can move accounts across servers). Sure my emailed path might eventually break because I'm losing the drive letter indirection but that's OK with me.



Answer



I had exactly the same problem -- not everyone had the same mapped drives as me, or mapped to the same letters.


After much searching I found a context menu extension named Path Copy Copy on GitHub (https://pathcopycopy.github.io/) which is an extended version of a similar, older extension (called Pathcopy) has quite a few options for copying paths as text, including one for UNC paths -- example of the options available are shown below:


Path Copy Context Menu example


You can also choose to show only one or two lines on the base context menu, for example you can have two lines, Copy Long Path, and Copy Long UNC Path. It's great for emailing users in your company who have access to a network path, and if they have the same network mapping as you, you can choose the former, otherwise you can use the latter.


Update: As of version 12.0, a new "portable" installer is available on the above site, which installs only for the current user into the AppData\Local folder. I've not tried this, but it could be solution for those who are prohibited from installing normally.


notepad++ - Choose whether to save when quit

I am using notepad++ V6.4.2. When I close a file, it seems to save defaultly without asking me. How can I configure to get the save/not_save option back?

windows - How to choose default program to a file to be opened with same exe name?


I am not able to select default program for a file that uses same program exe name as it used previously, but now in different folder and thus different version. When ever i select the program, it wont select anything.


How do i force Windows XP to open with the program exe path i selected, and not smart-guess which program i meant? I deleted the older program exe and now when i select new program it thinks its deleted and wont allow me to select the new one.



Answer



You can always approach it by going to the Registry Editor. If you aren't familiar with editing the registry, I suggest you back it up first before attempting anything.


You can find the extension at HKEY_CLASSES_ROOT\.yourextension


For example, let's take WinRAR's .RAR extension. For that, I'd have to go to HKEY_CLASSES_ROOT\.rar on the Registry Editor. As you can see on the screenshot below, the (Default) REG_SZ key points to WinRAR.


enter image description here


Now we will go to the registry key that actually contains the application information. That is WinRAR and it should be located on HKEY_CLASSES_ROOT as well. So it will be located under HKEY_CLASSES_ROOT\WinRAR. As you can see on the image below, under the WinRAR key, you can jump directly to shell\open\command.


enter image description here


As shown above, you just edit the (Default) key and place the path to your application inside double quotes then a space and followed by %1 inside double quotes as well. %1 denotes the path to your file.


I hope this somewhat lengthy explanation can serve as a template for you to be able to easily remap your file extension to your newly updated executable. Once you get the hang of this, it should be pretty easy from here-on out.


redirection - Hostmonster Subdomain redirected to home server IP: How to ssh into home server using subdomain


I setup a home server to play with. Instead of remembering the IP address, I created a subdomain on my hostmonster personal website (http://subdomain.domainname.com) and redirected it to point at my server at home.


On my router firewall at home, I forwarded port 80 and 22 to allow web and ssh to get through to that server.


It seems, however, that my webhost forwards the port 80 requests, but does not forward ssh requests. I came to that conclusion after noticing the following:


When I access http://subdomain.domain.com I successfully see the web pages hosted on my home server. However, when I ssh into homeusername@subdomain.domain.com I cannot authenticate. ssh'ing into homeusername@homeIP works fine.


I also found that ssh'ing into webloginusername@subdomain.domain.com will ssh successfully into my web account.


Does anyone know how I can setup that kind of 'ssh forwarding' ?


Thanks in advance,



Answer



You need to go into your domain's name server, and create an A record for your subdomain that points at your home IP. If you don't have a static IP at home, then you'll need to setup a dynamic DNS. There are many Dynamic DNS providers on Google; find one you like.


The key part of your question is that you "redirected" your subdomain to point at your server at home. I assume that you used something like the HTTP refresh header. When you try to reach your home server through the redirect, this is how the flow works:



  1. You send a request on port 80

  2. The Hostmonster server receives the request on port 80

  3. The apache server sees the redirect, and forwards to the redirect's port 80

  4. Your request reaches your home router on port 80

  5. Your request reaches your home server on port 80


Now here's what happens when you try to ssh into your home server:



  1. You send a request on port 22

  2. The Hostmonster server recieves the request on port 22

  3. The Hostmonster sees that your user doesn't exist on the server; access denied


The difference is that on port 80, apache sees the redirect. On port 22, sshd doesn't know about a redirect and believes you're trying to ssh into the Hostmonster server.


Can I completely disable Cortana on Windows 10?


Windows 10 has Cortana, which I don't like. I disabled it as soon as I could. However, looking in Task Manager, the process for Cortana is still running, and can't be effectively terminated: ending the task simply results in the process respawning a few seconds later. Using the command


taskkill /IM Cortana.exe /F

has the same result: the process respawns.


Is there any way to disable Cortana so that the process doesn't keep running in the background, and doesn't respawn if terminated?



Answer



The easiest way to disable certain privacy aspects of Cortana is to use a third-party tool such as O&O Software's free ShutUp10.


Cortana in ShutUp10


Part of Cortana, though, is Windows Search, so there would still be an occasional Cortana process such as file indexing. However, there should no longer be any use of the internet by Cortana.


enter image description here


You can remove Cortana completely, if you wish, but that also removes Windows Search (though that might not be an issue if you use a third-party tool such as DocFetcher or Mythicsoft's Agent Ransack, which provide increased search functionality). That said, after a Windows 10 update, expect that Cortana would be reinstalled. Apparently, the only way now to permanently avoid Cortana is to use another OS, such as Linux.


windows 8 - Something happened and this app couldn't be installed



Something happened and this app couldn't be installed.


Please Try Again. Error Code: 0x800700b7.



I got this message while trying to upgrade an app in my new Windows 8 PC.


What is the fix?



Answer



I got this message when trying to run an app from a non-admin account on a new Windows 8 PC. Internet searches reveal various suggestions, but for me it seems to have resolved itself after a few hours and multiple reboots.


You shouldn't expect to buy a new Windows PC and use it right away. It will take several hours and several reboots before all of the initial updates are complete.


I suspect that many people have and will encounter this problem.


Execute multiple commands with 1 line in Windows commandline?


How can I execute multiple commands in the Windows commandline with just a single line?


So for example say I want to perform an SVN update and then copy all of the files to another location...


svn update; copy *.* c:\development\copy\

That doesn't work obviously. Is there a character or delimiter like ';' to perform something like this?



Answer



Yes there is. It's &.


&& will execute command 2 when command 1 is complete providing it didn't fail.


& will execute regardless.


Wednesday 30 May 2018

ssh - OpenVPN vs. SOCKS proxy


I've been trying to set up a secure connection over which I can browse the internet, and it seems like there are two options, and SSH SOCKS proxy or OpenVPN (at least, those two are what I have found, but I'm certainly no expert.)


the SSH SOCKS proxy is really easy to setup - literally just ssh -D {port} -i {key} user@host.


My question is -- what are the advantages of OpenVPN over a SSH SOCKs proxy? It seems like such a pain to set up compared to the SOCKS proxy. Is OpenVPN faster? Is it more secure? (I don't think so, at least according to this post)



Answer



The SOCKS tunnel provided by SSH allows forwarding outgoing TCP connections, and nothing else. On the other hand, OpenVPN is a true Layer 2/3 VPN, and as such can transport any kind of IP packets. This makes it useful for almost all kinds of networked applications, including those using UDP. It also means your computer has an actual IP address, which makes it possible for other hosts to connect to you. You are also not limited to applications with built-in SOCKS support.


Most of the benefits of a true VPN are however not needed for just web browsing; they are of more use when your goal is to e.g. have a permanent secure connection between two private network at different locations.


However, the last bit about not needing SOCKS support in applications is in fact important for web browsing too. While the browser itself will respect the SOCKS server settings, plugins (e.g. Flash) may not. This means that traffic done by plugins may go directly into the Internet.


There are ways to force applications through SOCKS seamlessly (including browser plugins). You can try my tun2socks software, though it does require some effort to set up. If successful, it will make everything go through SOCKS, and you should disable any existing SOCKS configuration in the applications themselves.


networking - Is it possible to reinstall Raspbian on a Raspberry Pi

I have a Raspberry Pi and I need to get the image reinstalled but it's a 4 hour drive away to it. The OS is Raspbian and it is connected through an Ethernet connection. I can SSH into the Raspberry Pi just fine, but I need to find a way to remotely reinstall the OS on it.


I hear there is something called PXE Network Install that might be able to do this, but how would I go about doing this? The website doesn't really have much information on doing this.

multi boot - Windows system drive letter changed after repair install

yesterday I did a repair install, because Windows froze on welcome screen after resizing its partition on a dual boot system. corresponding question


Everything worked fine so far, but now I am facing another challenge: The Windows drive letter changed from G: to C:, so that most programs, including drivers, firewall and virus scanner do not work anymore. I tried to reinstall the virus scanner, but the uninstaller said, that drive G: is not available.


What to do now, to get all programs running again? Is it possible, to rename C: to G: or will that mess up my system?

How can I resume a httrack mirroring session stopped by limit?


I was mirroring a site using HHTrack, and it ran for some time and stopped with log containing the following:



Too many URLs, giving up..(>100000)
To avoid that: use #L option for more links (example: -#L1000000)
14:48:58 Info: Top index rebuilt (done)

Does it mean it didn't mirror all pages?


How do I continue the mirroring without spending unnecessary time copying the already-mirrored files?



Answer



Use the action continue an interrupted download/mirror after increasing the URL limit.


For the command line version:


Action options:
w *mirror web sites (--mirror)
W mirror web sites, semi-automatic (asks questions) (--mirror-wizard)
g just get files (saved in the current directory) (--get-files)
i continue an interrupted mirror using the cache
Y mirror ALL links located in the first level pages (mirror links) (--mirrorlinks)

For the GUI version:


enter image description here


Auto attach new consoles to conemu


I want that when a console is openning ConEmu will automagically detect the console (for example - by executable path) and attach it in a new tab.


for example, a console of an application I'm developing therefore anytime I start it in debug mode a console is open - I want the ConEmu to detect that and attach it.


Is this possibe? How?


Thanks!!!



Answer



this can help, especially if consoles are opened through cmd.exe:


enter image description here


add windows defender service exception for internet radio


I'm streaming internet radio from here: http://www.protonradio.com/player/live/player.php and windows defender service is running pretty hard inspecting the stream as it comes in. I trust the stream, is there anything I can do to turn this inspection off?



Answer



This is what I use to add exceptions, you can revise for ProtonRadio..


;Add HOSTS to "Excluded Files and Locations" In Windows Defender

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths] "C:\Windows\System32\Drivers\etc\HOSTS"=dword:00000000


batch - Windows CMD - How to rename all files in all subfolders to parent folder name


Alright scripters,


Im still trying to wrap my head around the FOR command. What Id like to do is rename all files in all subfolders to the folder name they reside in, retaining their extensions. Id imagine it could be done with something like:


   For /R %X in (*.*) do REN %X 

Maybe Im wrong. Whats the correct way to do this? And it must be a script. Im not asking about Bulk Rename Utility or File Renamer Deluxe, etc.


Thanks for your time!



Answer



You can only accomplish your stated goal if each folder never has more than one file of any given type. That is not a reasonable expectation unless there are unusual circumstances.


But it is possible to insert the name of the parent folder in front of every file - something like
"fileName.ext" --> "parentFolderName_fileName.ext"


The FOR /R command can iterate the folder paths of all folders within a root tree.


The DIR /B /A-D "folderPath" command can list all files within a folder. But you don't want to rename files that aready begin with the parent folder name, so that can be piped to FINDSTR to exclude the already renamed files.


The results of the piped command can be iterated with FOR /F. The EOL and DELIMS options are used to make sure that the full name of every file is preserved.


The %%~nxD returns just the folder name and extension of the parent folder.


Putting it all together, the following long one liner can be used directly on the command line. It will process the tree rooted at the current directory.


for /r %D in (.) do @for /f "eol=: delims=" %F in ('dir /b /a-d "%D" 2^>nul^|findstr /vbic:"%~nxD_"') do ren "%D\%F" "%~nxD_%F"

The command can be put in a script, and then the root folder to process can be passed in as an argument. If no argument is given, then the script processes starting at the current directory. If an argument is given, then that value is used as the root folder.


@for /r %1 %%D in (.) do @for /f "eol=: delims=" %%F in (
'dir /b /a-d "%%D" 2^>nul^|findstr /vbic:"%%~nxD_"'
) do ren "%%D\%%F" "%%~nxD_%%F"

The code is simpler if you use my JREN.BAT regular expression renaming utility. It is pure script (hybrid batch/JScript) that runs natively on any Windows machine from XP onward. No 3rd party exe files are needed.


Full documentation is embedded within the utility - accessed via jren /?, or jren /?? if you want paged output.


The following simple command will process the tree rooted at the current directory:


for /r %F in (.) do @call jren "^" "%~nxF_" /p "%F" /fx "%~nxF_*"

The first two JREN arguments are the find/replace strings - The search matches the beginning of the file name, and the replace simply insert the parent folder name (with a trailing underscore). The /P "%F" option specifies the root folder. And the /FX "%~nxF_* option excludes files that already begin with the name of the parent folder, followed by an underscore.


The command can be put in a batch script that accepts an optional root folder as an argument (process current directory if no value given):


@echo off
for /r %1 %%F in (.) do call jren "^" "%%~nxF_" /p "%%F" /fx "%%~nxF_*"

thunderbird - How to display the size of single emails?


I would like to be able to see the size of every email in my Thunderbird. I know how to check the size of a mail folder but not for a single mail.


How can I accomplish this?



Answer



To choose columns, click on the icon which appears at the right edge of the column headings. You'll be shown a drop-down menu of columns; the headings with checkmarks are the ones that are currently shown in your mail folders.


Select Size.


alt text


partitioning - How to turn off System Restore and remove System Volume Information folders in Windows?


I met the same problem of not being able to shrink the Windows OS partition C: as much as I plan to due to unmovable files.


Having learned from this post, I would like to "turn System Restore off and remove System Volume Information folders". So I was wondering where and how I can "turn System Restore off and remov System Volume Information folders"?


This is the only way I can find out to solve my problem. If you have other way please let me know.



Answer



To turn off System Restore (Protection) in Windows 7:


From Microsoft:



  1. Open System by clicking the Start button, clicking Control Panel, clicking System and Maintenance, and then clicking System.

  2. In the left pane, click System Protection. Administrator permission is required if you are prompted for an administrator password or confirmation, type the password or provide confirmation.

  3. To turn on System Protection for a hard disk, select the check box next to the disk, and then click OK. – or – To turn off System Protection for a hard disk, clear the check box next to the disk, and then click OK.


To remove the System Volume Information folders, which I believe are unremovable in Windows:



  1. Download an Ubuntu Live CD

  2. Burn it

  3. Boot from the CD

  4. After boot, open up the drive in the Ubuntu desktop, highlight and delete the folder.


64 bit - Can I upgrade from Windows 7 32-bit to Windows 7 64 bit without reinstalling all of my software?




Possible Duplicate:
When reinstalling Windows 7, does the language, version, architecture (64-bit or 32-bit) or source (OEM, retail, or MSDN) matter?



I'm getting a new PC soon and thinking that I'll start with Win 7/32 bit then upgrade later (if needed) to 64 bit and add RAM (beyond 4 GB).


Is this fairly easy to do?



Answer



No.


X86/32-bit to X64/64 bit is not supported in any version of Windows through either upgrade or anytime upgrade.


Your only option would be to do a fresh install - however, if I was you, you should format the drive first to really get a fresh start.


You can however use Windows Easy Transfer which should make it easy to transfer your documents and reinstall your programs.


worksheet function - Split Excel Cell by last Delimiter


I need to split a cell by the first delimter (reading right to left) so that I can put that value in another cell.


For Example, my data in cell A1 could look like:


"something - more something - a lot more of something - (this is the text I need)"

Cell B1 needs the value "(this is the text I need)"


so far what I have is:


=RIGHT(a1,LEN(FIND(RIGHT("-"),a1)))

but this seems to only return the last char: ")".



Answer



You need this formula:


=MID(A1,FIND("~~~~~",SUBSTITUTE(A1,"-","~~~~~",LEN(A1)-LEN(SUBSTITUTE(A1,"-",""))))+1,LEN(A1))

Breakdown:


LEN(A1)-LEN(SUBSTITUTE(A1,"-",""))

Counts the number of times "-" occurs within the cell,


SUBSTITUTE(A1,"-","~~~~~",LEN(A1)-LEN(SUBSTITUTE(A1,"-","")))

Then replaces the last occurrence of "-" with "~~~~~". If "~~~~~" has the possibility of occurring normally in your input, use a different value here.


FIND("~~~~~",SUBSTITUTE(A1,"-","~~~~~",LEN(A1)-LEN(SUBSTITUTE(A1,"-",""))))+1

Finds the position of the "~~~~~" that we just created, and adds one so we start just after it. And then finally, the full formula uses that position and MID() to extract the desired text.


linux - Find document files and copy them to another directory


This is a bit of a basic question but I'm trying to copy all .doc files I find in a directory and copy them to another directory.


I know each command:


find -name '*.doc' .

and:


cp filename location 

How can I combine the two commands?



Answer



find /path/to/search -name "*.doc" -exec cp {} /path/to/copy/to \;

If there are a lot of .doc files this is your best option to avoid hitting the character limit.


linux - Does anyone know why rsync would keep sending the files over and over again?

I'm trying to using rsync to backup some files, about half a TB. It's now it a state where it keeps sending the same files everytime it runs.


for example:


rsync -av /data/source/* user@host:/data/dest
sending incremental file list
source/file1.txt
source/file2.txt

I then verify those files are copied over... then the next time it runs it does the same thing


rsync -av /data/source/* user@host:/data/dest
sending incremental file list
source/file1.txt
source/file2.txt

any idea why it's getting stuck on these files? I've tried to wipe the whole dest directory out and start over but no luck.


thanks,

vba - Create timestamp formula for Excel


The idea is simple, I'd like a function I could do something like =MOD_DATE_OF(A1:A4) and when any of the cells in such range is modified, the cell I assigned that formula gets the current date.


I have found some similar questions on the web and even here, but none of them quite it.


The closest I've got was this code somewhere (sorry, lost track of the source):


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Column = 1 Then
Target.Offset(0, 1).Value = Date
End If
End Sub

But it is still not a function..


I am using Excel from Office 2010


thanks



Answer



Here's a full-fledged solution that will allow you to monitor change-dates of different ranges. Note, this uses a function from Chip Pearson's tools for using arrays in VBA and function from a StackOverflow answer by user Thomas.


The basic idea is that a global array, in which the addresses of all monitored ranges (past or present) are stored with their most recent update dates, allows the function and the Worksheet_Change Sub to interact. The Worksheet_Change Sub updates this array by checking the changed range against all stored ranges. The function looks for the monitored range in the array and returns the stored change-date if it's found. Otherwise, it will return today's date (which will then be added to the array).


Also, to prevent timestamps being lost when the workbook is closed and the array of timestamps is deallocated, the array must be written to a sheet on the Workbook_Close event, and then rewritten to the array on the Workbook_Open event.


In a module, paste the following code.


Public funcInstances() As Variant

Public Function MOD_DATE_OF(monitor As Range)
Application.Volatile True
Dim i As Long
Dim tmpArray() As Variant

If Not IsDimensioned(funcInstances) Then
ReDim funcInstances(1 To 1, 1 To 2) As Variant
funcInstances(1, 1) = monitor.Address
funcInstances(1, 2) = Date
Else
For i = 1 To UBound(funcInstances, 1)
If funcInstances(i, 1) = monitor.Address Then
MOD_DATE_OF = Format(funcInstances(i, 2), "yyyy-mm-dd")
Exit Function
End If
Next i
tmpArray = ExpandArray(funcInstances, 1, 1, "")
Erase funcInstances
funcInstances = tmpArray
funcInstances(UBound(funcInstances, 1), 1) = monitor.Address
funcInstances(UBound(funcInstances, 1), 2) = Date
End If
MOD_DATE_OF = Format(funcInstances(UBound(funcInstances, 1), 2), "yyyy-mm-dd")
End Function

'ExpandArray() is the work of Chip Pearson. Code copied from http://www.cpearson.com/excel/vbaarrays.htm
Function ExpandArray(Arr As Variant, WhichDim As Long, AdditionalElements As Long, _
FillValue As Variant) As Variant
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ExpandArray
' This expands a two-dimensional array in either dimension. It returns the result
' array if successful, or NULL if an error occurred. The original array is never
' changed.
' Parameters:
' --------------------
' Arr is the array to be expanded.
'
' WhichDim is either 1 for additional rows or 2 for
' additional columns.
'
' AdditionalElements is the number of additional rows or columns
' to create.
'
' FillValue is the value to which the new array elements should be
' initialized.
'
' You can nest calls to Expand array to expand both the number of rows and
' columns. E.g.,
'
' C = ExpandArray(ExpandArray(Arr:=A, WhichDim:=1, AdditionalElements:=3, FillValue:="R"), _
' WhichDim:=2, AdditionalElements:=4, FillValue:="C")
' This first adds three rows at the bottom of the array, and then adds four
' columns on the right of the array.
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim Result As Variant
Dim RowNdx As Long
Dim ColNdx As Long
Dim ResultRowNdx As Long
Dim ResultColNdx As Long
Dim NumRows As Long
Dim NumCols As Long
Dim NewUBound As Long

Const ROWS_ As Long = 1
Const COLS_ As Long = 2


''''''''''''''''''''''''''''
' Ensure Arr is an array.
''''''''''''''''''''''''''''
If IsArray(Arr) = False Then
ExpandArray = Null
Exit Function
End If

'''''''''''''''''''''''''''''''''
' Ensure the dimension is 1 or 2.
'''''''''''''''''''''''''''''''''
Select Case WhichDim
Case 1, 2
Case Else
ExpandArray = Null
Exit Function
End Select

''''''''''''''''''''''''''''''''''''
' Ensure AdditionalElements is > 0.
' If AdditionalElements < 0, return NULL.
' If AdditionalElements = 0, return Arr.
''''''''''''''''''''''''''''''''''''
If AdditionalElements < 0 Then
ExpandArray = Null
Exit Function
End If
If AdditionalElements = 0 Then
ExpandArray = Arr
Exit Function
End If

NumRows = UBound(Arr, 1) - LBound(Arr, 1) + 1
NumCols = UBound(Arr, 2) - LBound(Arr, 2) + 1

If WhichDim = ROWS_ Then
'''''''''''''''
' Redim Result.
'''''''''''''''
ReDim Result(LBound(Arr, 1) To UBound(Arr, 1) + AdditionalElements, LBound(Arr, 2) To UBound(Arr, 2))
''''''''''''''''''''''''''''''
' Transfer Arr array to Result
''''''''''''''''''''''''''''''
For RowNdx = LBound(Arr, 1) To UBound(Arr, 1)
For ColNdx = LBound(Arr, 2) To UBound(Arr, 2)
Result(RowNdx, ColNdx) = Arr(RowNdx, ColNdx)
Next ColNdx
Next RowNdx
'''''''''''''''''''''''''''''''
' Fill the rest of the result
' array with FillValue.
'''''''''''''''''''''''''''''''
For RowNdx = UBound(Arr, 1) + 1 To UBound(Result, 1)
For ColNdx = LBound(Arr, 2) To UBound(Arr, 2)
Result(RowNdx, ColNdx) = FillValue
Next ColNdx
Next RowNdx
Else
'''''''''''''''
' Redim Result.
'''''''''''''''
ReDim Result(LBound(Arr, 1) To UBound(Arr, 1), UBound(Arr, 2) + AdditionalElements)
''''''''''''''''''''''''''''''
' Transfer Arr array to Result
''''''''''''''''''''''''''''''
For RowNdx = LBound(Arr, 1) To UBound(Arr, 1)
For ColNdx = LBound(Arr, 2) To UBound(Arr, 2)
Result(RowNdx, ColNdx) = Arr(RowNdx, ColNdx)
Next ColNdx
Next RowNdx
'''''''''''''''''''''''''''''''
' Fill the rest of the result
' array with FillValue.
'''''''''''''''''''''''''''''''
For RowNdx = LBound(Arr, 1) To UBound(Arr, 1)
For ColNdx = UBound(Arr, 2) + 1 To UBound(Result, 2)
Result(RowNdx, ColNdx) = FillValue
Next ColNdx
Next RowNdx

End If
''''''''''''''''''''
' Return the result.
''''''''''''''''''''
ExpandArray = Result

End Function

'IsDimensioned() is the work of StackOverflow user @Thomas. Code copied from https://stackoverflow.com/a/5480690/657668
Public Function IsDimensioned(vValue As Variant) As Boolean
On Error Resume Next
If Not IsArray(vValue) Then Exit Function
Dim i As Integer
i = UBound(vValue)
IsDimensioned = Err.Number = 0
End Function

In the appropriate Worksheet module, paste the following code.


Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
Dim j As Long
If IsDimensioned(funcInstances) Then
For j = 1 To UBound(funcInstances, 1)
If Not Intersect(Target, Range(funcInstances(j, 1))) Is Nothing Then
funcInstances(j, 2) = Date
End If
Next j
Me.Calculate
End If
Application.EnableEvents = True
End Sub

Finally, in the ThisWorkbook module, paste the following code:


Private Sub Workbook_BeforeClose(Cancel As Boolean)
If IsDimensioned(funcInstances) Then
Application.ScreenUpdating = False
'Store array on a new temporary and hidden worksheet.
Dim tmpS As Worksheet, tmpR As Range
Set tmpS = Worksheets.Add
tmpS.Name = "TEMP Record of Timestamps"
tmpS.Visible = xlSheetHidden
Set tmpR = tmpS.Range("A1:B1").Resize(UBound(funcInstances, 1), 2)
tmpR.Value = funcInstances
ThisWorkbook.Save
Application.ScreenUpdating = True
End If
End Sub

Private Sub Workbook_Open()
Dim ws As Worksheet, tstamps As Range
Dim wsfound As Boolean
wsfound = False
Application.ScreenUpdating = False
For Each ws In ThisWorkbook.Worksheets
If ws.Name = "TEMP Record of Timestamps" Then
wsfound = True
Exit For
End If
Next ws
If wsfound Then
Set tstamps = ws.UsedRange
funcInstances = tstamps.Value
Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True
End If
Application.ScreenUpdating = True
End Sub

NOTE for anyone who stumbles across this page: Many of the comments are about previous, incomplete solutions, so don't be confused by them.


Tuesday 29 May 2018

macos - How to create image from Windows PC and run on Mac OS X


I don't want to carry my work notebook to home every day, so I thought of creating an image of the notebook's hard disk, and run it on Mac OS X 10.6 Snow Leopard.


So with what software can I create a virtual image, and with which software can I run this image. I have a preference for free software, but other solutions are welcome too.



Answer



VirtualBox


After finding this question: How to import an image for Virtualbox..., I did some further research and found this link describing how to turn a Windows installation into a Virtualbox virtual disk (it's for Linux, actually, but I guess one can adapt it to MacOS X). The advantage would be that VirtualBox is free, of course. That said, I have no experience with it.


Edit: harrymc suggested this article which describes how to use the VMWare Converter to convert the existing Windows installation to a vmdk-disk (VMWares Virtual Disk format). VirtualBox is able to use this disk just like its own format. (Thanks, harrymc.)


VMWare


VMWare has a Converter Tool (named VMWare Converter Tool... ;-) that does exactly that: http://www.vmware.com/download/fusion/windows_to_mac.html The Tool is free... VMWare Fusion not so much, it's just my tool of choice.


Parallels


There seems to be a special "Switcher" Edition of Parallels that has an easy way to transfer a complete Windows installation via an USB cable. Then again that solution costs money.


Can I auto-generate subtitles from a video file?



Is there software that can generate subtitles based on the speech from the a video file (e.g. WMV, MPEG, etc)?



Answer



I've tried that Youtube one and it's terrible - It can't deal with American accents let alone UK ones which I need.


The best solution I've found is http://speakertext.com/ they provide a captioning service for $2 per minute of video.


'Run as Administrator' does not work on Shortcuts in Vista


I have two Vista Ultimate 32-bit OSs installed on my PCs here (one desktop for about 3 years, the other a laptop for 1 year), and have been experiencing the following rather irritating problem for a while on both of the computers:


Right-clicking on any shortcut in Windows, be it in Windows Explorer, the desktop, or the Start Menu, and then selecting Run as Administrator has absolutely no effect. I am of course running on an administrator account, and the expected behaviour should be for a UAC prompt to appear to confirm the execution of the given program.


This is persistent behaviour which I have not since been able to eliminate, even temporarily, on either of the installations. It is worth nothing that the issue appeared only a number of months after setting up the OS, and is quite possibly due to a program I installed at some point on both machines, which has corrupted something (perhaps a registry entry) that prevents the Run as Administrator action. Unfortunately, since I've virtually mirrored the OS configuration and programs installed on both PCs, there is no real possibility I can determine which setup program caused the issue by cross-comparison.


I have described exactly the same problem here on the MSDN forums, which some feedback, but nothing close to a solution unfortunately. The only real recommendation I received in the end was to wipe and reinstall, which is not a feasible solution for me.


Any suggestions here, even long-shots, would be most appreciated here, as I am getting fairly desperate for a resolution.



Answer



Interestingly (and thankfully) this problem seems to have fixed itself after one of the recent Vista updates. On both computers I can now run any shortcut as administrator.


How to find the largest size of memory?


how can I calculate the largest size of memory that can be used with a 16 bit address bus and a 8 bit data bus?


Is it 2**16 bytes - with regard to the address bus - or 1 byte - with regard to the data bus?



Answer



It is the address bus bit count that determines how many locations you may pinpoint.


And yes, '2' to the power of 'bits' tells the amount.


In case of a longer read/write (16, 32 or even more bits) the "next" adress required is read.
Note also the difference between small-endian and big-endian CPU's; see
http://en.wikipedia.org/wiki/Endianness


The data bus size determines how big chunks the CPU will transfer at a time (for one read operation), it doesn't "stop" the ability to read more (e.g. the old M68008 is a 16/32 bit CPU - having fourteen 32bit registers, combined with an 8 bit external data bus - reading/writing 32 bits from/to memory is handled by the internal logic of the CPU - but takes longer as it has to be completed in several memory access operations).


Is a Windows 7 homegroup(workgroup) and a Windows Vista Domain compatible?


Can a Windows 7 computer connect to a Windows Vista domain?


Can a Windows Vista computer connect to a Windows 7 homegroup(workgroup)?



Answer



There is no such thing as a Windows Vista domain. There are NT and Active Directory domains of different vintages, but they all run via Windows Server. None of them run on Vista. Windows 7 can connect to any of them.


Windows Vista can connect to a "Windows 7" Workgroup. I use quotation marks because workgroups here are not specific to the version of windows or even Windows itself. I think it's likely you mean "Homegroup". Homegroup is a Windows 7-only feature, but it is possible to access some Homegroup resources in Vista.


Please remember that when dealing with technical concepts, accurate terminology is important.


linux - Finding the number of commands in command history


I'm trying to find the number of commands I've executed. At first I thought the command below would work:


wc -l < $HISTFILE

But now I know that the number this command returns doesn't show the number of commands, because a command can be multi-line.


How can I find the number of commands in my command history?



Answer



There's this command called fc that processes the command history list.


According to man fc,



−l (The letter ell.) List the commands rather than invoking an editor on them. The commands shall be written in the sequence indicated by the first and last operands, as affected by −r, with each command preceded by the command number.



we can use fc -l to list the commands previously entered. By default, this command prints the last 16 commands, in the following format:


 [number of command]  [command]

Now if we could get the last command and only print its number, that would be the number of commands in the history file. If we look at man fc again,



−number A negative decimal number representing the command that was executed number of commands previously. For example, −1 is the immediately previous command.



we can see that by specifying -n, we get the last n commands. So the command, fc -l -1 would return the last command.


❯ fc -l -1
3088 man fc

Now that we have that, we can simply print the first column of it, using awk:


❯ fc -l -1 | awk '{print $1}'
3089

Prevent mouse to turn on monitor - Windows


after monitor turns off after predefined amount of time, there is a danger of accidental wakeup by just touching a table. Is there any way not to wake monitor up when it rests and mouse moves just a little?


Thank you for help



Answer



Not that I know of, as the system is actually on.


The closest setting is to stop the mouse waking the machine out of stand by -


alt text


Sorry I couldn't be more help - the best solution I can think of is to turn the mouse upside down... it will work!


Monday 28 May 2018

windows 7 - Transfer Songbird metadata to new computer


I recently decided to move from my ancient Windows 7 (32bit) laptop to a newer Windows 7 64bit one. Unfortunately, I'm having trouble transferring my Songbird library.


I copied the folder with all my music files, and it imported just fine on the new computer. However all the metadata such as play counts and playlists is missing. Does anyone know how I can transfer it? I've tried searching online, but I wasn't able to find anything that looks helpful.


As I understand it, Songbird stores this information in an internal database somewhere, but I was unable to find the database, and I don't know if copying it over would even work anyway.



Answer



There are few places where programs commonly store their additional data. Songbird's directory containing its settings and some other files should be in one of these - you just have to copy it over to the same place on your new PC.



  • %appdata% - actually an alias to Application Data\Roaming directory. Type %appdata% in the Start menu search box and press Enter to open it.

  • Application Data\Local - go one level up from %appdata% and you'll find a directory called Local, that's it.

  • Program Data - it's located in your system drive's root and can be hidden, type C:\Program Data in the Start menu search box and press Enter to open it. This is a less common one, used for system-wide, user-independent data.

  • Application's directory - the folder where an app is installed, usually located in C:\Program Files (or C:\Program Files (x86) if it's a 32-bit program installed in a 64-bit OS). Sometimes overwriting this directory with the old one also copies all settings and data.


In the latter case remember that you'll have to move that folder to appropriate directory - Songbird is a 32-bit app, so it will probably be installed in Program Files (x86) on the new PC, but in Program Files on the old one.


linux - Automatic versioning upon file change (modify/create/delete)


I am looking for an implementation (on Linux) of a mechanism which would automatically and transparently version any changes in a directory (recursively). This is intended to be an addition (possibly replacement if all the requested features are available) to standard versioning (SVN, git, ...)


A product on MS Windows which does this is AutoVer (to have a better idea of the requirements). I would love to have something like that but aimed at Linux in a non-graphical environment.


I saw that there are some attempts to have this functionnality on Linux, the closest one I found is autoversionning on Subversion but it is not obvious to implement on existing environments (servers where, for instance, configuration files are local).


Maybe something working with inotify?


Thank you in advance for any pointers! WoJ



Answer



1. General purpose method using bazaar & inotify


This is untested by me but I found this write up that makes use of bzr (bazaar) & inotifywait to monitor a directory and version control the files in it using bazaar.


This script does all the work of watching the directory for changes:


#!/bin/bash

# go to checkout repository folder you want to watch
cd path/to/www/parent/www
# start watching the directory for changes recusively, ignoring .bzr dir
# comment is made out of dir/filename
# no output is shown from this, but wrinting a filename instead of /dev/null
# would allow logging
inotifywait –exclude \.bzr -r -q -m -e CLOSE_WRITE \
–format=”bzr commit -m ‘autocommit for %w/%f’” ./ | \
sh 2>/dev/null 1>&2 &
# disown the pid, so the inotify thread will get free from parent process
# and will not be terminated with it
PID=`ps aux | grep inotify | grep CLOSE_WRITE | grep -v grep | awk ‘{print $2}’`
disown $PID

# this is for new files, not modifications, optional
inotifywait –exclude \.bzr -r -q -m -e CREATE \
–format=”bzr add *; bzr commit -m ‘new file added %w/%f’” ./ | \
sh 2>/dev/null 1>&2 &
PID=`ps aux | grep inotify | grep CREATE | grep -v grep | awk ‘{print $2}’`
disown $PID

exit 0;

2. Managing /etc


For the special case of managing your system's /etc directory, you can use the app etckeeper.



etckeeper is a collection of tools to let /etc be stored in a git, mercurial, darcs, or bzr repository. It hooks into apt (and other package managers including yum and pacman-g2) to automatically commit changes made to /etc during package upgrades. It tracks file metadata that revison control systems do not normally support, but that is important for /etc, such as the permissions of /etc/shadow. It's quite modular and configurable, while also being simple to use if you understand the basics of working with revision control.



Here's a good tutorial to get you started with it.


3. Using git and incron


This technique makes use of git and incron. For this method you need to do the following:


A. Make a repo


% mkdir $HOME/git
% cd $HOME/git
% git init

B. Create a $HOME/bin/git-autocommit script


#!/bin/bash

REP_DIR="$HOME/git" # repository directory
NOTIFY_DIR="$HOME/srv" # directory to version

cd $REP_DIR
GIT_WORK_TREE=$NOTIFY_DIR /usr/bin/git add .
GIT_WORK_TREE=$NOTIFY_DIR /usr/bin/git commit -a -m "auto"

C. Add an entry to incrontab


% sudo incrontab -e $HOME/srv IN_MODIFY,IN_CREATE,IN_MOVED_FROM,IN_MOVED_TO $HOME/bin/git-autocommit

4. Using Flashbake


Another option is to use a tool like Flashbake. Flashbake is the version control system that Cory Doctorow (of BoingBoing fame) uses to write his books.


Flashbake uses git under the hood to track changes but is somewhere between doing automated backups and using a plain version control system yourself.



Cory wanted the version to carry prompts, snapshots of where he was at the time an automated commit occurred and what he was thinking. I quickly sketched out a Python script to pull the contextual information he wanted and started hacking together a shell script to drive git, using the Python script’s output for the commit comment when a cron job invoked the shell wrapper.



Resources



windows - How can I get the date in a locale independent format in a batch file?


I'm trying to read a file that contains a date in the filename.


The problem is when the date format is US in the system: mm/dd/yyyy it does not working .


For this format : dd/mm/yyyy it works as expected.


I need to get the date in this format dd/mm/yyyy even so the system is set with US format.


I'm new with batch and no idea how to get the date in the required format.


Here is my batch file:


for /f "delims=/ tokens=1-3" %%a in ("%date%") do (
rem Lets name our new variable "rdate" for reverse date
set _date=%%a-%%b-%%c
)

set source=%path%.csv
echo %source%
set dest=%path%_%_date%.csv
echo %dest%

Answer



It sounds like a bad idea to be parsing a date that could be in various formats which format you don't know. Better to get the date in a specific format, even if that means not pure batch but invoking powershell.


C:\Users\tod>for /f %a in ('C:\Windows\System32\WindowsPowershell\v1.0\powershell -Command "Get-Date -format yyyy_MM_dd__HH_mm_ss"') do set datetime=%a

C:\Users\tod>set datetime=2018_01_22__09_15_33

or without time.


C:\Users\tod>for /f %a in ('C:\Windows\System32\WindowsPowershell\v1.0\powershell -Command "Get-Date -format yyyy_MM_dd"') do set datetime=%a

C:\Users\tod>set datetime=2018_01_22

C:\Users\tod>

Once you have that you can do


C:\Users\tod>echo %datetime:~0,4%
2018

C:\Users\tod>

And so on.. So you can set whatever variable to equal the year, month, date in month.


Added


If you wanted to not use powershell and you don't mind that this will only work for US formatted dates.


C:\Users\tod>echo %date%
01/22/2018

C:\Users\tod>echo %date:~0,2%
01

C:\Users\tod>echo %date:~3,2%
22

C:\Users\tod>echo %date:~6,4%
2018

C:\Users\tod>

So you really should be able to see how to do it


set first=%date:~0,2%

set second=%date:~3,2%

set third=%date:~6,4%


C:\Users\tod>set first=%date:~0,2%

C:\Users\tod>set second=%date:~3,2%

C:\Users\tod>set third=%date:~6,4%

C:\Users\tod>echo %first%/%second%/%third%
01/22/2018

C:\Users\tod>echo %second%/%first%/%third%
22/01/2018

C:\Users\tod>

So you can say set ukdate=%second%/%first%/%third% and you can say echo %ukdate%


And that non-powershell method only works if you know the format of the date on the system, and know that it's US. I would generally recommend against batch, because for example what if a new revision of the OS comes along and the output of a command is a bit different and your code presumes a particular format in its parsing. And while in this case batch is in one sense, neat, sometimes it can be like banging sticks together. It's a good idea to know batch and to use it a bit but to install some other scripting language like Ruby or Python or Golang or NodeJS. But if you want to use solely batch for this, then there it is.


How can I verify the read/write integrity of a compact flash device?

I've got a bunch of compact flash cards that I've used heavily in a professional photo and video capacity.


I'm concerned that one of them is going bad, since I am seeing files (most often video, but occasionally photo) become corrupt on a hard to predict basis. I am absolutely sure this is not related to unmounting the card before removing it - the corruption is visible directly after properly removing the card from the camera.


The problem is, I don't know which card is problematic, and the issue seems to be intermittent, so I can't just shoot them full and look for a bad file (and corruption isn't always apparent even then - if the bad bit(s) are within the data portion of a file, it might not be obvious). The problem is rare enough that I can't reliably reproduce it (except when there's a client with a job with files that absolutely, positively cannot be lost - then it's sure to strike).


I could RMA them all under warranty (they're all Sandisk with lifetime warranty), but I'd prefer not to (how do I justify sending in a batch of 5 cards? what do I use during the month that they're gone?).


I'm looking for a tool that will fix them. Specifically, I need something that will do a write/read/write/read cycle for the whole card, and ideally do a full format to remove any bad bits, as well as letting me know the status (is one card particularly bad? are all the others perfectly fine? what level of errors am I seeing on a general basis?).


I'm aware of the badblocks tool, but was hoping to find something tailored more towards CF (and which would hopefully let me map the bad areas out of use, if it's only a few bits). I would prefer a non-windows tool if possible.


Has anyone else solved this problem without simply blindly replacing your devices? Some of the suspect cards are pretty new.

Windows 7: The ARP entry addition failed: Access is denied


I'm on Windows 7 and am trying to assign a static arp entry for my default gateway using the command:


arp -s 172.24.7.254 00-05-01-f9-28-00 172.24.1.20

But I get the following error:


The ARP entry addition failed: Access is denied.

When I don't mention my ip-address at the end, the static ip gets assigned for the virtual interface created automatically for virtualbox. I'm using an elevated prompt. I'll be grateful for suggestions. Thanks.



Answer



Here is what I found and it works great


arp -s : access denied. On the default gateway


Here is what I used :


delete:


netsh interface ip delete neighbors "Network card name here" "Gateway.IP.goes.here"

Add:


netsh interface ip add neighbors "Network card name here" "Gateway.IP.goes.here" "MAC-address-of-gateway-with-dash-here"

good luck


How does Http server distinguish between computers behind a router


HTTP servers usually operate at port 80. Yet NAT routers as most are these days assign port to outgoing requests so they would know when request is returned that which computer connected to it, it's suppose to be. They do it cause they can only use one public IP even though all computers behind router are given public IP address they are local IP address. Meaning they only work for everyone behind that router.


So how does server handles this. It only works at port 80, and router sends at whatever ports it wishes to do based on what is available and how it is programmed.


My understanding:




  1. Computer A to router. 22.22.22.22.22:80




  2. Router to World: 12.68.191.1.102:1 -ISP given IP address:Port to distinguish between computers connected to it.




Now what


Or maybe there is a difference between port and source port.



Answer



You're confusing source ports and destination ports. When the request is sent to the HTTP server, the destination port is 80 since that's what web servers typically listen on. NAT routers can choose whatever source port they want. When they receive replies, they use the destination port (and other information), which should match the source port they choose for the outbound packets, to know which connection the packets are associated with.


Your computer has to do the same thing. Say you fire up two different browsers and you point each at superuser.com. How do you think your computer tells which TCP connection incoming packets belong to?


Why does OS X Lion ask for my password whenever I delete a file in my home directory?


I updated to Mac OS Lion and now every time I delete any file it asks me for my password. Any file - be it on the Desktop, in the Downloads folder or in any other place. It asks me for my password every time.


That behaviour is annoying. Is it the new default? Or there is something wrong?


Edit:


For example: this file, which is located on the desktop.


➜  Desktop  l | grep terminal
-rw-r--r--@ 1 Nerian staff 841913 22 jul 14:16 terminal.png

Edit:


Seems that quite a lot of people are having the same issue:


https://discussions.apple.com/thread/3199093?start=0&tstart=0


https://discussions.apple.com/thread/3197928?start=0&tstart=0


Edit:


I can delete the same file – a screenshot in the desktop – using the terminal and I am not prompted for a password. If I use the GUI then I am prompted.


Also, If I create a new account and make a new screenshot and try to delete everything works just fine. No password required.


When I am prompted for my password and I write it, the file is then deleted yet it doesn't appear in the bin.



Answer



The problem was that the .Trash folder in my user's directory was owned by root.


➜  ~  l | grep .Trash
drwx------ 82 root staff 2788 25 jul 17:26 .Trash

In order to give back the ownership to my user issue the following command:


➜  ~  sudo chown your_user_name ~/.Trash 

Automate script | Rename a defined list of filename by a defined list of word powershell

All my code:


    #read list filenames + filter#
$listname = Get-ChildItem 'Y:\Users\H\Documents\D\Game Of Throne' -Filter *.bmp

#Read list file txt#
$line = Get-Content 'Y:\Users\H\Documents\D\Game Of Throne\prod\recup.txt'

#account name#
$count_listname= $listname.count

#account line txt#
$count_line = $line.count




#number of max action (inf_list)#
$count= $count_listname, $count_line
$inf_list= ($count | measure -Min).Minimum

#Var file by file of folder#
$list_split= $listname
$list_split | foreach {
$list_split = $_ -split '*'
Write-Host $list_split []
}

#Var line by line of the textfile#
$line_split = $line
$line_split | foreach {
$line_split = $_ -split '*'
Write-Host $line_split []
}
#Select type to delete#
$erase=Read-Host "Enter the type to delete"

#Select number of line#
$nb = Read-Host "Enter the number line to add."

#Line of replace#
$list_input[$nb] = Read-Host "Line(s):"

#Boucle#

$i= 0
while ($i -le $nb-1) {
$list_input[$i]| rename-item -newname { $_.name -replace ( $erase , $list_input[$nb] )}
$i++
}

#output#
echo "File folder" $listname ""
echo "Fichier texte " $line ""
echo "Number of file in folder" $count_listname ""
echo "Number of line in txt" $count_line ""
echo "Number max of actions" $inf_list ""
echo "Line by line" $line_split ""
echo "List one by one" $list_split ""
echo "Type to delete" $erase ""

#echo table($line_split[n] or $line_split[n]#

I have some problems to automate the script (Read-Host) This is working with the $erase but i need it too for the number of table-line and then the lines (without a textfile)


Hamdoun

Windows 10 black screen with blinking cursor - cannot boot

I cannot start my Windows machine. I get a black screen and a blinking white cursor. It is not responsive.


What happened was I was using the PC but the machine was running very slow, and then became completely unresponsive. I hard powered off the machine. When I restarted it, I got the Windows loading dots going round in a circle for some time. I then hard powered off the machine again. Upon restart, I experienced the symptoms above.


I believe that perhaps Windows was doing an upgrade and got interrupted.


I have tried the following trouble shooting steps:


I created a Windows bootable installation USB stick from here.


When I boot from the USB, I am presented with a screen asking



It looks as if you started an upgrade and booted from installation media. If you want to continue with the upgrade, remove the media from your PC and click yes. If you want to perform a clean installation instead, click No.



If I click "yes", the machine reboots and takes me back to the black screen again.


If I click "No", it asks for my localisation preferences, which I specify and click "next".


I am then presented with a screen with two options



Install Now
Repair your computer



I click "Repair your computer"


I am presented with a screen with two options



Troubleshoot
Turn off your PC



I click on "Troubleshoot"


I get



System Restore
Go back to previous version
System Image Recovery
Start-up repair
command prompt



I click "start up repair"


It shows "Diagnosing your PC", and then "start up repair couldn't repair your PC"


I click "System restore" – I get



To use system restore, you must specify which Windows installation to restore. Restart this computer, select an operating system, and then select System restore.



I click "Go back to the previous version", and I get



We ran into a problem and won't be able to go back tot the previous version of windows. Try resetting your PC instead *Troubleshoot > Reset the PC"



I click on "System Image Recovery", but I don't have a system image to recover from.


I click on "Command Prompt". Following advice found elsewhere on the Internet, I try the bootrec command:


bootrec /RebuildBcd

I get



Successfully scanned Windows installations.
Total identified Windows installations: 1
C:\Windows
Add installation to boot list? Yes etc



I enter "Y"


I get



Element not found



I enter


bootrec /fixMbr

I get



The operation completed sucessfully



I enter


bootrec /fixboot

I get



Element not found



I reboot the system without the USB stick. Same black screen with blinking cursor. I boot using the USB stick again, and go back to the command prompt.


I enter


bootsect /nt60 ALL

It states


C: \\?\volume{00030698-0000-0000-0000-100000000000}
Successfully updated NTFS filesystem bootcode

I reboot and get the black screen again.


I Reboot with the USB and go to the command prompt again. I enter


bcdboot C:\windows /s M:

It gives



Failure when initialising library system volume



You may note the the /s option is specifying a volume called "M". I don't have that volume.


I use disk part like this:


Diskpart
list volumes

It shows 3 drives that I use as storage drives, the USB stick, and the C drive which is where Windows is installed. I think that perhaps my Windows installation is using this volume as the system partition and the boot partition. So I tried


bcdboot c:\windows /s c

I get


BFSVC Error: Failed to set element application device. Status = [c00000bb]
BFSVC Error: Failed to populate BCD store. Status = [c00000bb]

I check that the C volume is active


DiskPart
select volume 2
detail volume

I get


Partition 1
Type : 07
Hidden : No
Active : Yes
Offset in bytes : 1048576

I check the that other volumes are not active. They are not except for the USB stick.


I try


bootsect /nt60 N: /force /mbr 
attrib -s -h C:\boot\bcd
ren C:\boot\bcd bcd.old
bcdboot c:\windows /s c:

I get



Boot files successfully created



I try rebooting. Same black screen. FFS. I go back to the command prompt as above.


I try


bootrec /scanos

I get



Successfully scanned windows installations
Total identified Windows installations: 1
[1] C:\Windows
The operation completed successfully



I try


bcdedit /export c:\BCD_Backup

I get



The store operation has failed.
The requested system device cannot be found



At this point I try rebooting the system and get the same black screen.


I have now run out of ideas and things to try. Does anyone have something I can try?

memory - Why does RAM have to be volatile?


If computer RAM was to be non volatile like other persistent storages, then there would be no such thing as bootup time. Then why is it not feasible to have a non volatile ram module? Thank you.



Answer



When most people read or hear "RAM", they think of these things:


Two SDRAM sticks, courtesy of Wikipedia


Actually these are made of DRAM chips, and it's controversial if DRAM is a kind of RAM. (It used to be "real" RAM, but technology had changed and it's more of a religious belief if it's RAM or not, see discussion in the comments.)


RAM is a broad term. It stands for "random access memory", that is any kind of memory that can be accessed in any order (where by "accessed" I mean read or written, but some kinds of RAM may be read-only).


For example HDD isn't a random access memory, because when you try to read two bits that aren't adjacent (or you're reading them in reverse order for whatever reason) you have to wait for the platters to rotate and the header to move. Only sequential bits can be read without additional operations in between. That's also why DRAM can be considered non-RAM - it's read in blocks.


There are many kinds of random access memory. Some of them aren't volatile and there are even read-only ones too, for example ROM. So non-volatile RAM exists.


Why don't we use it? Speed isn't the biggest problem as for example NOR Flash memory can be read as fast as DRAM (at least that's what Wikipedia says, but without citation). Write speeds are worse, but the most important issue is:


Because of the inner architecture of non-volatile memory, they have to wear out. The number of write-and-erase cycles is limited to 100,000-1,000,000. It looks like a great number and it's usually sufficient for non-volatile storage (pendrives don't break that often, right?), but it's an issue that already had to be addressed in SSD drives. RAM is written way more often than SSD drives, so it would be more prone to wearing.


DRAM doesn't wear out, it's fast and relatively cheap. SRAM is even faster, but it's also more expensive. Right now it is used in CPUs for caching. (and it's truly RAM without any doubt ;) )


ubuntu - Reinstalling Windows 7 Bootloader

On a computer running windows 7, I created a new partition and installed Ubuntu on the empty partition. Then in windows, I deleted the partition that ubuntu was installed on. After restarting my computer, I get an error:


error: no such partition


It sounds like when ubuntu was installed, it wrote over the windows bootloader, and I deleted the partition that Ubuntu's was on.


It sounds like I can reinstall the windows bootloader using a windows 7 disk, but will this erase the data that was on the windows partition? If it does, is there any way to recover that data?

hard drive - Equivalent of badblocks on Windows or DOS

Is there a utility in DOS or Windows that is as thorough as badblocks on Linux?

How do I force Windows 7 to create a new domain profile with same name as an existing one?


I had a corrupt user profile (let's call it bob) affecting xslx files for Excel on a Windows 7 Pro x64 workstation. I verified that the issue was not present on other profiles on the same machine.


I made a new user, temp. I logged in with the local administrator account and took ownership of bob's profile folder. I then copied everything in this folder except for ntuser.dat, ntuser.dat.log and ntuser.ini to the new user temp's profile folder. I then logged in as temp to make sure that the files were there. They were. My Excel file open issue and icon association was resolved on this user profile.


Next I deleted bob's profile folder after I made a copy of it to C:\temp for restore purposes. I then logged in as domain\bob, and Windows 7 put me into a temporary profile.


Making a local user with the name bob won't work for me here because the security context for that account won't point to the domain.


What do I do now to allow Windows 7 to forget I ever had a domain user called bob? I want to be able to log back in as this user and want the computer treat it like the first time they are logging in and make me a new profile. I will then move profile files over manually to synchronize things.


My user has a standard domain profile and not a roaming one.


I thought this was a relatively straightforward process, but I can't seem to figure out what I do differently when I am dealing with domain level accounts.



Answer





  1. Rename the user's profile folder to Bob.old




  2. Logged in as an admin, go to Control Panel → User Accounts → Manage User Accounts. Domain accounts show there after an initial login.




  3. Delete the account for Bob




  4. Open regedit and make sure that the user is no longer in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList. Delete it if present, even if it is followed by ".bak".




Then you can login as bob to recreate the local user profile, then copy your user data into it.


Source: Deleting a Local User Profile - Not as easy as one Might Assume


Find all the fonts used in a Photoshop file


I have this .psd (Photoshop file) and I'm trying to convert it to HTML & CSS.


Only thing I can't determine is what font they used in the .psd


How can I find out what fonts were used in the Photoshop file?



Answer



Depends on how you want to extract the information.


Per section or text area


Select the Text tool (T icon with serifs) and click on the text area to edit it. It will show what font is being used in the Character window.


All fonts used at a glance



  1. Save or export the image document as a PDF

  2. Open up the PDF version in Adobe Reader

  3. Select File → Properties → Fonts


This will list all the embeddable fonts used in the PSD file, provided you can embed them.


Missing fonts


In the Character tool, go to the font selection drop down. At the end of the list will be the fonts that are used in the image but are missing from your system. These will typically be greyed out.


Rastersized images


If you see any rasterized images you need the font face of, you'd best export just that section as a clear, standalone image and use a service like What the Font to determine the font.


osx snow leopard - Default editor for files without file name extension in Mac OS X


I want to open files without file name extension, including .dotsystemfiles (e.g. .htaccess or .vimrc) with a different editor than TextEdit. Doing the regular Change All... in the Get Info panel won't do the trick as it gives the following error:


alt text



Answer



You need to change the editor for the text/plain mime type or public.plain-text UTI. The regular Get Info dialog changes the association for the file name extension, which these files don't have.




Get RCDefaultApp and install it.


Open System Preferences » Default Apps » Apps. Select your desired default editor, and look for either of the above in the application's list of supported types.


alt text alt text alt text


Select the entry, and click Set as Default. You're done. Both opening from Finder and the command-line open will open your new default editor.




This also changes all .txt files and the like. I don't think this can be prevented, since OS X thinks both these and extension-less files are public.plain-text/text/plain.




To do this without RCDefaultApp, edit Edit ~/Library/Preferences/com.apple.LaunchServices.plist.


Add an entry under LSHandlers, containing the UTI (key LSHandlerContentType, e.g. public.plain-text) and application bundle identifier (LSHandlerRoleAll, e.g. com.macromates.textmate).


It looks like this in Property List Editor:


alt text alt text


Sunday 27 May 2018

logging - windows 7 randomly shuts down. where do I find related log? so that i can identify the error


during the normal use, windows 7 shuts down. sometimes it happened when I start google chrome and few times during system update.


after it shuts down, I turn it back on and I get to the screen, where windows asks me if I'd like a safe or normal start. the shutdown happens regardless if i'm on a battery or cord


is there a log that can tell me where the error is? it can help me to further identify the solution.


my setup: I run windows 7 on thinkpad x201 tablet. i have upgraded hard drive that worked fine for the last 6 months. the system is dual boot with ubuntu. I have installed some software recently, may be that can be the problem but sophos anti-virus cannot find anything. updates are all up to date.



Answer



Windows logs are available in the "Event Viewer":



Event Viewer is an advanced tool that displays detailed information about significant events on your computer. It can be helpful when troubleshooting problems and errors with Windows and other programs.


Open Event Viewer by clicking the Start button, clicking Control Panel, clicking System and Maintenance, clicking Administrative Tools, and then double-clicking Event Viewer.‌ If you are prompted for an administrator password or confirmation, type the password or provide confirmation.


Note


Here's another way to open Event Viewer: Click the Start button . In the Search box, type Event Viewer, and then, in the list of results, double-click Event Viewer.



Start under "Windows Logs", and look in "System" (for possible error events related to the hardware), and "Application" for software errors. Look around the time-frame in which the shutdowns happen.


Aside form the logs, as others have mentioned, it sounds like it may be overheating, which may not be logged. Ensure your intake and exhaust vents, heat-sink and fan are free of dust and debris, and that your system fan spins and spins (under it's own power) at power-on.


How do I see the most recent updates installed in Windows 8.1 in "installed updates"?


Windows 8.1 "installed updates" is one of two confusingly similar screens that let you view installed updates. It is the only non-useless one, because you can actually uninstall from this one. However it seems that there is some mandatory category groups that can not be removed, like "Microsoft Windows" and "Microsoft Visual Studio 2010", and so on. Hundreds of these categories. Clicking on the "installed on" column only sorts items within their existing groups, making the sort feature useless for finding what was installed on what day, as you now have to consult each of 200 "group" sections and you can only sort INSIDE the groups. How do I turn off this "grouping" feature within Installed Updates, or otherwise see the most recently installed updates, by date, across all the categories or groups?


There is an Organize button, which is tantalizing, but the Organize button contains no way to hide the category names.


enter image description here


How can I see the most recent day (today, yesterday, 3 days ago) that any update was installed regardless of categories that they are sorted permanently into?


Known Workaround: Use the otherwise worthless "View update history" window instead. (Review your windows update history). Then obtain a piece of paper and a pen, and write down the meaningless 10 digit KB number, then go find the meaningless 10 digit number in the other screen, and remove it.



Answer



Organize -> Layout -> Check 'Menu Bar' so you can see File, Edit, View at the top... (or tap Alt)


View -> Group By -> None


enter image description here


Google Chrome looks Dark/Grayed Out?


Has anyone noticed that all of a sudden (as of this morning) that Google Chrome looks different? My Chrome browser looks as if it's grayed out (colors are darker, almost a black-n-white look), and tab titles look lighter than usual, something is def not right, possibly caused by the latest update? Anyone else experiencing this?


I tried uninstalling/re-installing and it didn't work?


If nobody else is experiencing this I'll chalk it up to it being my computer and remove this question....


(All my other browsers work fine)


Chrome Version: Version 32.0.1700.76 m


OS: Windows 7


UPDATE: Downgrading to version 31x fixed all of these problems, I'm guessing it had to do with an incompatibility issue with the chrome update and my current GC driver, as NVIDIA has been acting up lately....


Also note that the rendering of default input elements such as text, dropdown menus, and number inputs are rendering incorrectly, and sometimes you can't even see the content.


Ex:


enter image description here Screenshots:


what it should look like:



What mine looks like: enter image description here



Answer



Have you've gone incognito? It's darker. Here is the main window sitting behind the incognito one to give you the color difference.


To get there click the click the three bars on the right to get this setup menu.


nat - Virtualbox -> Can't add 2nd adapter to network for VM


I have a Debian Wheezy VM running in virtual box with the 1st adapter being NAT. However I want to also add a Host-only network but I can't add 2nd adapter to network for VM, it is grayed out.


Any ideas?



Answer



Make sure the Virtual Machine is powered off. VirtualBox will not allow you to modify the network adapters while the VM is running.


windows 7 - Why doesn't File browser scroll to current folder in Windows7?

In Windows XP, when an app brought up a file browser for me to select a File or Folder, if there had been a current directory at launch, the browser would be centered on that directory. However, in Windows 7, when the file browser is launched, while it does expand the folder view to the current directory, it does not center the window on the current dir. So I always have to scroll down to where it has expanded the current dir.


Why is this? Is there any way to fix or workaround this behavior in Win 7?


Update: I guess this is a more narrow issue than I first thought. I seem to notice it when an app pops up a Browse for Folder window (e.g. kdiff3, Agent Ransack) This dialog seems to come from Windows since the usual/customized Windows Explorer RMB options are available. If I browse for a file using the standard Open dialog from one of these apps, then there are two panes and the explorer on the left one is scrolled to the current dir.


Just found that in Windows Grep, when I bring up the Browse for Folder dialog, it does scroll to the current dir. Maybe it's using a different windows API than the other apps, which works consistently on XP and Win 7.

distributed computing - Distribute list of processes to many windows machines

I have a list of independent tests which run a common executable with different command lines and in different working directories.


At the moment i simple run these one after the other in a batch file or script on my personal machine. However i have access to a large number of machines and so would like to be able to send some of these processes to the other machine and then collect up the output once they finish.


I could write something in python or whatever to do this, but I'm sure that someone has already done this much better than I could manage.


Any Ideas ??


cheers, Rob.

Reset Windows Spotlight


I am using Windows Spotlight on the lock screen of my Windows 10 laptop, and I have accidently liked some photos, and the keep coming up. is there a way to 'change your mind' about a photo, or just reset the whole thing?



Answer



I was also frustrated by this very same issue with the Windows Spotlight Lockscreen image on Windows 10.


Being unable to "change your mind" after having previously selected either "I want more" or "Not a fan" is a real pain. I've described below what worked for me. It may not be a full solution, especially if Microsoft change the way Spotlight works, but for now it seems to be a good enough work around.


WARNING: This involves changing values in the Windows Registry so be warned that it is generally considered a dangerous practice if you're not sure of what you're doing. Proceed at your own risk. Don't hold me liable if you break your machine.


The basic idea is that the current lockscreen image is stored at the following registry path: HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lock Screen\Creative



  1. Open the Windows Registry

  2. Follow the registry path:
    HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lock Screen\Creative

  3. Find the key "CreativeJson" and double click on it. The 'Edit String' dialog will open.

    • Go to the 'Value data' field. It contains a rather long json string with parameters affecting how the lockscreen image operates.

    • Start scrolling through the json string from the very left and you'll find a lot of key-value pairs in there including: "creativeId", "placementId", "impressionToken" among others. (These are not very useful for what we need, but i've pointed them out just as a check-point to see if you're on the right track)

    • The important ones for this process start approaching when you see "onHover", "onPositiveFeedback", "onNegativeFeedback" and the one that will solve our problems 'feedbackProvided'.

    • If you've previously given feedback it will have value of "true". If you have not it will be "false". So in our case where we want to change the decision we made, it should already read "true", so it will involve changing the value from "true" to "false".

    • Change this particular value and it should read now "feedbackProvided":false
      (NB: Don't change anything else. The entire rest of the string should remain the same)



  4. Once you've done this click "Ok" and you can close the registry.

  5. If you lock your screen now the current image should now allow you to make a choice again.


Note: As this registry path holds the settings for the current lock screen image, several parameters will obviously change when the Windows decides to change the lock screen for you. I think among these many parameters they have some sort of "Time-to-Live" for the current lockscreen.


Note2: The location of where the images are stored is also found at the registry path mentioned above, but at the Registry Key "HotspotImageFolderPath". On most Win 10 machines at the moment, the default should be:


C:\Users\[USERNAME]\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\ LocalState\Assets


Update: Here is a Powershell script to update the feedback flag:


$creativeJson = (Get-ItemProperty 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Lock Screen\Creative').CreativeJson | ConvertFrom-Json
$creativeJson.cdm.feedbackEvents.feedbackProvided = $false
New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Lock Screen\Creative' -Name CreativeJson -Value ($creativeJson | ConvertTo-Json -Depth 100 -Compress) -Force

Where does Skype save my contact&#39;s avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...