I only have one machine and want to save some variable values like a = 3 in linux. I can resume the last progress if power-off suddently happens.
I can only figure out two ways, one is to save in files and the other one is save to DB.
Are there any special ways to do like this without saving in files or db? any programming language is ok.
I guess there is some confusion. Do you want to save the state of your program? If so then use text editor which saves your progress even if you don't save it using ctrl+s, like sublime or gedit. Otherwise please elaborate more on what you want.
Related
I have 10-20 configuration files in which I have to change the same setting quite often.
I was thinking about multi cursor approach (like in Sublime Text), but in multiple documents at the same time.
I can use find/replace in files, etc, but I would love to see what is being edited and selecting same 'setting key' just by pressing CMD + D would be just amazing.
Anyone knows an editor which can do multi-cursor editing in multiple buffers/documents? Or maybe another way of efficiently editing multiple files which are almost identical?
This is not possible in Sublime, nor any other editor of which I'm aware. In Sublime, for example, you can have multiple open files in different tabs and/or windows, but only one has the focus at any one time. It just doesn't make much sense to have input going to multiple windows at once.
Your problem is just crying out for a scripted solution. In Sublime you can create macros and Python-based plugins, as well as using regex-based search and replace. If you're using a shell like bash with access to the standard array of command-line utilities, you can use any number of ways (sed, awk, Python, Perl, expect, and many more) to identify the desired files, select the setting that needs to be changed, and change it, either automatically or with confirmation at each step.
I'd like to write an AppleScript for replacing three system files with ones I've modified. I'd like to do this with an AppleScript instead of manually replacing them because I'll have to replace three files every time there's an OS X update. Specifically, I'll be replacing stock graphics drivers with ones I've modified to support a graphics card which is connected via Thunderbolt. Is it possible to write an AppleScript for replacing one file with another? I ask because I know that when you replace a file, a dialog pops up with three options, and I don't know how to address that.
You can do this with Finder:
set freshFile to choose file
tell application "Finder"
move freshFile to desktop replacing yes
end tell
All you need to do is work out the source and destination paths to completely automate the script.
Many scripters do not like working with Finder, for a variety of reasons. If you want something that is incredibly fast, you would use the do shell script inside of your AppleScript:
do shell script " mv -f ~/Desktop/ArlandaTilUppsala.pdf ~/Documents/Employ.pdf"
I need to perform certain actions to each file and doing it manually would take a lot of time as there are manny files.
Automating this somehow would be very helpful.
Can this be done with Sublime Text 3?
Sublime macros cannot open or close groups of files, you would have to specify the exact filename of each file you want to manipulate. To do what you are asking would probably require a Python plugin instead. You can use its pattern-matching capabilities to open whatever you want (or just feed it a list of files), then it can execute API commands, built-in editor commands, or simply wait for you to make the changes manually before saving, closing, and moving on to the next file. Essentially, any Sublime menu option can be automated, and new commands built up using the API and pure Python.
I am looking for a method by which I can print one document, and have a field that is incremented on each copy printed. I currently run linux, so bash in concert with several programs might be the way to go, but I'm just not sure where to start.
I have a document that is used for our business that currently is hand stamped for serialization... We would like to simply print them but cant find a method by which to increment a specific field. I would like to use either a PDF or an ODF/ODT for the document.
Thanks for any help you can give!
How is the document produced at the first place?
If you master that process, you could certainly add serialization at that level. For instance if using LibreOffice you could do that in LibreOffice. If using a text formatter (like LaTeX, Lout, ....) just emit the formatting instructions (e.g. the .tex or .lout source file) with some unique counting (perhaps simpler to do in some scripting language like Python or Ocaml).
Then run the relevant tool to get a .pdf file.
I want to use a algorithm to reduce memory used to save the particular text file.I don't really know how text is stored but i have an idea in mind.
Would it be better to extend a open source text editor (if yes than which one) or write a text editor myself.
It would be nice if someone could also give me a link or tutorial to some basics on how text editors work and the way data is stored.
Edited to add
To clarify, what I wanted to do is instead of saving duplicates of a word make a hash table and store the address where it needs to be placed.
That way I wouldn't be storing the duplicates.
This would have become specific to a particular text editor.
Update
thanks everyone I got what all of you'll are trying to say. Anyways all i wanted to do is instead of saving duplicates of a word make a hash table and store the address where it needs to be placed.
This was i wouldn't be storing the duplicates.
Yes and this would have become specific to a particular text editor. never realized that.
I want to use a algorithm to reduce memory used to save the particular text file
If you did this you would no longer have a text editor, but instead you would have created some sort of binary file editor.
The whole point of the text file format is that it is universal, meaning any text file can be open in any other text editor.
Emacs handles compression transparently. Just create a text file with .gz extension. Emacs will automatically compress contents of the file during save operation, and decompress when you open the file next time.
Text is basically stored as-is. i.e., every character takes up a byte or two (wide chars), and there is no conversion done on it when it's saved. It might add an end-of-file character or something though. Don't try coming up with your own algorithm to compress these files. That's why zip-files and other archives were created. They're really good at compressing text. If you wanted to add these feature to your text-editor, you'd have to add some sort of post-save hook to zip it, and then put a hook on the open command to unzip it. Unless you wanted to do it by hand every time. Don't try writing the text editor yourself from scratch, unless (maybe) you're writing notepad. Text editors with syntax highlighting aren't very easy to make, even with the proper libraries. I'd say write a plugin for something like Visual Studio or what have you. Or find an open-source text editor.