casperjs unable to run CoffeeScript scripts - coffeescript

I installed casperjs for the first time and ran the sample scripts. The first sample script (javascript) ran without incident. Then i tried running a coffescript sample, which I prefer, and received the following error:
Unable to load script test.coffee; check file syntax
I searched for an answer and the solution in the only related issue didn't work for me. I was able to compile the CoffeeScript (test.coffee) into JavaScript (test.js) and then ran the compiled JavaScript, again, without indecent.
I tried to track down the error by searching for the error message in the casperjs files. I found the error message at the end the ~/.node/lib/node_modules/casperjs/bin/bootstrap.js file where it passes control to phantomjs. I created simple a CoffeeScript: test_phantomjs.coffee:
console.log "hello phantomjs"
phantom.exit()
and ran the script (phantomjs test_phantomjs.coffee) with the following result:
Can't open 'test_phantomjs.coffee'
At this point I'm at loss. The problem is more of an inconvenience than anything since compiling into JavaScript solves the issue. Is their something I'm missing?

In Phantomjs2.0 was removed support of coffee-script
https://github.com/ariya/phantomjs/issues/12410

(disclaimer: i'm/was part of contribution team)
the support of coffee script in CasperJS depends on the version of phantomJs you are using because this is phantomjs that provide coffee script support out of box.
You can also use and install slimerjs (https://slimerjs.org) which - from my point of view - is more performant than phantomjs and supports coffeescript scripts.
Mickaël

Works for me. Can you post your PhantomJS version and platform?
Mine on Mac OS X:
$ phantomjs -v
1.9.8
Just works:
$ phantomjs test_phantomjs.coffee
hello phantomjs

As others say, PhantomJS v2.x no longer supports CoffeeScript.
Therefore, now you have 2 options to run PhantomJS with CoffeeScript:
Run plain *.coffee files with PhantomJS v1.9.8
Compile *.coffee files to *.js, and run *.js with PhantomJS v2.x
I recommend the latter up-to-date way, and this is how package.json looks like:
{
"scripts": {
"pretest": "npm install && coffee --compile **/*.coffee",
"test": "casperjs test --fail-fast script/*.js",
"watch": "coffee --watch --compile **/*.coffee"
}
}
See more detail at ymkjp/phantomjs2x_coffee_sample.
Btw, here's the way to install PhantomJS v1.9.8 on Ubuntu.
$ sudo apt-get update
$ sudo apt-get install build-essential g++ flex bison gperf ruby perl \
libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev \
libpng-dev libjpeg-dev python libx11-dev libxext-dev git
$ cd ~
$ wget -O- https://github.com/ariya/phantomjs/archive/1.9.8.tar.gz | tar zxvf -
$ cd ~/phantomjs-1.9.8
$ bash build.sh # It takes 30 min or so (Up to your host machine)
$ sudo ln -s ~/phantomjs-1.9.8/bin/phantomjs /usr/local/bin
$ phantomjs --version
1.9.8
Cheers.

Related

How to download packages from pypi using Wget?

Where from should I download virtualenv to use locally from source using wget?
I'm having troubles downloading virtualenv from the command line.
Info: if you search for virtualenv you will find the site for the stable version and its installation guide which is just equals to the latest version installation guide.
To install locally it describe this :
To install version X.X globally from source:
$ curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-X.X.tar.gz
$ tar xvfz virtualenv-X.X.tar.gz
$ cd virtualenv-X.X
$ [sudo] python setup.py install
To use locally from source:
$ curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-X.X.tar.gz
$ tar xvfz virtualenv-X.X.tar.gz
$ cd virtualenv-X.X
$ python virtualenv.py myVE
I'm using wget instead curl but should not be problem at all with this. Am I wrong?
The only place where I can download it (and not from the command line) is from here.
I'm typing the url correctly.
Different virtualenv versions at the url return the same not found:
HTTP request sent, awaiting response... 404 Not Found
2017-07-21 17:53:09 ERROR 404: Not Found.
Please note that I have already downloaded the tar.gz so I don't need it right now but I'm not sure if this is a broken link issue or I'm forgotten something else at the download command. I will not associate an issue to virtualenv just because a broken link but I need to know why this is not working.
EDIT: I can't download it using wget from ..python..packages/source/v/virtualenv etc.
TARGET="https://pypi.python.org/simple/virtualenv/"
PATTERN="virtualenv-15.1.0.tar.gz"
wget --recursive --no-directories --accept=$PATTERN $TARGET
Yes, curl and wget are equivalent for what you're trying.
No, you can download from anywhere. From PyPI, e.g.
There is no functional difference between pip install virtualenv and what you're trying to do but the former is simpler and less error-prone so why bother with manual labour?

How to start IDLE that comes with Python 3.6

I am using Linux Mint 18. I installed Python 3.5 and 3.6 using apt-get in the terminal. I can open IDLE of Python 2.7 and 3.5 using commands idle and idle3 respectively. How can I access IDLE that comes with Python 3.6?
Try the command idle3.6. python3 and idle3 are still associated with your system Python, which is 3.5.
Simply typing in idle3.6 should work just like carusot42 mentioned. If it doesn't work, perhaps you might want to see if everything else is installed correctly. Here are the steps I followed which worked perfectly fine for me. I am also running Linux Mint 18. The steps that I followed were:
Installed the prerequisites of Python. Do that by typing in the following commands -
sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
Download Python using the following command and extract it (use your desired location) -
cd /usr/src
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
sudo tar xzf Python-3.6.0.tgz
The next step is to compile Python source. To do that type in the commands below-
cd Python-3.6.1
./configure
sudo make altinstall
make altinstall is used to prevent replacing the default Python binary
file /usr/bin/python
You should be good to go. You check your Python version by typing python3.6 -V in the terminal.
Once you do that, type in idle3.6 and then Python 3.6.1 shell should open for you.
The Software Manager in Linux Mint lists the Python Packages and IDLE Packages
separately. After you install Python, go look up the associated IDLE package in the Software Manager and install it. Reboot and it should work fine. It worked for me.

Error: Invalid or corrupt jarfile sbt/sbt-launch-0.13.5.jar

I have been trying to install spark using the tutorial and everytime I run the command sbt/sbt assembly, I get the error "Error: Invalid or corrupt jarfile sbt/sbt-launch-0.13.5.jar"
I have tried everything: seperately adding the sbt file to the sbt folder in the spark folder, installing sbt individually, checking the download and reinstalling it over again, but in vain. Any advice about what I am doing wrong? Thanks.
Ok, After playing around for a while I finally got it and hopefully this will work for you aswell. That tutorial builds spark, where they do provide prebuilt binaries. I'm using Spark 1.2.0 just as a note (1.4.1 wouldn't work for me)
This is on Ubuntu 15.04 but should work on 14.04 the same
1) Remove the following lines from your bashrc
export SCALA_HOME=/usr/local/src/scala/scala-2.10.4
export PATH=$SCALA_HOME/bin:$PATH
2) Remove and reinstall scala
sudo rm -rf /usr/local/src/scala
# The following line is only needed if you installed scala another way, if so remove the #
# sudo apt-get remove scala-library scala
wget http://www.scala-lang.org/files/archive/scala-2.11.7.deb
sudo dpkg -i scala-2.11.7.deb
sudo apt-get update
sudo apt-get install scala
3) Download PreBuilt Spark and extract
wget http://d3kbcqa49mib13.cloudfront.net/spark-1.2.0-bin-hadoop2.4.tgz
tar -xzvf spark-1.2.0-bin-hadoop2.4.tgz
4) Run spark-shell
cd spark-1.2.0-bin-hadoop2.4/
./bin/spark-shell
Sources (basically where I've read from, this solution has been trial and error)
https://chongyaorobin.wordpress.com/2015/07/01/step-by-step-of-installing-apache-spark-on-apache-hadoop/
https://gist.github.com/visenger/5496675
If you have downloaded spark package from http://d3kbcqa49mib13.cloudfront.net/spark-1.1.0.tgz then cross check file - "sbt/sbt-launch-0.13.5.jar". If it just contains small (5-6lines) html content then you need to download jar file manually. This html file just indicate that required jar file was not found. You may use follow following steps for centos:
Download jar manually:
wget http://dl.bintray.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.1/sbt-launch.jar ./sbt/sbt-launch-0.13.5.jar
Prevent automatic downloading of jar file:
sed -i '47,68s/^/#/' sbt/sbt-launch-lib.bash
Install spark again:
sbt/sbt assembly
It worked for me without altering scala installation. Hope it helps.
The sbt script does not download properly sbt-launch-0.13.5.jar because there must be something wrong with the URLs it is using. As a result the file that it downloads contains just an HTML header (wither 400 or 302 codes). Until a better solution becomes available, as a workaround I would download manually sbt-launch-0.13.5.jar beforehand.
In the SPARK_HOME/sbt/sbt-launch-lib.bash script replace line 53 to line 57 with following
if hash curl 2>/dev/null; then
(curl --fail --location --silent ${URL1} > ${JAR_DL} ||\
(rm -f "${JAR_DL}" && curl --fail --location --silent ${URL2} > ${JAR_DL})) && \
mv "${JAR_DL}" "${JAR}"
elif hash wget 2>/dev/null; then
(wget --quiet ${URL1} -O ${JAR_DL} ||\
(rm -f "${JAR_DL}" && wget --quiet ${URL2} -O ${JAR_DL})) &&\
mv "${JAR_DL}" "${JAR}"
else
Then try again, run the sbt assembly command
sbt/sbt assembly
Simplest method is install sbt manually as follows
download sbt deb file
wget http://dl.bintray.com/sbt/debian/sbt-0.13.5.deb
Then run
sudo dpkg -i sbt-0.13.5.deb
sudo apt-get update
sudo apt-get install sbt
then build using
sbt assembly instead of sbt/sbt assembly from spark home folder
#Frozenfire, I'am not sure if it's possible but the Spark documentation Overview says :
For the Scala API, Spark 1.4.1 uses Scala 2.10. You will need to use a
compatible Scala version (2.10.x).
And I wonder if it would be the reason why you have this problem:
I'm using Spark 1.2.0 just as a note (1.4.1 wouldn't work for me)
Because you do :
sudo dpkg -i scala-2.11.7.deb
which downloads and installs scala-2.11.7.
I don't know but this might be a clue !
PS1: this is more a comment to Frozenfire's answer, but I can't comment because of a lack of reputation and I wanted to share this.
PS2: Building for Scala 2.11

How can I run madge on Windows

The instructions for madge are only good for a linux system (it requires sudo to get the command line part set up). Is there a way to run it on windows?
It turns out to be very simple. To install madge:
npm install madge
Then to set it up for the command line:
npm -g install madge
You can then run it with a command of:
madge
For typescript generate .js files do:
madge -f amd -c .
and you'll get the circular report. You need the "-f amd".

Setting up Mesos on CentOS

I tried to install the latest release tarball of Mesos on CentOS 6.4 with no luck. It ended up in all sorts of failures in trying to find jvm & jni bindings. Is there any instructions on how to install Mesos on RHEL or CentOS ?
I couldn't find any instructions around so I thought I would troubleshoot all through my way and thought of documenting it here so it can save your time.
First things first, load your CentOS box with essential build tools to get started
$ sudo yum groupinstall "Development tools"
Get Java and python dependencies installed
$ sudo yum install java-1.6.0-openjdk.x86_64 java-1.6.0-openjdk-devel.x86_64 python python-devel libcurl libcurl-devel
Get the latest Mesos tarball
$ wget http://mirror.nus.edu.sg/apache/mesos/0.13.0/mesos-0.13.0.tar.gz
$ tar -xzvf mesos-0.13.0.tar.gz
$ cd mesos-0.13.0
Before you can build Mesos, you need to set correct JAVA binding paths
$ export JAVA_HOME=/usr
$ export JAVA_LDFLAGS="-L/usr/lib/jvm/java-1.6.0/jre/lib/amd64/server -R/usr/lib/jvm/java-1.6.0/jre/lib/amd64/server -ljvm"
$ export JAVA_CPPFLAGS="-I/usr/lib/jvm/java-1.6.0/include -I/usr/lib/jvm/java-1.6.0/include/linux"
$ export LD_LIBRARY_PATH=/usr/lib/jvm/java-1.6.0/jre/lib/amd64/server:$LD_LIBRARY_PATH
Configure and build it
$ ./configure
$ make
After you have built Mesos, it is advisable that you build and run the tests, this will make sure that what you have installed meets all the requirements
$ make check
If the checks are successful, You are just one step away from installing it in your system installation paths
$ make install
To learn how to use Mesos , go here http://mesos.apache.org/gettingstarted/
For those who prefer installing from RPM's, here is a link to a number of different releases for different Linux flavors: http://mesosphere.io/downloads/ For example, for Centos64:
wget http://downloads.mesosphere.io/master/centos/6/mesos_0.14.2_x86_64.rpm
sudo rpm -Uvh mesos_0.14.2_x86_64.rpm
I also had to set my LD_LIBRARY_PATH, though to a slightly different value. Check yours.
Python bindings can also be downloaded from the first link above:
wget http://downloads.mesosphere.io/master/centos/6/mesos_0.14.2_x86_64.egg
sudo easy_install mesos_0.14.2_x86_64.egg