how to install python for using d3 charts at windows - d3.js

I have to use d3 graph at my web page. I never worked with d3. That's why, I'm facing some problem using it. Basically, I've to work at dropbox folder. So, my clients can see the worked file locally at their browser. Consider, I put a d3 chart at file.html file and my folder structure is like this
D:\Projects\Dropbox (Company)\MyName\FolderName\file.html
But, I saw that to run and see/show d3 examples I need run web server or run a python server. So, I've downloaded Python 3.4.1 and installed by double click. It's installed at this directory: C:\Python34
After that, I tried to follow d3's documentation for installing python server. So, I opened my cmd and type:
python -m http.server 8888 &
But, it gives me this error:
So, my question is:
How can I install python web server?
After installing that web server, is it possible see the d3 chart via this link: file:///D:/Projects/Dropbox (Company)/MyName/FolderName/file.html or I've put my files inside htdocs and run via http://localhost/folderName/file.html (I don't want to put files inside htdocs. It'll be tough for my clients see the output of the files directly from their pc)?
If it can't be seen without putting inside htdocs folder, I may find solution for running d3.js locally without installing any additional software/server(though I've found this type of solution for some d3.js chart but not for all). Thanks in advance and please don't mind if it's a lame question. Basically, it's my first day working with d3.js and I'm only ameture level skilled with javascript and jQuery.

OK, browsers are designed with security in mind, by default they don't let scripts go and grab a file from anywhere for very good reasons. They allow you to grab a file from the server or through requests. So to share your work with your client you will either need to use a hosting service - I would recommend bl.ocks, design your visualisation so it doesn't require any external data or provide instructions on how to disable browser security. You can read more about this here, here and here.
On python, in many cases python is already installed on people machines, so running a server from python shouldn't be an issue. All you have to do (on a windows machine) is launch your command prompt navigate to your directory and start your python server. Then open a browser and navigate to the localhost. Please note that python needs to be set as an environmental variable (i.e. your system path), the python documentation might help you here.

Related

Jekyll on Windows without installation

Is there a way to run Jekyll on windows without installing Ruby or anything else?
It doesn't need to be perfect - I am basically looking for a simple way to preview a Jekyll and GitHub pages based blog.
It's not possible without copying anything onto your machine, but it's possible without installing anything.
You can use Portable Jekyll - it's a portable download including Ruby and anything else needed to run Jekyll.
Just download it as a .zip file, unzip on your machine and run setpath.cmd, which opens a command prompt with all environment variables set that you need to execute Jekyll.
I'm using this to build multiple Jekyll sites locally on my Windows machine.
By slightly tweaking setpath.cmd, it's also possible to create a batch file which you can just double-click to build your site.
I submitted a pull request for that (but unfortunately it has not yet been merged yet), read the description for more information.

How to open local .htm file with anchor(#) link in Edge browser from command line?

I try to open local .htm file with anchor link in Edge browser from command linе.
LaunchWinApp.exe "file:///C:/index.htm#anchor.htm"
But Edge browser opens only index page file:///C:/index.htm without additional page.
Why is this happening?
For the time being, you cannot open local files in this manner. You should instead host a web-server out of your target folder, and access the resources via localhost.
There are currently discussions taking place within the Microsoft Edge team around this topic, and what we may be able to do that would greatly improve the experience for developers like yourself.
If/when we make a change, impacting this issue, I'll return to update this answer. However, for the time being, your best option is to host a local server. Instructions for doing so using npm and Node.js are provided below.
If you're unsure how to stand up a local server, following these steps:
Install the latest version of Node.js
Open a command prompt, and run npm install -g http-server
Navigate to your website folder, and Shift+Right Click to select Open command window here
Run the command http-server
There is a GIF of the process online.

Problems using D3.js locally [duplicate]

This question already has answers here:
D3 Bar Graph example not working locally
(3 answers)
Closed 7 years ago.
I'm trying to play around with this Simple d3.js Graph, yet whenever I load the file locally, the graph won't render.
I'm not sure if this has something to do with loading the D3.js library? I have the CSV file in the directory.
I know this is kind of a vague question, but any ideas as to why this won't work locally?
Change the line trying to load data.csv to request the version he is hosting at http://bl.ocks.org/d3noob/raw/b3ff6ae1c120eea654b5/a1f7e8f2a609bfab778b8c48eaa0f7c90f3f6f80/data.csv
You cannot load files locally.
If you're using Chrome, it may prevent you from opening the file properly because of cross domain security restrictions. Try Firefox to see if that's the case (it will probably let you load the file correctly).
If that is the problem, you will want to install a local web server like WAMP (if you're running Windows) or follow instructions on the wiki page here: https://github.com/mbostock/d3/wiki
Good luck
javascript is not allowed to load files from local disk. which is what the csv file becomes when saved to local, and the d3.js tries to refer to it. if you have a local webserver, you can make it work.

Editing remote files over SSH, using TextMate?

I LOVE using TextMate on my MacBook. It's great.
Unfortunately, I want to edit some files directly on my dev server, since it's difficult to recreate the environment locally. I'm using Git, so one alternative is to just edit locally, git commit, git push, and then git merge, but that's kind of complicated every time I want to make a simple change.
I'd rather just ... use another solution. One thing I tried is mounting a hard drive via MacFusion, and then loading that in an editor. But that's so freaking laggy/slow!
Has anyone cooked up a better solution?
OK - here is the one that works on Mountain Lion.
Go to http://osxfuse.github.com/
Install FUSE for OS X
Install SSHFS for OS X
Then the following commands on your terminal:
mkdir /Volumes/SSHFS
/usr/local/bin/sshfs username#host:/path/to/dir /Volumes/SSHFS
Done.
I would also recommend using the ReMate plugin as pointed out by another user to prevent TextMate from beach-balling every time you refocus it. Link:
ReMate http://ciaranwal.sh/remate
I use Fetch and TextMate for just such tasks. Fetch can be set to use TextMate as an external editor and can even automatically open files in TextMate by double clicking.
Saving the window in TextMate automatically pushes the file back to the server. Of course you would have to commit the changes on the server at a later time.
I'm sure most Mac FTP clients could do the same.
The best thing would be using TextMate's rmate script, follow the link and you'll find the instructions bellow, I recommend it since it will make your life easier and handle all the Nitty-Gritty.
I use the free version of TextWrangler for just this and it works great. I can load and save files over sftp.
The correct answer is to use sshfs and make sure "Perform atomic saves" is checked in the Textmate preferences window. The easiest way to setup sshfs is to use Macfusion. http://macfusionapp.org/.
Try one of these methods.
see: http://wiki.macromates.com/Main/FAQ#projects
also have a look at:
http://www.gnu.org/software/tramp/
You don't need to push every time you make simple changes; git is a distributed version control system, you commit to your local repository for the small changes. You should only push to the remote repository once you finished working on a feature/bug (or for really huge feature, a complete subfeature). Well, that's assuming you can recreate the environment; which apparently you can't.
A decent text editor can have integration with your favorite control version system; if you cannot configure your editor to commit and push from inside your editor, get a decent editor.
An even better editor can be set to save, commit, push, compile, and run your program all in one click or keypress.
If you are not able — for whatever reason — to replicate your environment locally and still want to use TextMate, the FTP client+TextMate combo is the best solution I can think of. MacFusion and all the other similar solutions are neat on the paper but awfully slow.
If you feel adventurous and confident enough to drop the TextMate requirement, SSH+Vim in the terminal works amazingly well.
Are you positive you can't replicate at all your remote environment?
I know this question already has several answers, and it's been a while, but I wanted to also point out DokanSSHFS - This will use SSH to make a local drive of the directory location on the server that you choose. Then you can use your editor of choice to edit the files as if they were on a local disk.
Most of the proposed solutions are centered around sshfs in one form or another. I have tried these solutions, but I found that reliability of filesystem is not always as good as desired.
There is tool called rmate, which allows editing of remote files in text mate.
Use command from ssh session to edit file on the server:
rmate file_name
The readme on github provides easy to follow instructions on how to set it up.
MacFusion is pretty sweet for free - basically ssh-mounting of directories.
http://macfusionapp.org/
Transmit 4 has a similar feature, tho it costs $$.
Try http://ciaranwal.sh/remate/ if it seems slow, as that will disable textmate from refreshing the file list so often.
Use Fuse for OS X http://osxfuse.github.com and the companion package, SSHFS (same URL) and install them. I installed the MacFUSE compatibility libraries from there too, just for good measure.
Then, install http://macfusionapp.org and follow the instructions located here ( https://github.com/osxfuse/osxfuse/wiki/SSHFS ) to configure macfusion to use the newer libraries.
I had trouble getting authenticated with password, so I set up ssh key authentication and used macfusion without password. Works like a charm.
If you do use an IDE, you could just set up an SSH tunnel to your dev server and edit your files from the comfort of your favourite IDE. Saving the files locally would automatically then push the files on the dev server as well
P.S: I am NOT endorsing the use of IDE
You need rmate it works fine to edit files on your server via ssh using TextMate on you local machine.
Github link here
rmate might be another choice. On server side, you type rmate /path/to/file. The file will be transferred to local machine, where you use some editor like Sublime Text or VS Code (TexMate may also work). To use it, one needs to install both server and client.
For server side, there are several ones in various languages. Choose one you like. Here is the Github repo.
On local machine, as far as I know, VS Code and Sublime Text have their extensions to receive files. For VS Code, refer to here. For Sublime Text, refer to here.
On the other hand, Microsoft just announced an official remote editing extension for VS Code (not released yet).
For those remote machines not having ruby or if bash not compiled with /dev/tcp, but has python, this works: https://github.com/scriptmaster/rmate-python
If you have pip:
pip install rmate
or simply:
wget https://raw.githubusercontent.com/scriptmaster/rmate-python/master/bin/rmate
chmod +x ./rmate
mv ./rmate /usr/local/bin/rmate
then rmate /path/to/file
especially if you are in a containerd-os with restrictions (with only python and docker) such as kubernetes-vm or gce-vm
you don't need vs-code-server, atom-editor,

Project update via TextMate (like Espresso)

I am thoroughly in love with TextMate. I program everything in it, including ASP.NET for my daily job. However, I have a license for Espresso, and I was looking at it recently and discovered that there is a "Publish" section that I knew about before, but I didn't know that it could compare my FTP directory with my local directory and publish only the changed files.
Over the past week I've been finding myself using Espresso just for that functionality. However, I was hoping there was a way to get this functionality inside TextMate. I know that you could use an AppleScript script with Cyberduck (my FTP client) to upload a file when it changes, but I have never got that working and it also doesn't include the ability to merge files like Espresso does.
Am I plumb out of luck? Am I stuck using two different programs for the forseeable future?
I haven't tried it, but you should be able to set up a simple rsync command in a bundle in TextMate that will use environment variables from your project to synchronise.
See Using rsync to enable the project drawer in TextMate while working on a remote server for an example.

Resources