How can you get the path to a user's home directory in Clojurescript running on Node? - clojurescript

You can't use ~ in paths for NodeJS functions because that's a bash-specific thing. So how do you get the path to a user's home directory in Clojurescript (on Node)?

(def os (node/require "os"))
(.homedir os)
And to combine it with an additional path:
(def path (node/require "path"))
(.join path (.homedir os) "/directory/file.txt")

Related

Index.html without XAMPP

Is it possible to automatically load index.html on a system folder without using XAMPP, IIS or similar?
It is for a school project and I can't use them, so I have to open the file putting the path (C:/...) into the address bar.
I know I could use .htaccess, but I don't know what to write and if it gets read without any web server solutions!
This can get a little tricky... but is possible without any "administrator" privileges, nor without installing anything.
Download Python 3.8.2 - Windows x86-64 embeddable zip file
Create a folder on "python" on the c:\
Extract the "Zip" file into this folder
Change the folder name from "python-3.8.2-embed-amd64" to "python_src"
Create a folder named "python_html"
The folder structure should look like:
c:\python\
c:\python\python_src\
c:\python\python_html\
Create a file named "webserver.py" in the "c:\python\python_html" folder
Place the following code into that file:
#webserver.py
import http.server
import socketserver
PORT = 80
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print("serving at port", PORT)
httpd.serve_forever()
Save and close the file
Create index.html file in the "python_html" folder and place the following code in that file:
<html>
<head>
<title>Web Title</title>
</head>
<body>
<h1>Python Web Server File</h1>
<p>Congratulations! The HTTP Server is working!</p>
</body>
</html>
Open the "Command Prompt" and type the following commands
cd\
cd python\python_html\
c:\python\python_src\python ./webserver.py
Open a web browser and navigate to "http://localhost/"
Once you have confirmed this works, you can build an entire website within that "python_html" folder. As long as you don't close the command prompt it will continue acting as a "Web Server".
I know I could use .htaccess
.htaccess is an Apache (Web Server) config file, so unless you have Apache installed (ie. the "A" in XAMPP) then you can't use that. (If .htaccess was available then index.html would likely load automatically anyway.)
On Apache, being able to load index.html by default when requesting a directory requires mod_dir (an Apache module). In this case, mod_dir issues an internal subrequest for the DirectoryIndex - this all requires additional processes.
I can't install extensions... I have to open the file on my school computer
If you can't install anything then you can't do this I'm afraid. You appear to be limited to direct file requests.
When using a webserver (such as Apache or IIS) then you have a differentiation between a URL and a filesystem path. The webserver maps the URL to a filesystem path. Without a webserver you don't have that abstraction.
There are lighter webservers, other than Apache and IIS, but you need to install something extra.
Just give your file(s) meaningful names (ie. not index.html) and use those instead? eg. fox-project.html

How to load-and-launch a Google Chrome App from the command line?

At this link, it says:
These command line options to Chrome may help you iterate:
--load-and-launch-app=/path/to/app/ installs the unpacked application from the given path, and launches it.
What is the entire command line statement?
For example, is it:
$ chrome --load-and-launch-app=/path/to/app/
or maybe:
$ cca --load-and-launch-app=/path/to/app/
What, specifically, is the entire command?
The basic command you have correct
/Path/to/Chrome --load-and-launch-app=/Path/to/App
Assuming you are using Mac, OSX(from your comments) and you installed Google Chrome the normal way, (into your Applications directory), your /Path/to/Chrome will be
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
But to make sure you can your Google Chrome Application directly into your terminal (assuming standard MacOSX terminal or iTerm)
For the /Path/To/App part of the command, use the directory which contains the manifest.json file.
For instance, if your path to the manifest.json file is
/Users/[Your Username]/Downloads/basic/manifest.json
which you can get from going to this link
Your command to load and launch the "Basic" google chrome app is
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --load-and-launch-app=/Users/[Your Username]/Downloads/basic
One additional detail that may be helpful: the path to your app must be an absolute path, beginning at the root directory (/).
You have to do --load-and-launch-app=/Users/YourUsername/Documents/my_chrome_app
Alternately, if you don't want to type the whole path, you could use $PWD, which evaluates to your current directory (must execute the command from the same directory as your manifest.json):
--load-and-launch-app=$PWD
You cannot do --load-and-launch-app=.
You cannot do --load-and-launch-app=~/Documents/my_chrome_app

What is the method or class or whatever that show me the configurations files of JRuby?

I'm new to JRuby, I installed it on windows 8, and I'm following it's wiki. When the wiki said to change a configuration option, it dose not say exactally where I can find the file where the option resides, it gives only its name but not the full path.
So is their a method that I can run on jirb to find the path to any configuration path.
thanks.
The .jrubyrc file is searched in your current directory (user.dir Java property), your home directory (user.home), and since you're on Windows, also in HOMEDRIVE\HOMEPATH, in this order (and the first one wins).

Where is a localSharedObject file stored on a Mac

I'm working with localSharedObjects and want to inspect the files that are created on the user's machine. According the the documentation, localSharedObject files are stored on a Mac in the following location: /Users/username/Library/Preferences/Macromedia/Flash Player/#SharedObjects/web_domain/path_to_application/application_name/object_name.sol
When I try to find the file, I cannot even get to: /Users/username/Library
as the Library file does not exist in that location. Also, I've been searching for files with a .sol extension, but without success.
My question: Where can I find loaclSharedObject files on a Mac running 10.7.5?
There is a Library folder that Mac OS X 10.7 hides. Go to Finder, hold down the Option key and select the Go menu. The Library folder will then appear and you can select it. If you wish to have permanent access to it, you can drag it into the Finder sidebar, or there's a Terminal command to get it to show permanently:
chflags nohidden ~/Library

Padrino app not aware of its own root path

I have a Padrino app which doesn't seem to be aware of its own root path. The app works fine, but when I try to require a file I wrote and put into the models folder, it says it cannot find it. The file is required from within another file in the models folder: DvdActor.rb. I can use any of these paths and it won't find it:
/app/models/file.rb
file.rb
models/file.rb
app/models/fie.rb
...
It will only find it if I use:
"#{Padrino.root}/app/models/file.rb"
Furthermore, the Thnking Sphinx gem will also have problems writing its configuration file or indexing (if I hardcode the path to the config file).
And when I have Padrino generate a Model, it will create a new model folder in the root folder insted of in the app folder itself.
I could recreate my app from scratch and copy the files over but I already have Heroku and git setup, etc. and don't want to recreate all this (sometimes simply copying the files over doesn't work properly).
Is there a way to reset this?