how to set "company" information in file properties through cygwin - cygwin

After I right-click on a file in Windows, a pop-up menu appears with "Properties" on its bottom.
Going to: Mouse-Right-Click on a File -> Properties -> Details I get a tab with file description containing:
File Description,
Type,
File Version,
Product Version,
Copyright,
Size,
Date modified,
Language.
Is it possible to setup any of the above parameters (Example: File Version, Product Version, Copyright) from cygwin? I want to have the parameters available after each compile/build session.
If yes please let me know, Thanks.

There is a small guidance on Cygwin user guide at
https://cygwin.com/cygwin-ug-net/windres.html
For example the Cygwin1.dll info are stored in:
https://cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/winver.rc;h=980d51204c84b67d09c9cb1e247cc899a72ea288;hb=HEAD
27 BEGIN
28 BLOCK "StringFileInfo"
29 BEGIN
30 BLOCK "040904B0"
31 BEGIN
32 VALUE "CompanyName", "Red Hat"
33 VALUE "FileDescription", "Cygwin POSIX Emulation DLL"
34 VALUE "FileVersion", STRINGIFY(CYGWIN_VERSION)
35 VALUE "InternalName", CYGWIN_DLL_NAME
36 VALUE "LegalCopyright", "Copyright \251 Cygwin Authors 1996-" STRINGIFY(CYGWIN_BUILD_YEAR)
37 VALUE "OriginalFilename", CYGWIN_DLL_NAME
38 VALUE "ProductName", "Cygwin"
39 VALUE "ProductVersion", STRINGIFY(CYGWIN_VERSION)
40 VALUE "APIVersion", CYGWIN_API_VERSION
41 VALUE "SharedMemoryVersion", STRINGIFY(CYGWIN_VERSION_SHARED_DATA)
42 VALUE "RegistryKey", CYGWIN_INFO_CYGWIN_REGISTRY_NAME
43 VALUE "BuildDate", CYGWIN_BUILD_DATE_TIME
44 END
45 END
46 BLOCK "VarFileInfo"
47 BEGIN
48 VALUE "Translation", 0x409, 1200
49 END
50 END

Related

replacing a value in python

I'm writing a bingo game in python. So far I can generate a bingo card and print it.
My problem is after I've randomly generated a number to call out, I don't know how to 'cross out' that number on the card to note that it's been called out.
This is the ouput, it's a randomly generated card:
B 11 13 14 2 1
I 23 28 26 27 22
N 42 45 40 33 44
G 57 48 59 56 55
O 66 62 75 63 67
I was thinking to use random.pop to generate a number to call out (in bingo the numbers go from 1 to 75)
random_draw_list = random.sample(range(1, 76), 75)
number_drawn = random_draw_list.pop()
How can I write a funtion that will 'cross out' a number on the card after its been called.
So for example if number_drawn results in 11, it should replace 11 on the card with an x or a zero.

How to use ExecWB command for printing pages as pdf

I am trying the below code used to print a webpage as pdf
IE.ExecWB 6, 2, "U:\Translations", Null
I am not sure how to specify the path name in the above syntax .
The parameters as as follows :
object.ExecWB nCmdID, nCmdExecOpt, [pvaIn], [pvaOut]
browser.ExecWB method does not have any parameter to pass the file path.
object.ExecWB nCmdID, nCmdExecOpt, [pvaIn], [pvaOut]
The ExecWB method requires an OLE Command ID to be passed in to identify the command to execute. This value nCmdID is of type Long. The nCmdExecOpt parameter represents the value for the command execution option. Together, these values instruct the control as to what supported command to execute and what degree of user prompting should occur.
The last two parameters pvaIn and paOut are optional and is usually set to either NULL or an empty string.
Here is a complete list for the 1st parameter
OLECMDID_OPEN 1 Open
OLECMDID_NEW 2 Create a new document
OLECMDID_SAVE 3 Preservation
OLECMDID_SAVEAS 4 Save as
OLECMDID_SAVECOPYAS 5
OLECMDID_PRINT 6 Print
OLECMDID_PRINTPREVIEW 7 Print preview
OLECMDID_PAGESETUP 8 Page setup
OLECMDID_SPELL 9 The spelling check
OLECMDID_PROPERTIES 10 Attribute
OLECMDID_CUT 11 Shear
OLECMDID_COPY 12 Replication
OLECMDID_PASTE 13 Paste
OLECMDID_PASTESPECIAL 14 Paste special
OLECMDID_UNDO 15 Revoke
OLECMDID_REDO 16 Repeat
OLECMDID_SELECTALL 17 Select all
OLECMDID_CLEARSELECTION 18 Clear selection
OLECMDID_ZOOM 19
OLECMDID_GETZOOMRANGE 20
OLECMDID_UPDATECOMMANDS 21 The update command
OLECMDID_REFRESH 22 Refresh
OLECMDID_STOP 23 Stop it
OLECMDID_HIDETOOLBARS 24 Hide toolbar
OLECMDID_SETPROGRESSMAX 25 Progress bar maximum
OLECMDID_SETPROGRESSPOS 26 Progress bar position
OLECMDID_SETPROGRESSTEXT 27 Progress bar text
OLECMDID_SETTITLE 28 Set the title
OLECMDID_SETDOWNLOADSTATE 29 Set download status
OLECMDID_STOPDOWNLOAD 30 Stop downloading
OLECMDID_ONTOOLBARACTIVATED 31
OLECMDID_FIND 32 Search
OLECMDID_DELETE 33 Delete
OLECMDID_HTTPEQUIV 34
OLECMDID_HTTPEQUIV_DONE 35
OLECMDID_ENABLE_INTERACTION 36 Allow the interaction
OLECMDID_ONUNLOAD 37 When uninstall
OLECMDID_PROPERTYBAG2 38
OLECMDID_PREREFRESH 39
OLECMDID_SHOWSCRIPTERROR 40
OLECMDID_SHOWMESSAGE 41 Display a message
OLECMDID_SHOWFIND 42 Display search
OLECMDID_SHOWPAGESETUP 43 Display page setup
OLECMDID_SHOWPRINT 44 Display and printing
OLECMDID_CLOSE 45 Close
OLECMDID_ALLOWUILESSSAVEAS 46
OLECMDID_DONTDOWNLOADCSS 47
OLECMDID_UPDATEPAGESTATUS 48
OLECMDID_PRINT2 49 Print 2
OLECMDID_PRINTPREVIEW2 50 Print preview
OLECMDID_SETPRINTTEMPLATE 51 Set the print template
OLECMDID_GETPRINTTEMPLATE 52 Get a print template
OLECMDID_PAGEACTIONBLOCKED 55
OLECMDID_PAGEACTIONUIQUERY 56
OLECMDID_FOCUSVIEWCONTROLS 57
OLECMDID_FOCUSVIEWCONTROLSQUERY 58
OLECMDID_SHOWPAGEACTIONMENU 59
OLECMDID_ADDTRAVELENTRY 60
OLECMDID_UPDATETRAVELENTRY 61
OLECMDID_UPDATEBACKFORWARDSTATE 62
OLECMDID_OPTICAL_ZOOM 63
OLECMDID_OPTICAL_GETZOOMRANGE 64
OLECMDID_WINDOWSTATECHANGED 65 windows status change
Here is a complete list for the 2nd parameter
OLECMDEXECOPT_DODEFAULT 0 Default parameters
OLECMDEXECOPT_PROMPTUSER 1 Prompt the user, namely the pop-up dialog box
LECMDEXECOPT_DONTPROMPTUSER 2 User is not prompted
OLECMDEXECOPT_SHOWHELP 3 displays help
IE.ExecWB method can be used to print the web page as PDF but it will prompt the user to select the folder and ask the file name to save it.
This method does not have any parameter to pass the file path. So if you are looking for using the path written in your code than you need to change your logic and modify your code based on that.
References:
(1) ExecWB method
(2) Microsoft Internet Controls

Where to place the return statement when defining a function to read in a file using with open(...) as ...?

I have a text file consisting of data that is separated by tab-delimited columns. There are many ways to read data in from the file into python, but I am specifically trying to use a method similar to one outlined below. When using a context manager like with open(...) as ..., I've seen that the general concept is to have all of the subsequent code indented within the with statement. Yet when defining a function, the return statement is usually placed at the same indentation as the first line of code within the function (excluding cases with awkward if-else loops). In this case, both approaches work. Is one method considered correct or generally preferred over the other?
def read_in(fpath, contents=[], row_limit=np.inf):
"""
fpath is filelocation + filename + '.txt'
contents is the initial data that the file data will be appeneded to
row_limit is the maximum number of rows to be read (in case one would like to not read in every row).
"""
nrows = 0
with open(fpath, 'r') as f:
for row in f:
if nrows < row_limit:
contents.append(row.split())
nrows += 1
else:
break
# return contents
return contents
Below is a snippet of the text-file I am using for this example.
1996 02 08 05 17 49 263 70 184 247 126 0 -6.0 1.6e+14 2.7e+28 249
1996 02 12 05 47 26 91 53 160 100 211 236 2.0 1.3e+15 1.6e+29 92
1996 02 17 02 06 31 279 73 317 257 378 532 9.9 3.3e+14 1.6e+29 274
1996 02 17 05 18 59 86 36 171 64 279 819 27.9 NaN NaN 88
1996 02 19 05 15 48 98 30 266 129 403 946 36.7 NaN NaN 94
1996 03 02 04 11 53 88 36 108 95 120 177 1.0 1.5e+14 8.7e+27 86
1996 03 03 04 12 30 99 26 186 141 232 215 2.3 1.6e+14 2.8e+28 99
And below is a sample call.
fpath = "/Users/.../sample_data.txt"
data_in = read_in(fpath)
for i in range(len(data_in)):
print(data_in[i])
(I realize that it's better to use chunks of pre-defined sizes to read in data, but the number of characters per row of data varies. So I'm instead trying to give user control over the number of rows read in; one could read in a subset of the rows at a time and append them into contents, continually passing them into read_in - possibly in a loop - if the file size is large enough. That said, I'd love to know if I'm wrong about this approach as well, though this isn't my main question.)
If your function needs to do some other things after writing to the file, you usually do it outside the with block. So essentially you need to return outside the with block too.
However if the purpose of your function is just to read in a file, you can return within the with block, or outside it. I believe none of the methods are preferred in this case.
I don't really understand your second question.
You can put return also withing with context.
By exiting context, the cleanup are done. This is the power of with, not to need to check all possible exit paths. Note: also with exception inside with the exit context is called.
But if file is empty (as an example), you should still return something. So in such case your code is clear, and follow the principle: one exit path. But if you should handle end of file without finding something important, I would putting normal return within with context, and handle the special case after it.

I have a spreadsheet with rows of text in a single column

IE:
23 HL*3*2*23*0
24 PAT*19
25 NM1*QC*1*CUSTOMER*COLE
26 N3*228 PINEAPPLE CIRCLE
27 N4*CORA*PA*15108
28 DMG*D8*19940921*M
29 CLM*945405*5332.54***12>B>1*Y*A*Y*Y*P
30 HI*BK>2533
31 LX*1
32 SV1*HC>J2941*5332.54*UN*84***1
33 DTP*472*RD8*20110511-20110511
34 REF*6R*1099999731
35 NTE*ADD*GENERIC 12MG CARTRIDGE
36 LIN**N4*00013264681
37 CTP****7*UN
I want to populate column C with the text from row 29 as a min row with "945405" all the way to row 37 (the one with the text "CTP" in it). I cannot do this in VBA due to permissions. Is there a formula that will grab this value (it is always CLM * xxxxxx *...), assign it to column C using the "CLM" as the min row and CTP as the MAX row all the way through the SS? IE:
23 HL*3*2*23*0
24 PAT*19
25 NM1*QC*1*CUSTOMER*COLE
26 N3*228 PINEAPPLE CIRCLE
27 N4*CORA*PA*15108
28 DMG*D8*19940921*M
29 CLM*945405*5332.54***12>B>1*Y*A*Y*Y*P 945405
30 HI*BK>2533 945405
31 LX*1 945405
32 SV1*HC>J2941*5332.54*UN*84***1 945405
33 DTP*472*RD8*20110511-20110511 945405
34 REF*6R*1099999731 945405
35 NTE*ADD*GENERIC 12MG CARTRIDGE 945405
36 LIN**N4*00013264681 945405
37 CTP****7*UN 945405
38 NM1*DK*1*PATIENT*DEBORAH****XX*1
39 N3*123 MAIN ST*APT B
****Update*****
I was given permissions in VBA. How would I loop this?
Here is a clearer picture of what I am trying to accomplish
enter image description here
you can use the =MID(Source_Cell, Start_Position, Desired_Length) function to pull the substring. In your case it would be:
=MID(B29, 5, 6)
You can then put this formula in all of the cells you'd like it to be in.

Vim slow down in python mode after I type "=" (equal) or " "(while space).

It seems to happen after I installed YCM. I also have Python-mode plugin installed because I like the lint and "run inside vim" feature, but I turned off "rope". My YCM settings are like below.
31 " Use gcc syntastic checker
30 let g:ycm_show_diagnostics_ui = 0
29
28 " Skip checking of ycm config file at vim startup
27 let g:ycm_confirm_extra_conf=0
26
25 " Includes tags in completion
24 let g:ycm_collect_identifiers_from_tags_files=1
23
22 " Include text in comments and strings
21 let g:ycm_collect_identifiers_from_comments_and_strings = 0
20
19 " Start completion from second char
18 let g:ycm_min_num_of_chars_for_completion=2
17
16 " Disable chache, rebuild every time
15 let g:ycm_cache_omnifunc=1
14
13 " Enable syntax based completion
12 let g:ycm_seed_identifiers_with_syntax=1
11
10 " Enable completion while in comments
9 let g:ycm_complete_in_comments = 1
8
7 " Enable completion while in strings
6 let g:ycm_complete_in_strings = 1
I tried to profile vim, but I don't get a clue from the result. Below is my profiling report.
0 FUNCTIONS SORTED ON SELF TIME
1 count total (s) self (s) function
2 60 0.883352 0.782989 <SNR>93_GetCompletions()
3 2967 0.905869 0.579009 pymode#folding#expr()
4 1997 0.275032 <SNR>110_BlockStart()
5 302 0.168611 <SNR>93_Pyeval()
6 120 0.968933 0.066387 youcompleteme#Complete()
7 1997 0.051828 <SNR>110_BlockEnd()
8 76 0.030649 0.028957 <SNR>97_GetNearbyTag()
9 154 0.026513 <SNR>69_Highlight_Matching_Pair()
10 61 0.025747 <SNR>93_InsideCommentOrString()
11 61 0.057955 0.016587 <SNR>93_IdentifierFinishedOperations()
12 6 0.013762 0.013707 <SNR>93_OnFileReadyToParse()
13 60 0.012566 <SNR>93_OnCompleteDone()
14 4 0.011961 <SNR>143_SearchParensPair()
15 74 0.040687 0.010170 Powerline#Functions#fugitive#GetBranch()
16 76 0.114571 0.009806 <SNR>93_OnCursorMovedInsertMode()
17 2 0.006829 0.006792 SyntasticRefreshCursor()
18 61 0.040498 0.005477 <SNR>93_InvokeCompletion()
19 74 0.005211 308()
20 91 0.004580 Pl#Statusline()
21 74 0.005954 0.004241 <SNR>59_buffer_spec()
Vim doesn't stand asynchronous job control and is basically mono-thread, so he can only do one thing after the other.
You can't type text while YCM is working.
You should try NeoVim who stand it, it won't solve your problem but will minimize it.

Resources