📜 ⬆️ ⬇️

By lamers for lamers

I am a lamer.


I honestly am not a superprofessional in any programming language, I don’t understand how the modern windows, linux kernel works, didn’t advance further in knowledge of assembler PDP11 and slightly x86 (and I even knew what I forgot) not very long ago, I never bothered to study the theory, as a result I don’t really understand them. Moreover, I can hardly explain how the processor works, I programmed FPGAs and PIC controllers only at the institute and it was a long time ago.
But for some reason, I very often manage to solve the problems that cool professionals give up.
Along with this, I would like to raise the question of the need for WIDE knowledge of any IT's. And not only IT'shnika.

Partly this post is a protest against the prevalence of the opinion that the PHP programmer does not need JavaScript (for example, comments here ), the analyst does not need to be able to use Visual Basic in Excel, and the marketer just needs to read Kotler, and after that he only needs to be creative. Those. against narrow specialization. I saw how good experts did amazing things with the help of pivot tables in Excel, while all the others required IT-specialists to urgently implement BI and make the necessary reports.
I am afraid that raising this topic in a pure and original form will lead everyone into very philosophical conversations that will lead nowhere.
Therefore, here is an example of how I solve my problems using my head and not having super knowledge.

Problem.


Once, an employee who often had to convert tables from Excel to html said that it was very long and difficult to do this without DreamWeaver. And in general there are no free editors that allow you to work fast enough.
I doubted this and decided to see what can be done in Notepad ++.
The problem is that Excel generates a bunch of unnecessary attributes in tags and the code must be cleaned and dreary for a long time. Moreover, Excel breaks up the lines into parts, and the search and replace Notep ++ conducts the replacement line by line.
In general, try saving your xls file in html and then opening the html in Notepad ++.
Those. there is a problem. And at first glance - not solved. As I said before, I’m a lamer and I can’t write my own plugin or quickly fix the Notepad ++ code.
But there is Google, who said that there is a wonderful plugin Pork2Sausage, which allows you to process the selected text with an arbitrary console application.
I immediately downloaded this plugin, wrote an application on c # and ... And I realized that it would not help me.
For some reason, Russian letters terribly korezhili.
I did not want to give up, because I downloaded the source Pork2Sausage and opened it with fear. It turned out not so scary. The code was simple and I only had to fix the tangled piece, which I really did not understand. And it all worked. The truth is only for texts in UTF-8, but that was enough for me.
Now I can:
  1. clean tags with one button
  2. make new tools to change text. Very useful in many cases. I can, for example, make a utility in notepad ++ that will retrieve all texts from habrahabr for some tag. Well, or any other nonsense


What had to do for this.


')
Pork2Sausage

Code:
std::string inputA = pAsciiText;
std::wstring inputW(inputA.begin(), inputA.end());
inputW.assign(inputA.begin(), inputA.end());
selectedText += inputW;



replaced by:
size_t templen = 0;
while (pAsciiText[templen]!=L'\0' && templen <= asciiTextLen) templen++;
templen = (templen-1)/sizeof(wchar_t);
wchar_t *inputW = new wchar_t[templen];
wcsncpy(inputW,pAsciiText,templen);
selectedText += inputW;



Well, added to the function launchProgram:
char* filename;
if (progInputStr != TEXT("")) {
filename = new char[progInputStr.length()];
wcstombs(filename,progInputStr.c_str(),progInputStr.length()+1);
remove(filename);
}
if (progOutputStr != TEXT("")) {
filename = new char[progOutputStr.length()];
wcstombs(filename,progOutputStr.c_str(),progOutputStr.length()+1);
std::remove(filename);
}



so that the files do not breed.
Surely I did stupid and not optimal, but it works.

Actually cleaning script

Created a console application in C # with code:
string strAll="";
strAll = File.ReadAllText("C:\\tmp\\in_"+args[2]);
Regex reg = new Regex(args[0]);
strAll = strAll.Replace("\r\n", " \r\n");
strAll = reg.Replace(strAll, args[1]);
strAll = strAll.Replace(" \r\n", "\r\n");
File.WriteAllText("C:\\tmp\\out_" + args[2], strAll);



The code is also not masterful.

Configuring

Posted in ini file Pork2Sausage
[excel_convertor]
progPath=C:\regexp_notepad\bin\Release\regexp_notepad.exe
progCmd=regexp_bstd "<([az]*) [^>]*>" "<$1>" "$(TIMESTAMP)"
workDir=C:\regexp_notepad\bin\Release\
progInput=C:\tmp\in_$(TIMESTAMP)
progOutput=C:\tmp\out_$(TIMESTAMP)



Everything. Everything is working.
And you don’t need to be a super programmer to solve most problems.

Those who read to the end probably have their own LifeHacks of this kind. Let's share.

And I repeat the question.


Do I need a programmer to have wide knowledge? For example, do not be afraid of tasks on JavaScript, if you are a PHP programmer? To be able, if you need to use Excel and VisualBasic, not to be afraid of MS SQL, pivot tables and other cubes, if you are an analyst, etc.?
Or is it all from the unclean and if the employer did not provide all the materials (reports, data in the right form, etc.), then you can do nothing and wait, and if they do, the authorities do not understand the specifics?

Source: https://habr.com/ru/post/136291/


All Articles