Is it possible to undelete a file in Gitpod? - gitpod

You won't believe this, but I genuinely am asking for a friend...
They've deleted a file (which they hadn't pushed to github) and have lost quite a bit of work. Not quite sure how it happened, but anyway. Is it possible that it's gone into some sort of recycling bin type folder? And if so, can it be recovered?
Can't find any docs online suggesting whether it's possible to recover files or not.

Ah, it seems that it is possible! There's a hidden Trash folder in the /workspace which you can view with ls -a. It contains a files directory with another directory inside with a UUID name. Deleted files can be found in there!

Related

is script autoloading possible in rebol or red-lang?

Is there a way to do so ? I searched Google but couldn't find any answer, so I guess the answer would be no. Is there anything close ? If not, would it be easy to extend red-lang to do so ?
From http://www.rebol.com/docs/setup.html
Startup Scripts
When REBOL starts it will automatically run the rebol.r and user.r files, if they exist.
The system looks for these files first in the current directory (or the directory of the script being run), then in the directory that contains the REBOL executable program.
Note that REBOL/Core runs fine without the rebol.r and user.r files. They simply provide an easy way to include additional code and data on startup, such as your network preferences.
If you compile your own Red interpreter you can add an autoloading file, maybe in console.red after system/console/init "Red Console" and before system/console/launch Best advice is to ask on the https://gitter.im/red/help site to ask for help. I guess this was already discussed.

Prevent renaming of file from another binary on Mac OS

I am working with multiple processes that write to the same directory.
I have a directory dir1/
My process creates a file a.txt under dir1/. However the other process creates a-temp1.txt and renames it to a.txt. I don't have control over the other process since that code comes from a library. Can I prevent a-temp.txt from being renamed?
There's nothing you can do that the other process can't undo. Your best hope (other than changing your program to work sanely) is that the other process doesn't try too hard to do the rename. That is, it tries the simple approach and gives up if that fails.
In particular, you can set the UF_IMMUTABLE flag on either file and that will prevent one from being renamed to replace the other. You can set the flag using chflags(). Using Cocoa, you could also use [someURL setResourceValue:#YES forKey:NSURLIsUserImmutableKey error:NULL].
Keep in mind that you won't be able to change the file in any other way, either, until that flag is removed. If the other process is determined to rename the file, it has permission to remove the flag just like your process does.
Also keep in mind that a system such as this is inherently race-prone.
You really ought to use separate names for the files, or separate directories, or ditch that library that doesn't give you the control you need.
Set the user immutable flag chflags(...,uchg). This will keep the other process from changing your file unless it takes action to clear the bit. Of course I don't know how the other process will react to you putting things in it's way, but that wasn't the question.
You can use chflags() on an HFS+ (Mac OS X) file system to set the UF_APPEND attribute. (Do a man 2 chflags.) That will permit appending to the file, but not deleting or renaming, even by the same user.
You can, but it unlikely will solve your problem. I strongly suspect this is an X-Y problem, and almost certainly the correct solution is to redesign some part of this system entirely, probably by changing your file names, using unique temporary files, moving to another directory, or reworking the usage of the library (libraries only do what callers tell them to do; and libraries are just code anyway). You shouldn't try to defeat another process; you're all working for the same user.
All that said, sure, you can prevent your own userid from renaming over file. Just deny yourself permission. You can modify the file:
chmod 400 a.txt
That says that you can read the file but may not write it. However, if you already have an open file handle, you may continue to use it (so you can keep writing to the file, even though another process running as the same user may not).
Similarly, you may change permissions on the directory:
chmod 500 .
This would prevent the rename because file names are kept in the directory.

How to fork a project in objective-c

Say you create a project. Then you want to do something else. You want to create another project that uses all the files of the previous project. You then modify it a little bit.
In vb.net it's simple. You just copy the vbproj file and that's it.
In objective-c copying the xcproj will result in a project file that won't compile.
Solution?
Note:
I do not want to do simple copy. If I do simple copy changes will not be propagated. I want if the fork change so will the original file.
As far as I know changing the project file name will make the project fail to compile. So just copying the project file doesn't work unless I do something wrong.
I think it's utterly ridiculous that there is no easy way to make the project work after changing the name of the xcodeproj file? I can't even open that xcodeproj file in textedit. In vb.net I can hack the project file straight. Why not in xcode?
There are two options which I would prefer :-
If there are classes which are constant and are not changing, you can make library which is called as Cocoa Touch Static Library
OR
Just copy folder to another location, rename application name and changes you want to do and run it!
Hope this info helps you..
I long for the day when you can simply choose "save as template" from Xcode(!)
In the meantime it might save you some headache to check out Project Duplicator from the AppStore. I haven't tried it out myself yet, but it sounds like it's designed to do exactly what you're asking for.
If you want to do it the manually way you could duplicate the folder with all corresponding files in the Finder and go about renaming everything from there.
You can create multiple targets for your project.
look at this link.

iOS 5: ~/Library/Caches - How to check all required files are present a very smart way?

I guess everybody read about the recent issues with the new iOS 5.
e.g. at http://iPhoneIncubator.com/blog/data-management/local-file-storage-in-ios-5
My Magazine-App holds about 1k html/css/image/video files for every issue and I want to know if anything is missing.
So my question is how to check all required files are present a very smart way?
I would expect iOS to clean caches atomically; i.e. iOS will either clean you app's cache or it will not. It shouldn't partially remove files from your cache. However, I don't believe this is documented behaviour, so it's a bad idea to assume this.
When you download your content, you have to know what to download for each issue, right? So you already have some kind of manifest file that references every file that is needed by each magazine. You should save this manifest locally so that you can refer to it when checking for the existence of files. You can still save this in the caches directory, if it's missing, you know your cache has been at least partially cleaned.
Also, I don't believe there's any guarantee that iOS won't clean caches while your application is running. As well as checking at the point where the user opens the magazine, you should check when your application becomes active after it has been put in the background, and your code should be robust in the face of missing files (i.e. pop up a warning message instead of crashing).
You could zip all the files relating to each issue in an archive (objective-c wrapper for zlib here, to make life easier for you). That way you can make sure that the system either deletes your issue or not, without having to worry about individual files.

Is there a way to change user desktop directory path value in Cocoa?

I know there is NSDesktopDirectory that will get me the path to current user desktop directory, but where is this path value written and is there a way to change it from my cocoa application I cannot find out.
Can anyone point me in the right direction?
Additional explanation: in Snow Leopard when I rename Desktop folder to anything whatsoever, the content of this folder still shows on desktop, so I guess OS keeps track about that folder name and locations changes and keep it as desktop folder. Does anyone know how it does that?
One way you could do this is by storing whole set of files from the user's desktop (including .DS_Store, which has positional/spatial information) into a folder in your ~/Library/Application Support/ folder, then moving other files on the ~/Desktop? This should effectively "replace" the user's desktop.
[Posted as an answer as suggested above]
I spent about 40 minutes researching this out of curiosity. Google is unhelpful in this particular scenario so I poked around my ~/Library folder. The path isn't stored anywhere there. I then dug around with command-line-fu to check flags and any other metadata I could find. Nothing helpful.
I think this is a built-in thing that uses file system references as opposed to hard-coded file paths (which is why its "Desktop" designation survives renaming). If you delete it, it creates a new one and stores the ref to that one. You'll not be able to swap it around.
I think Phil's comment is probably your best bet: move the contents of the folder rather than the folder itself. Here's my take on it:
~/Desktop/.myDesktop1 ... ~/Desktop/.myDesktop2 ... ~/Desktop/.myDesktop3
Perhaps even: ~/Desktop/.myappdesktops/1 ~/Desktop/.myappdesktops/2 ~/Desktop/.myappdesktops/3
If you move stuff into a dot-folder, it'll remain hidden but there. Active stuff stays in ~/Desktop as normal but each of your conceptual "Desktops" gets stored in a dot-file so it stays hidden.
Caveat: Time Machine. :-) Regardless of your approach, swapping out "sets" of files will potentially wreak havoc with any backup solution.
So, to answer my own question: there is no way to change the desktop path in Snow Leopard or Lion (although you van read it). The only way to switch dasktops is moving the contents itself which can be done with a set of AppleScripts to some degree :(.
The other way is this app here :)):
http://itunes.apple.com/us/app/projectdesktops/id499870251?ls=1&mt=12