So I have come across this excellent twitter library from Remy Sharp. Hoever I am not able to find an real instructions on how to implememt it, I have included the .js file and wish to use it in the following way to produce the 5 most recent updates from a user account.
But I cannot see how I actually output it to html correctly.
twitterlib.timeline("xclusivfitness", { page: 1, limit: 5 }, callback);
I presume i need to create a function to produce the html, but have hit a wall.
Sorry!
He's documented this library at https://github.com/remy/twitterlib. That should give you a good start.
Related
I'm writing my first plugin for DocPad and I'm really enjoying the process because it's actually pretty intuitive.
My plugin uses shortcode-parser to parse shortcodes in my markdown-documents.
Here's my problem:
The marked-plugin for DocPad converts " to ", which is totally expected behaviour. However, this breaks my plugin because what was [tagname attribute="some value"] becomes [tagname attribute="some value"].
Possible Solution:
There is already a plugin out there that handles shortcodes. It circumvents this problem by using a file-extension. The reason I wrote my own plugin was (aside from learning DocPad) that I don't want to have to add file extensions to hundreds of documents just to enable my plugin.
Are there any clean alternative besides using file-extensions to prevent render-plugins from clashing? If there was, for example, a configuration-attribute to specify the order in which render-plugins execute – I would consider that a pretty good solution.
I just went with using extensions. The resulting plugin can be found here, if anybody's interested: https://github.com/maximilianschmitt/docpad-plugin-shortcodeparser
If anybody has a better idea to solve this kind of issue, please let me know!
I think it would be handy to have a plugin, that could provide predefined pipelines.
For example:
docpadConfig = {
plugins:
PLUGIN:
main: '.html.md.eco'
}
With this plugin document with extension .main could be processed as if it had extensions '.html.md.eco'.
Not sure, but maybe it's possible to replace pipeline by some query like this:
docpadConfig = {
collections:
_main: ->
#getCollection('html').findAllLive({extension:'main', }).on 'add', (model) ->
model.setMeta({extensions:['html', 'md', 'eco']})
}
I am working on creating a process flow using IBM BPM 8 on a dojo platform which encompasses the use of javascript. We have in use three versions that supports NextGen coaches; Heritage coaches and Portal versions. Now through this, we are trying to implement a calendar view like that of FullCalendar or one like that of SharePoint. The group that I am working with is uncertain of how to incorporate the code function dojo.version.toString() in order to yield the results we want. I do have examples of what I have tried but am unsure of exact syntax due to using different tools.
Below are a few examples of what I have tried. Such a call is a little more out of my knowledge of what to do or the syntax to use, so laugh if you want, wont take offense, but I do hope to get some help or at least guided where I can get some help.
<script type=”text/javascript”>
getVersion(){
alert(“Version: “ + dojo.version.toString());
}
</script>
<input type=”button” onclick=”getVersion()”>Get Version</input>
RESULT: nothing
var foo: String=dojo.version.toString();
RESULT: nothing
var string=dojo.version.toString();
RESULT: nothing
var string=dojo.version.toString();
<button type="button">Get Version</button>;
RESULT: nothing
I am not the most savvy of programmers and have been directed by the group to just look up if there have been successes in this realm but have found a few that looked promising but when I try it out myself, everything works except for the version not appearing.
Thank you for your time and consideration. Any and all information is greatly appreciated.
I'm not exactly sure of your setup, but if you browse to:
http://dojotoolkit.org/
And then either in Firebug's console for Firefox, or Chrome developer tools' console, type this:
dojo.version.toString()
Then press enter, you will get (something like) this:
"1.8.3 (30226)"
To get this working in your code, you would use the following assignment:
var dojoVersion = dojo.version.toString();
Or in the style of your example
<script>
function getDojoVersion() {
alert("Version: " + dojo.version.toString());
}
</script>
<button onclick="getDojoVersion()">Get Version</button>
Off topic: I think some of your double quotes have pasted incorrectly, and I don't think they are valid JavaScript as they are.
Off topic: The <input> tag is not supposed to have any content.
dojo 1.7.3 is used in IBM BPM 8, if i remember correctly.
IBM BPM 8, 8.0.1 and 8.0.1.1 all use the dojo version 1.7.3. IBM BPM 8.0.1.2 now uses 1.7.4. However, these dojo builds are IBM customized. They are not necessarily the ones released officially by dojo. Many of their features are specific for IBM BPM.
I know it's been a while since you posted this question
If you still in need or maybe someone else who has the same issue
you can use Firebug onload it will give you which version is used
dojo version used by Coach is: 1.8.6
I am looking at using http://code.google.com/p/libphonenumber/ for a well-established project. Today the project does not use Google's libraries for JavaScript, favoring jQuery, jQueryUI, requirejs, and so on.
libphonenumber looks awesome ... except that the javascript version (svn co http://libphonenumber.googlecode.com/svn/trunk/javascript/ libphonenumber-js) is laced with goog.require calls. If one runs the demo (libphonenumber-js/i18n/phonenumbers/demo.html if you checked out as suggested) it pulls in tons of google libraries from closure-library.googlecode.com :
GET base.js
GET deps.js
GET error.js
GET string.js
GET asserts.js
GET array.js
GET useragent.js
GET browserfeature.js
GET tagname.js
GET classes.js
GET math.js
GET coordinate.js
GET size.js
GET object.js
GET dom.js
GET json.js
GET util.js
GET descriptor.js
GET fielddescriptor.js
GET message.js
GET serializer.js
GET objectserializer.js
GET stringbuffer.js
GET lazydeserializer.js
GET pbliteserializer.js
I believe if I compile this using the closure compiler ("If you give the use_closure_library parameter a value of true, the compiler looks for goog.require() statements in the source code and supplies the Closure Library code requested by any such statements.", https://developers.google.com/closure/compiler/docs/api-ref) I can cut down the raw number of requests, but this still seems like a rather excessive amount of content for a phone number parser, even a full-featured one.
My question has two possible answers:
A way to use libphonenumber in JavaScript without having to pull in all the Google JavaScript base libraries
An alternate standalone (as in doesn't have dozens of dependencies) first-class phone number processing library with both JavaScript and Java implementations
Any and all suggestions most appreciated.
I've got a custom build (currently 220KB) that I use for my International Telephone Input plugin, with plenty of helper functions exposed. Read the source for details.
You can also use my lib.
https://github.com/Gilshallem/phoneparser
Its only got one method but you can do a lot with it
parsePhone("12025550104");
result: { countryCode:1, areaCode:202, number:5550104, countryISOCode:"US" }
Here are two implementations of Google libphonenumber in JavaScript that have zero dependencies and are implemented in a single file. I've used Nathan Hammond's version without issue but it is not on NPM. Rui Marinho's version is on NPM.
https://github.com/nathanhammond/libphonenumber
https://github.com/ruimarinho/google-libphonenumber
I just spent 2 days figuring this out. For now, anyway, you can download a minified version of libphonenumber-js from here
drop it in place, with the usual
<script type="text/javascript" language="javascript" src="/static/js/libphonenumber-js.min.js"></script>
and get busy coding!
<script>
$(".phone-format").keyup(function () {
var val_old = $(this).val();
var newString = new libphonenumber.AsYouType('US').input(val_old);
$(this).focus().val('').val(newString);
});
</script>
There is a website called Gild.com that has different coding puzzles/challenges for users to do. They can be completed in wide array of languages including Javascript. I am interested in solving these puzzles in Javascript, but I am unsure of the following:
How am I supposed to access the input file which is supposed to be passed as an argument?
How am I supposed to output the result?
My understanding of Javascript is that it is run from within an HTML page and that output really is only in the form of placing values in the HTML, modifying the DOM, etc. For that reason it is not clear to me how Javascript can be used for solving these types of problems. Can someone who has used Gild before or has some insights into my question suggest how to proceed?
An example of a problem would be: the given input file contains a positive integer, find the sum of all prime numbers smaller than that integer and output it.
EDIT: Some of the solutions below involve using external resources, but on Gild, I am supposed to put my solution in their editor and then submit it that way, like the following picture shows:
In other words, I don't think my solution can have access to Node.js or other external resources.
Edit: Here are some interesting articles that I have found that I think are the answer to my question:
http://www.phpied.com/installing-rhino-on-mac/
http://www.phpied.com/javascript-shell-scripting/
I haven't spent much time on Gild, but I do a lot of similar types of problems on Project Euler. I think the best way to go is probably Node.js.
If you're not familiar, Node is basically server-side JavaScript that runs in Google's V8 engine. Installing it on your own Mac/Windows machine takes about 2 minutes. It's also really fast (considering it's JavaScript).
And you'd use it like this:
var fs = require('fs'); // the filesystem module
var contents = fs.readFileSync('theFile.txt', 'utf-8');
// Do stuff with the file contents...
Everything after those first two lines can be done with the same JS you'd write in the browser, right down to calling console.log() to spit out the answer.
So, if you wrote your script in a file on your desktop called getprimes.js, you'd open up your terminal and enter node ~/Desktop/getprimes.js (assuming you're on a Mac)
If you're:
on a Mac,
planning to do a lot of these puzzles, and
willing to pay $10, then
I highly recommend CodeRunner. It encapsulates runtimes for a variety of languages — from C to JavaScript — and lets you quickly build and run any sort of one-off code. Just hack together your code, ⌘R, and the results are printed right there in the same window.
I haven't used any file-based JavaScript in CodeRunner, but I imagine kennis's suggestions would apply. To output your results:
console.log(...)
Easy as pie!
Spent a bunch of time looking at this.. It seems that what little info there was about accessing a Google-apps spreadsheet is not very well maintained..
At Google IO this year there was an announcement of enhanced Google-apps script. Including UI elements..
That got me to thinking of creating a widget based on data in Google spreadsheets, no data writing just a simple reading/look up and display calculations.. Then I realized the UI feature was only available for Premier account.. Not a huge deal at only $50/yr and some free trial time up front. It seems that the ui feature may be somewhat restrictive.
But then I began to think about all the little things I might have to do,, so I started to investigate how to just access the spreadsheets from Javascript, in which case I think they could be a plain I-Google gadget.. an I-Google gadget is quite powerful and flexible in what it can do. And this could allow a lot more flexibility.. In short I've come up short.. anyone else out there? This sort of looked like a clue http://almaer.com/blog/gspreadsheet-javascript-helper-for-google-spreadsheets and this one which I could not fetch a current spreadsheet http://code.google.com/apis/gdata/samples/spreadsheet_sample.html but has not been touch for a long time and I could not make it work on a current spreadsheet.
Here is a current "public" read only spreadsheet. http://spreadsheets1.google.com/ccc?key=tzbvU7NnAnWkabYmGo4VeXQ&hl=en
This is in what Google now refers t as it's old format, I've tried both (old and new).. don't know if that makes any difference..
Google provide a documented way to access google spreadsheet via JSONP that works for normal gmail.com accounts. In short:
Create a spreadsheet
Click on the dropdown next to "Share" and select "Publish as a web page"
Copy and paste out the key from the URL that shows (i.e. the bit after &key=)
Go to https://spreadsheets.google.com/feeds/cells/0AmHYWnFLY1F-dG1oTHQ5SS1uUzhvTnZTSHNzMjdDaVE/od6/public/values?alt=json-in-script&callback=myCallback replacing "0AmHYWnFLY1F-dG1oTHQ5SS1uUzhvTnZTSHNzMjdDaVE" with whatever key you cut out of the url
To access this from within JavaScript you'll have to insert a HTML script tag into your document:
<script src="https://spreadsheets.google.com/feeds/cells/0AmHYWnFLY1F-dG1oTHQ5SS1uUzhvTnZTSHNzMjdDaVE/od6/public/values?alt=json-in-script&callback=myCallback"></script>
And you'll need to implement the callback function in your webpage:
function myCallback(spreadsheetdata) {
// do something with spreadsheet data here
console.log(spreadsheetdata);
}
You can simplify this with jQuery:
var url = "https://spreadsheets.google.com/feeds/cells/0AmHYWnFLY1F-dG1oTHQ5SS1uUzhvTnZTSHNzMjdDaVE/od6/public/values?alt=json-in-script&callback=?";
$.getJSON(url,{}, function (d) { console.log(d); });
I have implemented a fairly complete example and the code is at
https://bitbucket.org/tbrander/ggadget/wiki/Home
Code is BSD license (except for Trademarks and institutional markings which are all rights reserved)
It is reasonably well commented...
It is in operation at
http://acre.cba.ua.edu/ (bottom of page)
Stand alone at :
http://acre.cba.ua.edu/mobiletool/res.html
It functions across IE, Chrome FF i-Phone and Android
Your hints above are close but I was looking for yet more... as You can now see,, But I will explore the Jquery syntax as the current implementation is pure JS