Mac OS X doesn't allow to name files starting with a dot. How do I name the .htaccess file? - apache

As mentioned in the title, Mac OS X doesn't allow me to name files starting with a dot ( . ).
But, I need an .htaccess file. Or, better, how do I use an htaccess file in Mac OS X without giving it a name starting with a dot?
I am running Mac OS 10.5.8 and XAMPP 1.7.3.

You can't do this with the Finder. Open Terminal.app (Applications -> Utilities -> Terminal), and type:
> cd /path/to/directory/containing/htaccess
> mv current_file_name .htaccess
Example (do not take directory names or initial filename literally, of course):

Finder-only Solution. No Terminal Needed
You need to be able to see invisible files first.
In finder press ⌘+⇧+. –command + shift + dot– to toggle hidden files visibility.
Then just go to the folder where the file is and you'll see it there. You can now rename the file to start with a . if you want.
To create a new file you'll need the terminal. Do touch .htaccess once the terminal is at the right folder.

You can create files that begin with a "." if you can view hidden files.
Enter the following commands to show hidden files:
defaults write com.apple.finder AppleShowAllFiles -bool YES
killall Finder
When you're done enter these commands to hide them again:
defaults write com.apple.finder AppleShowAllFiles -bool NO
killall Finder

Use the terminal instead of Finder to rename it. Try mv.

You can add an alias in your startup script file to make the command shorter. Usually this is .bashrc, .bash_login or .profile file in your home directory.
alias ondot='defaults write com.apple.finder AppleShowAllFiles -bool YES; killall Finder'
alias ofdot='defaults write com.apple.finder AppleShowAllFiles -bool NO; killall Finder'
Now you can just type ondot to show hidden files. and ofdot for hiding hidden files

This works so far as it goes. But TextEdit automatically added .txt to the end of the filename so I ended up with .htaccess.txt
And files with names starting with . don't show up in folders in Finder. You only see it if you go back into Terminal and use ls -a. And if it can't be seen then it can't be uploaded to an online webserver.
Using Fetch as my FTP client, I found it has a function which enables me to create a simple text file directly on the server. This worked to create .htaccess where I really needed it.

Since .htaccess files will not be viewable once you change the name with Terminal (without some annoying searching) it is simpler to just drag an empty text file into the directory of choice using FTP and then rename away. Both filename and extensions can be change/removed once inside FTP.

Use Terminal.
Open Terminal.
Change Directory to source folder where you want to create the file
cd Desktop
Create the file using touch
touch .htaccess
Open the file in any text editor
atom .htaccess

Related

How do I change path directory in Jupyter lab?

How do I change initial path directory in Jupyter lab, when i want to get a file via "~/"?
Have tried to generate config, and then change some parameters but only got confused.
You can change file directory like that.
import shutil
File= r'C:\Users\ivan\Desktop\Somewhereidonotknow\example.csv'
Whereyou_want= r'C:\Users\ivan\Desktop\example.csv'
shutil.move(File, Whereyou_want)
You should be using the %cd magic command to change the working directory. And then to set up using tab completion, you'd start by typing ./ before hitting tab at the place where you want to choose your CSV file.
In the demonstration set-up for the screenshot below I made a test directory in the root (home) location and made two CSV files in there.
Using %cd test first I am then able to use tab completion to get the option to select one of the two CSV files:
I probably should have included running pwd to 'print the working directoryafter I ran the%cd test` command to demonstrate things more fully.
Before I executed the command %cd test, the tab-completion was showing the root (home directory) when I tried for tab completion.
The tilde symbol (~) always means the HOME directory on the system. It won't change. So you were always specifying to start in HOME in your example in your post, no matter what the current working directory is in the notebook's active namespace. You want to use relative paths for when the working directory has been adjusted.
There are more complex settings you can take advantage of using inside the notebook in conjunction with the %cd magic.
For example, this post and answer shows how you can use the %boookmark magic to set assign a directory to a bookmark setting and then you can more easily switch around to various directories using %cd.

How can I open the ~/.ssh/config file as a text file instead of opening the TextEdit app on Mac?

I have been trying to add my SSH keys to the ssh-agent by following the directions on this GitHub doc: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key
This is what I put into the terminal:
root#Nicoles-MacBook-Air nicoletr # eval "$(ssh-agent -s)"
Agent pid 21417
root#Nicoles-MacBook-Air nicoletr # open ~/.ssh/config
The file /var/root/.ssh/config does not exist.
root#Nicoles-MacBook-Air nicoletr # touch ~/.ssh/config
root#Nicoles-MacBook-Air nicoletr # open ~/.ssh/config
But when I hit enter to open the ~/.ssh/config file, the TextEdit app opens instead of a text file that I can modify. I am supposed to modify the config text file but I don't even see any file at all. I am still very new to coding so I would be extremely grateful for any guidance.
Open command
On MacOS, the open command will open file in parameter with the default configured application for this filetype (such as Preview, TextEdit or Safari for some others)
Even though you can override which application is used to open the file, there are more standard solutions to achieve this.
For the sake of completeness, you can override default app by using -a option, for example, if you want to open an html file with TextEdit instead of Safari by default:
open -a TextEdit page.html
More information about open:
Article on scriptingosx.com
Open man page
Alternative
If you would like to edit any file directly from your terminal, you can use packages such as nano, to easily get started with it you can check this article. As an added bonus, it also go through setting brew to easily install package, also from your terminal
There are alternatives to nano (like vi, vim) and to brew (such as macports). They all have their pros and cons depending on the use, though in you case, I don't think your need would justify the steeper learning curve yet
Happy discovering coding !

Executing Love2D scripts

The only way I found out to execute my script with the Love2d framework is to zip all of it and then rename the zip to love. This kinds of take a lot of time for a small modification. Is there a faster way to do it? I tried to command line and I get this error
'love' is not recognized as an internal or external command,
operable program or batch file.
LÖVE also executes folders if they have the main.lua in them - you can just drag and drop the folder onto the application, or call it from the command line with the folder as the argument if you prefer.
LÖVE runs the contents of a folder if it can find a main.lua in it (Like Bill said).
[Note that it doesn't check subfolders].
There are three ways to run a love2D program, you can:
a) Drag the folder over the love.exe binary/link (This works in Win and *Nix, I don't know about OS X).
b) Navigate to the directory that is one level above the folder and type love [folder containing main.lua]
or
c) Zip it up and rename the .zip to a .love. Then double click the .love file
Option 'b' will fail if the binary is not in the %PATH%(Windows) or $PATH(*Nix) variable
(It will spout an error message like 'love' is not recognized as an internal or external command, operable program or batch file. on windows and bash: love: command not found on linux).
There are two ways to solve this:
(Both require ADMIN/root privileges, )
1) Add the love binary to the PATH variable. Here's how to do this in windows and in linux (In linux you want to do something like this: PATH=$PATH:$HOME/where/ever/you/put/love/)
2) You can add a link to the love2D binary in C:\WINDOWS\system32 or /usr/bin/.
In windows you create a shortcut to the love.exe (wherever you installed it to) and then drag it into C:\WINDOWS\system32. In linux you can run this:
sudo link /path/to/love/binary /usr/bin/love && sudo chmod ugo+rwx /usr/bin/love
I hope this helps!
Sources:
Google (the links above), Love2D and my knowledge :D
I found this to be very helpful when i started. Hope this helps
A Guide to Getting Started With Love2d
If you're using Mac OS, you should run using:
open -a love xxx.love
To recreate a file as .love, you can run in command line:
zip xxx.love file1.lua file2
If you just want to replace a file in .love:
zip -r xxx.love file1.lua
I think this will make your work easier.
simple way:
create folder /path/to/Game
put your files (main.lua, conf.lua, ...) in folder /path/to/Game
you can run script like this:
love /path/to/Game/
or if you use Linux, you can go in folder (cd /path/to/Game) and type just:
love .
(dot means that you want to run it form in folder
I found a simple solution for save time.
You have to create a file .bat with this simple command:
del Project.love
7z.exe a Project.zip ..\Project\*
ren Project.zip Project.love
For do this you need to download 7zip and insert this file (file.bat) into the folder of your project. Like this:
Good work!
If you're yousing Notepad++ to write your code, just open your main.lua file, then go to Run and add there this text including quotes:
"Path" "$(CURRENT_DIRECTORY)"
Where Path is a Full path to love.exe.
The save it to a key combination and now you can test your code by using this combination in any script at Notepad++.
If you use Sublime Text, you can make a build which runs your application.
https://love2d.org/wiki/Sublime_Text
While in Sublime Text press CMD + B or Ctrl + B

Trying to create .htaccess file using ftp doesn't work

I want to create a .htaccess file in a specific directory. I'm using Notepad++ and their plug-in for FTP (NppFTP). I'm able to create any other files and see them in the folder but when I try to create a .htaccess I don't see that file in the directory. I get no errors, it is like nothing happened.
I tried to create this file using an FTP program and it showed the file and right away it disappeared. My guess it is because this is a special file used by the system and prefixed by a (.)
What is a way to edit that file?
This is probably because your ".htaccess" file is a hidden file and your system is set up to no display hidden files.
Have a look in your Notepad++ settings if there's an option to make hidden files visible/unhide.
In addition to that check the windows folder options for that option!
switch on showing hidden files in your ftp client

Using relative paths for Gnome launcher

We're developing an app that needs to run on a removable device (e.g. USB stick). On Linux, we're using Gnome launchers to place a shortcut to the app on the root of the device. However, we need to use relative paths for the executable and icon since we don't know in advance where the device will mount. In the .desktop file I have something like:
Exec=../myapp/myexecutable
Icon=../myapp/myicon.png
Neither the executable or icon is found. I read the spec on icon lookup in .desktop files (http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html#icon_lookup) but it didn't enlighten me.
Is there a way to get launchers to use a relative path? If not, is there another approach to achieve what I want (i.e. a shortcut with an icon and an executable, specified using relative paths)?
Relative paths are not supported*.
One solution is to have an installer. This script updates the desktop file according to the location the script is run from. Make the script executable, and the user can click it to install. The script requires the desktop file to be writable.
This was done with Linux in mind. The file is named autorun.sh; but that is just a convention, it usually won't run automatically. If you deploy this on something other than Linux, then name the file something else(autorun.linux), or adapt it to do different things according to the platform.
#! /bin/sh
#### Fixup $APPNAME.desktop.
APPNAME=xvscatter
ICONNAME=xv_logo.png
cd $(dirname "$0")
APPDIR="$PWD/$APPNAME"
EXEC="$APPDIR/$APPNAME"
ICON="$APPDIR/$ICONNAME"
sed -i -e "s#^Icon=.*#Icon=$ICON#" \
-e "s#^Exec.*#Exec=$EXEC#" "$APPNAME.desktop"
*The convention for the freedesktop is to have the icons in $HOME/.icons, /usr/share/icons or /usr/share/pixmaps. Under those directories are subdirectories for different icon sizes and types. When using one of those directories to store the icon, only the icon name(without the directory) is listed in the desktop file; otherwise record the full path to the file.
The executable, if in the path, can be listed with no pathname(unsafe). It's best to list the full path. Imagine the wrong program getting launched because the full path isn't specified.
Another possibility is to copy the desktop file to the user's desktop or to /usr/share/applications, and edit it there. Do this when the program is on read-only media.
Because none of the above results in a true install, if possible, use the platform's native installer and packaging tools(rpm,dep,portage, etc.). Those tools provide a framework for complete installation including the proper file permissions(think selinux), and desktop menus. They also provide for easy uninstall.
If the program has to run from the removable media, consider using the system install for just installing symlinks, maybe to /opt/vendor/progname.
What I did and worked perfectly was:
Exec=sh -e -c "exec \\"\\$(dirname \\"\\$0\\")/.sh/server.sh\\";$SHELL" %k
Explaining the command:
The snippet below will get the dir name of who is executing that, therefore the launcher dir name
$(dirname \\"\\$0\\")
So appending the desired path, will make this execute relative path.
Ref: https://askubuntu.com/questions/1144341/execute-shell-on-a-relative-path-on-ubuntu-launcher