Can any one point out as where can I get some tutorials about IronJS and how to call a method written in IronJS from C# 4.0
Thanks
C#4.0, IronJS
There is now some good information from the author on the GitHub project wiki:
https://github.com/fholm/IronJS/wiki
There is a 'first steps' blog post here:
http://blog.dotsmart.net/2011/04/20/first-steps-with-ironjs-0-2/
And I have written several blog posts on IronJS including one that stej has linked. The post stej linked is actually current, but it only covers some basic aspects of embedding. IronJS has undergone a radical rewrite since my first posts so I have put notices on those posts directing to newer updates.
This post specifically covers the original poster's question about how to call JS code from C#:
http://newcome.wordpress.com/2011/03/13/embedding-ironjs-part-ii/
Here is a quick summary:
IronJS.Hosting.Context ctx = IronJS.Hosting.Context.Create();
ctx.Execute("hello = function() { return 'hello from IronJS' }");
IronJS.Box obj = ctx.GetGlobal("hello");
Func<IronJS.Function,IronJS.Object,IronJS.Box> fun =
obj.Func.Compiler.compileAs<Func<IronJS.Function,IronJS.Object,IronJS.Box>>(obj.Func);
IronJS.Box res = fun.Invoke(obj.Func, obj.Func.Env.Globals);
Console.WriteLine( res.String );
Checkout https://github.com/fholm/IronJS/wiki for guides on using IronJS
If you have a Context, you can call Context.CompileSource() and pass its results to Context.InvokeCompiled(), or just call Context.Execute() and pass it the source code. Roughly, this:
IronJS.Hosting.Context ijsCtx;
ijsCtx = IronJS.Hosting.Context.Create();
ijsCtx.Execute("(function(){return 42;})()");
You might have a look at Embedding IronJs. But it looks outdated as well as the answer by #Gabe.
Currently it should be called like this:
var o = new IronJS.Hosting.Csharp.Context
o.Execute('var a = 10; a');
Related
I'm in the process on making a actions on google project and I am wanting to add a carousel to the action.
I understand the code end of things of how to add it to your action, but I'm a bit confused on how you get the links for your images. So for example, I seen in googles tutorial for carousel they have this following code snippet (to get it started):
const IMG_URL_AOG = 'https://developers.google.com/actions/images/badges' +
'/XPM_BADGING_GoogleAssistant_VER.png';
const IMG_URL_GOOGLE_ALLO = 'https://allo.google.com/images/allo-logo.png';
const IMG_URL_GOOGLE_HOME = 'https://lh3.googleusercontent.com' +
'/Nu3a6F80WfixUqf_ec_vgXy_c0-0r4VLJRXjVFF_X_CIilEu8B9fT35qyTEj_PEsKw';
const IMG_URL_GOOGLE_PIXEL = 'https://storage.googleapis.com/madebygoog/v1'
+
'/Pixel/Pixel_ColorPicker/Pixel_Device_Angled_Black-720w.png';
const IMG_URL_MEDIA = 'http://storage.googleapis.com/automotive-
media/album_art.jpg';
const MEDIA_SOURCE = 'http://storage.googleapis.com/automotive-
media/Jazz_In_Paris.mp3';
// Constants for selected item responses
And if you actually type these links in, you will get something like this back. The last two are other media types, but same idea.
Could someone explain how getting the images/ image links works for carousel's with actions on google? Do you have to make a html page for that image or am I just overthinking this and you can take an image link from online and it will work (given the right size of course). I might have missed something in the docs.
Thanks for the help or suggestions!
To maybe provide further context, I'm going off of this doc
Is there a way to filter github events using the GET request?
For example can I preform a GET that returns a subset (ForkEvents) of a repo's events?:
pseudo-request (though this doesn't work):
GET /repos/:owner/:repo/events?type=ForkEvent
More generally is there any way to implicitly filter the response data in the GET request i.e. before the data reaches my code? (I am new to the github-api and RESTful APIs in general, so I apologize in advance if this is a clueless question)
Thanks
If the Events Documentation is correct, it would appear this is in fact not possible. If you're new to the GitHub API you should probably try to use a library that exists for it. For example, if you were using python and github3.py then you might do something like:
import github3
g = github3.login("nelag", "nelag's password")
r = g.repository("nelag", "nelags_repo")
forks = filter(lambda event: event.type == 'ForkEvent', r.iter_events())
Nice and simple and you will have the added benefit of your code being lazy.
I'm searching for a way to retrieve data (formatted in json) from an API and parse them.
I really want to use the code both for android and for IOS. I already saw examples but they didn't work for both platforms.
If you can provide me examples for connection, retrieving and for json, it is the best for me because I didn't find great docs about cross-platform (quite simple) implementation.
Comments Welcome !
Thanks in advance!
I've used Newtonsoft's json library in a monotouch solution
Find the source code here.
As far as retrieving the data - that depends on your API, I suspect it's a web API with HTTP calls? If that's the case you can further elaborate on this, obviously exception handling and threading is up to you:
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create (url);
...
request.BeginGetResponse ((r) =>
{
string res = null;
using (StreamReader srd = new StreamReader(response.GetResponseStream())) {
res = srd.ReadToEnd ();
}
T jres = Newtonsoft.Json.JsonConvert.DeserializeObject<T> (res);
}, null);
Instead of using nuget to download Newtonsoft, you need to download it from here:http://components.xamarin.com/view/json.net/
The Spotify UI guidelines for Spotify apps (at https://developer.spotify.com/technologies/apps/guidelines/design/) say "When listing tracks in your app, use our standardized track listings". I cannot find any examples in the documentation on how to use these "standardized track listings". By using the Inspector I have found classes in list.css (such as sp-list and sp-item) which it looks like I need to use but have not been able to work out quite how to use these to recreate the look of the Spotify track listings.
The Billboard Top Charts app appears to use track listings like I need, but I can't find ay way to see how they are doing this as the Inspector only works for your own apps as far as I can tell.
Does anybody have any advice or examples?
Some examples
sp = getSpotifyApi(1);
var m = sp.require("sp://import/scripts/api/models");
var v = sp.require("sp://import/scripts/api/views");
// Example 1
var tpl = new m.Playlist();
var tempList = new v.List(tpl);
tpl.add(m.Track.fromURI("spotify:track:4z4t4zEn4ElVPGmDWCzRQf"));
tpl.add(m.Track.fromURI("http://open.spotify.com/track/7E8JGVhbwWgAQ1DtfatQEl"));
tpl.add(m.Track.fromURI("spotify:track:40YBc3mR3yyqyYvtesQOMj"));
tpl.add(m.Track.fromURI("spotify:local:Rolling+Stones:A+Bigger+Bang:Rain+Fall+Down:293"));
document.body.appendChild(tempList.node);
// Example 2
var pl = m.Playlist.fromURI("spotify:user:username:playlist:424km2k4m24");
var list = new v.List(pl);
document.body.appendChild(list.node);
// Example 3
var album = m.Album.fromURI("spotify:album:1vWnB0hYmluskQuzxwo25a");
var albumList = new v.List(album);
albumList.node.classList.add("album");
document.body.appendChild(albumList.node);
Thanks for asking, I had exactly the same question too!
I too get the issue where i get no actual content added - just the wrapper div. Not including api.css makes it work, but the list is obviously not styled. Including css/list.css directly breaks it too. Creating my own copy and selectively commenting out list.css I found the offending rule to be:
.sp-list > div {
if you change this to be
.sp-list {
then it renders fine. No idea what is going on. Obviously this solution is not idea because I've just duplicated what's meant to be a common resource...
This question came up on the etherpad-open-source-discuss mailing list and I thought it would be useful to have it here.
Just construct a URL like so and fetch it:
http://dtherpad.com/ep/pad/export/foo/latest?format=txt
That will get the live, plaintext contents of http://dtherpad.com/foo
For example, in PHP you can grab it with
file_get_contents("http://dtherpad.com/ep/pad/export/foo/latest?format=txt")
Note that that's just the "export to plain text" link that's provided in the Import/Export menu of every pad.
A few other possibilities:
From a browser, you can hit http://your-etherpad-server.com/ep/pad/view/padId/latest?pt=1
From within the code of the collaborative editor (ace2_inner.js), use rep.alltext
Within the Etherpad's javascript, use pad.text for the most recent version of pad.getRevisionText(rev.revNum) for a specified previous revision.
It seems that the javascript functions mentioned by Ari in his response are no longer present in the current versions of Etherpad as implemented on sites like http://etherpad.mozilla.org
However you can now simply use the following javascript function, within eherpad's javascript to get the text of the latest revision
padeditor.ace.exportText()
You can get the plaintext content of etherpad using jQuery as:
jQuery(document).ready(function(){
jQuery('#export').click(function(){
var padId = 'examplePadIntense';//Id of the div in which etherpad lite is integrated
var epframeId = 'epframe'+ padId;
var frameUrl = $('#'+ epframeId).attr('src').split('?')[0];
var contentsUrl = frameUrl + "/export/txt";
jQuery.get(contentsUrl, function(data) {
var textContent = data;
});
});
});
You can also use the getText HTTP api to retrieve the contents of a pad.
See my other answer for more details.