Sharing code in the cloud

Hey sparkers – I’m working on an LED cube with a spark core at its heart, and I want myself and other people using our cube to be able to share code for others to run on their cubes.

Ideally, I’d like us to be able to ‘publish’ my code to show up in the web IDE like example code, that others can flash with a button click, or fork into their own accounts. Is there a good way to publish code like this?

Barring the publish functionality, my first take on this was to pull all the code from my app (which I developed on the web IDE), save all the files to a local directory, zip it up, and make it available on our wiki (http://lytelab.lookingglassfactory.com/index.php/Programs). Ideally, I’d like a user to be able to download the zip file, unzip it into a directory on their computer like ./Example, and then the user could type ‘spark flash Example’ to load it onto her core.
The bummer is, I developed the code on the web IDE, and I use the Neopixel library, so I have a

 #include "neopixel/neopixel.h" 

line at the top of my code, and the compiler doesn’t know where to find this. I tried a couple ideas, like saving a copy of the library code into a subdirectory, but no joy so far. I’m looking for an elegant way to make the cloud compiler use cloud libraries. Do you have any suggestions?

Thanks!
-enjrolas

Hi @enjrolas,

This might not be exactly what you are looking for, but you can package your example app along with your library if you like, checkout the uber library example here:

docs here: http://docs.spark.io/build/#flash-apps-with-spark-build-contribute-a-library

I hope that helps! :slight_smile:

Thanks,
David

Hey David,

Sorry, I missed your reply. Your suggestion works for a limited set of cases, but I wish there was something more general. Here's a more detailed picture of what I'm doing:

I work with several friends on an LED cube based around a spark core. Each of us has our own core and spark account. Often, somebody will cook up some new code for a neat visualization, and he'll want to share it with the rest of us. We'll want to load the code onto our own cubes to check it out, and tinker around with it to build off of the first code. We also sell the cubes as an open-source hardware produce, and we'd like other users to be able to fork, develop and share spark code easily.

Unfortunately, there's no easy way to do this in the web IDE. For me to use my friend's code, I have to create a new project in my account, add in all spark libraries first, and then create new files for each .h or .cpp file in my friend's code, and copy-paste his code into my blank files.

It's not impossible -- it just takes ten minutes and has to be done in very specific order. By contrast, the 'fork this example' button for your example apps is awesome and elegant, and I wish there was a similar 'fork this program' button for any code that I want to share.

The issues with your library solution are that (1) it requires anyone who wants to share code to be comfortable creating a library, and not all of us are, and (2), we can only include one example (and there are lots of programs we want to share)

Incidentally, if I add any helper files and then add a spark library, the web IDE has a bug where it duplicates all of my helper files -- if I had the helper file 'colors.h' included in my program, and then add a spark library, the IDE creates two identical copies of colors.h, and I have to go through the program and delete them. No fun!

There's lots of ways to share code outside of the web IDE, but I think your IDE is one of the best things about the Spark, and makes it very easy for anyone to create programs, regardless of their programming experience. I think it's a really good direction, and I want to keep heading that way.

Thanks, and congratulations on making a great product!
--alex

Hi Alex,

Totally! We’ve talked about an easier feature for sharing code, or even an “export to gist” / “import from gist” feature that would make this a 1-2 click process. I think an easier sharing feature would be really useful! I’ll make a note for our build IDE team, and hopefully we can start to build this out this in the coming weeks. :slight_smile:

Thanks,
David

3 Likes

Awesome! When you get something that’s test-able, I’d love to give it a whirl.

Thanks!
–alex

@enjrolas, personally I use Spark CLI and “locally” compile. The local code is a clone of a repo and easily maintained and shared. :smiley:

2 Likes

@Peekay, I use the CLI a lot, as well, and I think that’s the way to go for Ultra-Tech-Mega-Geeks (UTMGs). I’m more concerned here with sharing code with users who don’t use the command line, but would experiment with code if there was a low barrier to entry (think: getting high schoolers comfortably tinkering in a one-hour workshop).
FWIW, I don’t think installing the spark CLI is a high barrier to entry. That’s wicked easy. It’s the command line itself that takes a lot of time to learn.

@enjrolas, I hear you! You bring up some good points and would be so cool if someone could put a simple GUI or menu front-end to make it easier. Is that feasible @Dave?

1 Like

Sounds like a great job for the atom IDE! :slight_smile: