I'm having trouble understanding how to go from installing to using a cljsjs package. I am using the standard figwheel template, and I've made a little progress learning it, but now I'd like to use some 3rd party JS, and while cljsjs looks like the ticket, I can't find a clear example of how to actually use the packages.
I'm attempting to use the material package, to start with (http://material-ui.com). I'd like to just display a simple button to start.
I've added the [cljsjs/material "1.0.4-0"] to my project.clj, and lein installs it....now what?
Where and when should I (:require [cljsjs.material]) ?
How would I then create a <FlatButton> component, or whatever?
I see a resources/public/js/compiled/out/material.inc.js with what appears to be the full source for material - how do I use it?
Thanks in advance to any kind soul taking pity on a cljs beginner. It is incredibly appreciated. If there is anything out there that answers my question that my googling somehow missed, I apologize in advance.
The package [cljsjs/material] you're referencing does NOT use http://material-ui.com/ but instead uses: http://www.getmdl.io/
So there is NO <FlatButton>.
A primer on actually using cljsjs packages can be found here:
https://github.com/cljsjs/packages/wiki/Using-Packages
To use the material-ui package for example:
Put [cljsjs/material-ui "3.9.1-0"] in the :dependencies section of your project.clj file (make sure you update the version number to latest).
Require the cljsjs package in the (ns) section of your code: (:require material-ui)
Finally, you can reference the imported JavaScript objects directly by name: js/MaterialUI
It is sometimes difficult to figure out the JavaScript names. Generally you need to refer to the original JS package.
In the case of material-ui specifically, there are :global-exports helper mappings which you can see here, and these allow you to reference the library more conveniently and directly with material-ui.
Note that it is also quite often possible to import npm modules directly now with :npm-deps.
Related
I'm admittedly new to Netsuite, so this may be obvious, although I've been unable to find anything specific one way or the other. In fact, I don't even attend any training until next week, but I'm trying to get part of my development environment setup with one of the editors/IDEs I prefer. I know that Netsuite offers an Eclipse plugin, but I'm not an Eclipse fan. I'd prefer to use either WebStorm or TextMate. (I'm on MacOS Sierra)
I tried installing the WebStorm plugin, but it's throwing an exception and is not functional. I submitted a bug on GitHub, but what I'd really like to know is if it's possible for me to write my own script to upload/download files to the cabinet, so I could just roll my own feature in TextMate. Is this possible, and if so, how? (Just a link to the docs is perfectly fine)
In other words, is it possible via their API, to submit changes to a script I've been working on in another editor/IDE? Or interact with our cabinet? (Not sure if I'm using the proper NS verbiage, but hopefully you get my intent) I'm thinking about writing a Python script, that accepts a local script path as a parameter, that will then get submitted to our cabinet. Thanks for the help in advance.
I wrote a plugin for JetBrains IDEs (I use WebStorm specifically though) that mimics NetSuite's Eclipse plugin. Feel free to take a look. It is open source and has ~1500 downloads at the current moment.
https://plugins.jetbrains.com/plugin/8305?pr=
If you are the same person that opened this issue (https://github.com/Topher84/NetSuite-Tools-For-WebStorm/issues/7), it has been closed and was due to using an older version of WebStorm.
I don't like eclipse personally, so I just make my scripts in whatever and use Netsuite's script backend to upload the scripts as 'new' when I'm done. If I want to change them, simply use their backend again to 'edit' the script. You'll see a simple editor, where you can change things, or you just copy and paste what you have in there. It's a little more work than something integrated, but it does work..
So how does the "replace" property work with composer? I have read the composer document but still not understand it. Searching for more info hasn't answered my questions.
When I look at the composer.json file on Laravel/Framework on github. I can't see how replace will work. Can someone explain to me how this works? And what the variable "self.version" will equal to?
The Composer documentation gives two basic examples. I'll try to explain:
Lists packages that are replaced by this package. This allows you to fork a package, publish it under a different name with its own version numbers, while packages requiring the original package continue to work with your fork because it replaces the original package.
Suppose your software uses original/library and other/package, which itself also requires original/library.
Now you think that original/library needs to integrate a feature, but the maintainers won't let your suggestion happen in their package. You decide to fork that library under the name better/library, and tag a new release.
Back to your software. Of course it should start using better/library, so you require that instead, but that other/package still requires the original/library - code duplication! How can you make that other package to use your better/library instead without also forking it and only changing the composer.json (you are still compatible to that original/library, so it should work)?
You add a replace key to your composer.json:
"replace": {
"original/library":"1.0.2"
}
Now Composer knows that any package from your better/library is equally good as the original/library when it comes to resolving the dependencies of the other/package.
This is also useful for packages that contain sub-packages, for example the main symfony/symfony package contains all the Symfony Components which are also available as individual packages. If you require the main package it will automatically fulfill any requirement of one of the individual components, since it replaces them.
The same rules, a slightly different angle: Requiring components of a framework is a good approach for any other component that needs some feature. But if you require the full framework in your software, and another library, which subsequently also requires a component of that framework, the replace declaration of the framework allows Composer to not have to install that single component twice, because it is already included in the full framework.
Beware: Placeholders in replaced versions are usually bad
In my original answer I suggested:
"replace": {
"original/library":"1.*"
}
This has consequences: Composer will now treat your library version 1.0.0 to be as good as ANY version 1.x of the original library, even if they fix stuff or add features and release version 1.2.34 some day. This also means that if your other/package some day gets an update and requires original/library:^1.1, the replacement in YOUR library is still active and states that it can replace ANY version 1.*, even without you updating anything inside - which it can not, your old code will never implement new features of the original library without you doing some work, but the replacement states exactly this.
So in essence: Avoid wildcard versions in the replacement version! If you use them, you make a statement about the future that you cannot know or predict (unless you can control original/library, but even then be very careful). Always use a specific version of the original/library that you know and can re-implement completely.
When you create your own package, you define in your composer.json what kind of packages does it provide which basically tells Composer that your package has it already installed, so no need to install it again.
If you use replace property, it tells Composer that your package wants to replace the original package with your own fork, so other packages don't need to install it.
For example if a/a package requires b/b and you tell to replace b/b, it won't be downloaded on Composer install/update.
This is explained in more details in here: How does the “replace” property work in Composer?
Hello all CodeIgniter guys :), I'm new to CodeIgniter andIi have now put my project on github. Here is my github page: https://github.com/SimonJ/Hip-hop-project
So I would hear about someone bothered to look through my files and make comments about what I can do better so I can learn something new :)
I have tried to use ocular template system but I get this error:
An Error Was Encounter Unable to load the Requested Class: ocular
Do you know what I'm doing wrong?
This question borders on the edge of belonging on Code Review instead of Stack Overflow, but I'll help you with your templating issue.
Are you running PHP 5 on your server? It looks like Ocular is using "public" and "private" words for functions and variables.
You are running an older version of Codeigniter by the looks of it because I don't see a folder called "core" in your application folder. There's a community version of CI called Reactor here or you can get the standard CI 2.0 from EllisLab here. I would upgrade to one of those, personally I would use Reactor.
Ocular is great but Phil Sturgeon has a lighter template library simply called template you might be interested in looking at as well, here. Like I said in the first paragraph of this answer, go to Code Review if you would like to have your code critiqued and reviewed.
PS. Welcome to Codeigniter, it's an awesome PHP framework.
I need to write a Clojure script to create a simple app by using Vaadin.
In Java I cam use some thing like this. "import com.vaadin.Application;"
But I don't know how to do it in Clojure.
I need to know how to import it and the place I should keep that .jar.
There is a build tool for clojure called leiningen.
Follow these instructions to install it: https://github.com/technomancy/leiningen
Create a new project
Put that jar to lib folder
Import classes you need
For example:
(ns your-project-name.core
(:import (com.vaadin Application)
(com.vaadin.ui Button Form HorizontalLayout)
(com.vaadin.data.Property ValueChangeEvent)))
Also read this article on how to use java classes in clojure: http://java.ociweb.com/mark/clojure/article.html#JavaInterop
Note that clojure does not provide a way to import every class in a Java package without specifying each class explicitly: How do I import the entire package but exclude some in Clojure?
I use Vaadin with Clojure as well and I initially had alot of pain. In the end I made sure I wrote alot of example Vaadin applications using Java only. Once I was familiar with Vaadin I wrote alot of example Clojure applications. Once I was proficient in both then I attempted to use Vaadin with Clojure, and I haven't looked back since.
I occasionally get this problem, and generally work around it, but it's rather frustrating.
I have all of Incanter (check it out if you don't know it: it's superb) on my classpath. I try to import it (through a Slime REPL) like this: user> (use 'incanter.core), but fail.
Doing this: user> (use 'clojure.contrib.def) works just fine, and this file is in the same place–on my classpath.
Regardless, the error isn't anything about classpath: it's this:
Don't know how to create ISeq from: clojure.lang.Symbol
[Thrown class java.lang.IllegalArgumentException]
You can see my entire terminal here (a screenshot.)
I don't know what's going on here, and it's really frustrating, as I really would like to use Incancter, and I can from the Incanter binary's REPL. I definitely don't want to develop from that–and this should work.
Any help would be much appreciated.
EDIT:
It appears as though Incanter requires Clojure 1.2, and lein swank gives me Clojure 1.1. This might be the cause of my problems: if so, is there a way to continue to use Swank & Lein with Clojure 1.2?
Thanks again!
EDIT:
Apparently if you start using Clojure-1.1 and lein swank, you're stuck with it unless you make a new project.
If future people have this problem, this article helped me out, but also, at least for me, you must start a new lein project if you had begun it using leink swank and Clojure-1.1. Simply changing your project.clj file and then lein swanking again doesn't work.
Yes, you can use Leiningen and swank-clojure with Clojure 1.2. You might need to use a recent version of Leiningen (I'm not sure if a certain old limitation affected lein repl only or was it lein swank as well; anyway, try the 1.2-RC2 which you'll find in the downloads section on GitHub). You will also need to use a recent-enough swank-clojure; I use a bleeding edge checkout myself, get yours here.
Other than that, simply use 1.2 jars for Clojure and contrib. (Lein uses it's own Clojure, separate from the one used for lein swank, for its internal workings and you never need to care about it; swank-clojure has no AOT'd namespaces and doesn't particularly care about the Clojure version, except once in a (long!) while something breaks, a patch is applied and joy is restored.)
I hope the above helps, but if it doesn't: your problem description is not entirely sufficient for me to get a clear picture of what is happening. Could you add information on what it means for "all of Incanter" to be on your classpath (do you mean the jars? sources? where do you get them? how do you set your classpath?). Without knowing this, it'll be hard to replicate your setup to try to track down the source of the problem.
Of course if bumping some versions fixes things, please disregard my current confusion. ;-)