< HELLO > MY NAME IS MUHAMMAD TASHFEEN. I AM A 14 YEAR OLD WEB DEVELOPER. FROM PAKISTAN. I ❤ TO CODE! < /BYE >


Part of AadhaarAuth.signature View In Hierarchy
| Method | __init__ | Undocumented |
| Method | init_xmlsec | Undocumented |
| Method | shutdown_xmlsec | Undocumented |
| Method | sign_file | Undocumented |
| Method | verify_file | Undocumented |
| Method | cleanup | Undocumented |
| Method | check_filename | Undocumented |


pop-api
Features
The pop-api project aims to provide the core modules for the
popcorn-api
project, but
can also be used for other purposes by using middleware.
- Cli middleware for reading user input with
commander.js
. - Database middleware for connection to MongoDB through
mongoose
. - Logging of routes and other information using
winston
. - Uses
express
under the hood with:- Body middleware with
body-parser
- Error handling
- Security middleware with
helmet
- Body middleware with
- Interface for registering routes for
express
. - Data Access Layer (DAL) class for standard CRUD operations.
- Route controller to handle routes for your content.
Installation
$ npm install --save pop-api
Documentation
Usage
For your basic setup you have to create a controller which will handle the
routes. Your controller needs to extend from the IController
interface to
implement the registerRoutes
method which will be called during the setup.
The route controller below will be created with a constructor which takes an
object as the parameter. This example will register a GET /hello
route and
sends a JSON object as a response with a greeting to the name provided by the
object from the constructor.
// ./MyRouteController.js
import { IController } from 'pop-api'
// Extend your route controller from the 'IController' interface.
export default class MyRouteController extends IController {
// The constructor takes an object as the parameter.
constructor({name}) {
super()
this.name = name
}
// Implement the 'registerRoutes' method from the 'IController interface.
registerRoutes(router, PopApi) {
router.get('/hello', this.getHello.bind(this))
}
// Router middleware to execute on the 'GET /hello' route.
getHello(req, res, next) {
return res.json({
message: `Hello, ${this.name}`
})
}
}
To initialize the API we create an array of the route controllers and their
constructor arguments we want to register. Then we just call the init
method
with the route controllers array, and the name and version your API (needed for
the Cli). The API should run by default on port 5000
.
// ./index.js
import { PopApi } from 'pop-api'
import MyRouteController from './MyRouteController'
import { name, version } from './package.json'
;(async () => {
try {
// Define the controllers you want to use.
const controllers = [{
Controller: MyRouteController, // The controller to register.
args: { // The arguments passed down to the
name: 'John' // The additional arguments to pass to
// your route controller.
}
}]
// Initiate your API with the necessary parameters.
await PopApi.init({
controllers, // The controllers to register.
name, // The name of your API.
version // The version of your API.
})
// API is available on port 5000.
// GET http://localhost:5000/hello -> { message: 'Hello, John' }
} catch (err) {
console.log(err)
}
})()
License
MIT License


{% endblock breadcrumbs_self %}
{% block content %}
{{ block.super }}
{% include "hawc/_delete_block.html" with name="reference" notes="This also removes the reference from any searches/imports which may have included the reference. If data was extracted with this reference and it is associated with bioassay or epi extractions they will also be removed." %}
{% endblock content %}


HotelsCombined
Front end forum
Talk 1: Mobile debugging
Boris Pavlov
Boris shows us how to debug mobile sites - all without using USB or wires, wow!
Talk 2: Gotta test 'em all!
Mikkel Bergmann
I wanna be the very best, Like no one ever was, To catch them is my real test...!
Like this
How does it work?
Browser->ControlProxy: Request a page
ControlProxy-->Endpoint: Forward request
Endpoint-->ControlProxy: Response
note over ControlProxy: Inject "parasitic JS" \nbelow body tag
ControlProxy->Browser: respond with proxied page
Browser event sync example
note over Browser: User clicks\non element
Browser->ParasiticJS: Event object
ParasiticJS->ControlProxy: serialised\nevent object
ControlProxy-->OtherBrowsers: Event object
note over OtherBrowsers: Apply events\nfrom object
Browsersync
"BrowserSync makes your tweaking and testing faster by synchronizing file changes and interactions across many devices."
Note: It does a bunch of other things, but we will concentrate on the proxying capabilities.
So do we just give up?
What's different?
- Preliminary touch event support (slideshow)
- More input events (better typing support)
- Uses xpath to find elements instead of indexes (fix calendar issue)
- Sync content-editable data
CodeKit
"CodeKit automatically refreshes browsers as you work. Like magic."
Thanks for coming!
If you are interested in presenting a lightning talk, please let me know for next month.


--- layout: page title: Talks --- {% assign talks = site.talks | reverse %} {% for talk in talks %}
{{ talk.date | date_to_string }}
{{ talk.content }}


Lcf.vs
on 2011-07-02 12:34:09
Me>
var test;
test=[]; // true
test=[[]]; // true
test=[new Array()]; // true
test=new Array(); // true
test=new Array([]); // true
test=new Array(new Array()); // true
test[1]=3; // true
test={}; //false
test[0]=1; //false
What else?
Me
on 2011-07-02 11:29:50
@Lcf.vs: You can find an answer to your question here http://phpjs.org/functions/is_array:437#comment_112008
Lcf.vs
on 2011-07-02 00:39:50
Why complicate?
function isArray(supposedArray){
return supposedArray instanceof Array;
}
Nathan Sepulveda
on 2011-03-16 19:28:09
@Brett: Thanks!
Brett Zamir
on 2011-03-15 04:09:11
@Nathan (Sepulveda): Fixed in Git. Thanks!
Nathan Sepulveda
on 2011-03-14 23:16:22
I was wondering if you could put my last name on the credits for this function, I only say this because the name "Nathan" links to two different contributions, but I have only contributed on this function, and not to the htmlspecialchars function and I would like to make that distinction. Thanks.
Brett Zamir
on 2011-01-02 10:49:15
@abdelrahman salem: That's a good one, unless you pass in a string constructed by a String constructor:
is_array(new String('abc')); // true
(or if you override propertyIsEnumerable)
There seem to be no 100% perfect solutions for this one...
abdelrahman salem
on 2011-01-02 09:27:05
function is_array(inputArray) {
return inputArray && !(inputArray.propertyIsEnumerable('length')) && typeof inputArray === 'object' && typeof inputArray.length === 'number';
}
Brett Zamir
on 2010-11-30 16:09:54
@Nathan: I adapted your code a bit and added to Git, thanks for the patches. We still want to keep the INI settings so that people can force this function to disallow objects from being considered as arrays. I also kept part of the old way in the comments because the old way was also valid and even harder to get a false result, but I agree your solution is simpler.
Nathan
on 2010-11-24 19:35:51
Sorry for the reposts, feel free to remove the other one below, I didn't know the code would be hidden, and I forgot to remove a this:
function is_array (mixed_var)
{
var getFuncName = function (fn) {
var name = (/\W*function\s+([\w\$]+)\s*\(/).exec(fn);
if (!name) {
return '(Anonymous)';
} return name[1];
};
if (!mixed_var) {
return false;
}
if(Object.prototype.toString.call(mixed_var) === "[object Array]")
{
return true;
}
else if(Object.prototype.toString.call(mixed_var) === "[object Object]" &&
getFuncName(mixed_var.constructor) === "Object")
{
return true;
}
return false;
}
Nathan
on 2010-11-24 19:30:49
REVISION:
function is_array (mixed_var)
{
var getFuncName = function (fn) {
var name = (/\W*function\s+([\w\$]+)\s*\(/).exec(fn);
if (!name) {
return '(Anonymous)';
} return name[1];
};
if (!mixed_var) {
return false;
}
if(Object.prototype.toString.call(mixed_var) === "[object Array]")
{
return true;
}
else if(Object.prototype.toString.call(mixed_var) === "[object Object]" && this.getFuncName(mixed_var.constructor) === "Object")
{
return true;
}
return false;
}
Nathan
on 2010-11-24 19:26:09
@Brett: I posted some code earlier and it hasn't shown up, I used the constructor and was able to shorten the above function to only a few lines:
if(Object.prototype.toString.call(mixed_var) === "[object Array]")
{
return true;
}
else if(Object.prototype.toString.call(mixed_var) === "[object Object]")
{
if(getFuncName(mixed_var.constructor) === "Object")
{
return true;
}
}
return false;
(of course, I need to add the getFuncName function, but you already have it)
Brett Zamir
on 2010-11-24 12:57:56
@Nathan: Pretty much, yes (by default). But this should probably be checking the constructor property instead to see whether it is a regular function or the built-in object constructor, since the current approach would allow some non-inheriting objects created with "new" to be considered as associative arrays (though maybe some would like it that way).
Another issue with associative arrays is ECMAScript's annoyingly unpredictable iteration order, so I'm hoping we can allow array() to allows objects to be built something like this, with multiple objects passed as arguments to preserve order: var arr = array({key1:'val1'}, {key2:'val2'});.
Yet another related issue is how IE doesn't really delete properties, as it remembers their iteration sequence, making it impossible for us to sort arrays in place (thus requiring us to deviate from PHP and return a copy of the array). The proposal I mentioned would deal with this problem too, albeit in a regrettably but necessarily ugly way.
Nathan
on 2010-11-22 21:20:20
@Zamir: I can see how instanceof would have have issues with a user defining their own Array object. As for frames, they just shouldn't be used, but, seeing as they are, and that they are available, one must program for them. As for associative arrays, according the function above, are we assuming that all literal objects (meaning "var myObj = {};") are considered assoc arrays, and that all non-literal objects (such as functions and javascript psuedo-classes (via the prototype) are to be then considered objects? The only exception here of course being the Array class. This makes sense to me, I just have never programmed for assoc arrays in javascript because I really just have never had the time, and now that I do, here I am.
Brett Zamir
on 2010-11-22 07:41:11
@Nathan: Although I can't see Andrey's comment here, what you cite is not supposed to work across frames because "Array" will be a different constructor on another frame: http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/ (also if someone defined their own Array: "var Array = function () {}"). Also, in our case, we may treat objects as arrays, since we allow them potentially as associative arrays.
Nathan
on 2010-11-21 22:27:06
I agree with Andrey, I cannot find a single instance where:
function is_array(mixed_var)
{
return mixed_var instanceof Array;
}
does not work.
Nathan
on 2010-11-21 22:25:05
I agree with Andrey, I cannot find a single instance where:
function is_array(mixed_var)
{
}
Brett Zamir
on 2010-05-11 06:35:58
@Mathias Bynens: php.js, in order to support use of object literals as associative arrays (to the extent possible), considers these as "arrays" (while attempting to exclude objects which have inherited properties and thus less likely to have been intended as an associative array). We also allow configuration for people who do not want to treat objects as arrays.
Mathias Bynens
on 2010-05-10 19:01:16
Wow, WTF!
What’s wrong with:
function isArray(obj) {
return '[object Array]' === Object.prototype.toString.call(obj);
};
Brett Zamir
on 2009-05-12 02:43:39
Sorry, I neglected to add the "phpjs." prefix in a few cases. Fixed now in SVN.
Kevin van Zonneveld
on 2009-05-11 17:38:55
Great work Brett, I Gotta say!
Brett Zamir
on 2009-05-10 12:23:20
FYI, I've just added the ability (function in SVN) for you to set the ini (e.g., ini_set('phpjs.objectsAsArrays', 0);) to establish strict type checking for arrays (not any kind of object). However, the default behavior still treats objects as arrays (unless they are objects which inherit properties).
Brett Zamir
on 2009-04-30 05:05:22
Looks like we need one more check:
&& a.constructor !== String
since the rare
var str = new String();
form would otherwise qualify.
Actually if the same frame problem with Array occurs (presumably due to Array constructor being of a different identity), I've wondered why:
!a.constructor || a.constructor.name !== 'Array'
or in our case here:
!a.constructor || a.constructor.name !== 'String'
couldn't do the trick regardless of frames...
If this wouldn't work, we could use the same trick to check for methods that are only built-in on String (as opposed to Array).
Brett
Brett Zamir
on 2009-04-30 04:55:24
You know, unless I'm just getting dizzy from this topic, I think I may have found (or refound?) a foolproof way to establish that something is an array, and only an array (i.e., for strict checking mode).
typeof a === 'object' && a.hasOwnProperty('length') && !a.propertyIsEnumerable('length')
The first test excludes strings, the 2nd test excludes objects with a length property added further up the prototype chain, while the 3rd test excludes objects with a length property added directly on an instance, all while catching arrays. Am I missing something? I don't think there are any other built-in types with a length property...
Brett
Brett Zamir
on 2009-04-30 04:20:35
@KELAN, in the same line as Kevin's question, see also the discussion I had earlier with Luke here. I think my own proposed check for both splice and concat, etc. should be pretty safe, though feedback is welcome.
@Mk. Keck, sorry for the late reply. Rather than overload the arguments to the functions (to which PHP itself might add additional arguments in the future which could conflict with any we add), the approach we are taking for customizability is the same as for PHP: use ini, and to distinguish our own specific ini-setting needs, we can use "phpjs." as a prefix (as though phpjs were an extension to PHP).
So, we can modify things to work like this:
ini_set('phpjs.objectsAsArrays', false);
is_array({prop:'val'}); // false
(If you were curious about the technical details, this can work since is_array() will check for the global this.php_js.ini['phpjs.objectsAsArrays'].local_value set by ini_set() and act accordingly, or default to true if none had been set; 'this' will refer to the global window unless the namespaced version is used, in which case this.php_js will be an instance variable, rather than a global. ("php_js" is reserved as the single global we require in some functions in the non-namespaced version.)
How does that sound?
Kevin van Zonneveld
on 2009-04-29 15:27:46
@ KELAN: Thanks for contributing. I would like to make the same point as here:
http://phpjs.org/functions/view/422#comment_33054 though
KELAN
on 2009-04-28 09:00:02
function is_array(mixed_var){
if (mixed_var) return Object.prototype.toString.apply(mixed_var)==='[object Array]';
else return false;
}
mk.keck
on 2009-03-06 16:21:20
Improved function is_array():
Why not let the user change dynamicly the behavior of is_array()?
function is_array() {
var a = arguments;
if (a.length < 1) {
return false;
}
// Check Value
var v = a[0];
// Check Strict
var s = ( (typeof(a[1]) !== 'undefined' && a[1]) ? 1 : 0 );
if (typeof(v) === 'object') {
if (v.hasOwnProperty) {
for (var k in v) {
// Checks whether the object has the specified
// property if not, we figure it's not an object
// in the sense of a php-associative-array.
if (false === v.hasOwnProperty(k)) {
return false;
}
}
}
// If (s > 0) then strict JavsScript-proof type checking
// is enabled. This will not support PHP associative
// arrays (JavaScript objects), however.
// Read discussion at:
// http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_is_array/
if (s > 0) {
if (v.propertyIsEnumerable('length') || typeof(v.length) !== 'number') {
return false;
}
}
return true;
}
return false;
}
Brett Zamir
on 2009-02-10 08:17:55
Here's my stab at isArray() (I'm not using the PHP format since this doesn't return true for objects/associative arrays) in case any were interested.
function isArray (arr) {
if (arr instanceof Array || // catch most common occurrence and exist quickly if so
(
'splice' in arr.constructor.prototype &&
'concat' in arr.constructor.prototype && // not a word, so may be safer than splice, but can't replace it since concat present on string object
!(arr.propertyIsEnumerable('length')) &&
typeof arr.length === 'number'
)
) {
return true;
}
return false;
}
Brett Zamir
on 2009-01-27 05:19:55
Hi Luke,
Yes, thanks for pointing it out. But also note "Martin B." makes the same observation I did per the "Miller device" on the blog you cite. There's apparently really no foolproof/secure way to conclusively determine something is an array (and only an array) in JS.
Luke
on 2009-01-26 04:54:55
@Brett, FYI, Doug uses the Object.proto.toString method now.
http://blog.360.yahoo.com/blog-TBPekxc1dLNy5DOloPfzVvFIVOWMB0li?p=916
Kevin van Zonneveld
on 2009-01-25 14:32:46
@ Luke: Thanks for the heads-up. Interesting article. But for the record: it's not exactly our philosophy to obfuscate object types. I don't even think there is a WE in this matter.
But my view is: that if you're 'inside' php.js, you have a PHP mindset and expect associative arrays to be, well, just arrays.
You'd probably want this to just execute:
var keys = array('0', '1', '2');
var vals = array('a', 'b', 'c');
combined = array_combine(keys, vals);
if (is_array(combined)) { // WILL FAIL IF WE DENY OBJECTS!
print_r(combined);
}
.. but it clearly doesn't if we don't allow objects to be arrays as well.. And so we've been struggling with imperfection since.
Luckily, if you need the JavaScript-point-of-view of a variable, you can also just use JavaScript code to establish that. If you want the php point-of-view, use php.js functions.
Brett Zamir
on 2009-01-25 08:51:56
Hi Luke,
Clever idea--I like it. Of course it's not foolproof if somebody overrides the Object prototype's toString() (e.g., to list all of its properties). I think an even more robust solution (and one unlikely to fail in an environment which played with built-in prototypes) might simply be to build on Crockford's approach and test for further methods (e.g., 'concat' is a pretty unlikely property) and/or to insist the method is on the prototype (excluding a user from having the property as a direct property). For example, the test, ('concat' in obj.constructor.prototype ), would catch arrays but not even {concat:'something'}. Someone could still do "delete Array.prototype.splice" but I think that would be much less likely than overriding Object.prototype.toString() which has some potential uses.
Luke
on 2009-01-24 23:10:35
While I entirely disagree with the philosophy of obfuscating a purposeful distinction in object types vis Array vs Object in the language you are entreating your consumers to write in, it has recently become best practice in js to check for Array type using this technique:
function isArray(a) {
return Object.prototype.toString.call(a) === '[object Array]';
}
See this article for reference:
http://thinkweb2.com/projects/prototype/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/
Onno Marsman
on 2009-01-20 18:56:28
Hadn't looked at this 'thread' for a while and I see there's still a question from Brett more or less open for me, about the hasOwnProperty solution and the answer to that is pretty much the same as my feelings for the whole framework/configuration idea:
I only use phpjs for the functions that are missing from javascript, and I also use it to promote javascript for other php-developers in my team because they can easily see in this library how some things can be done in javascript. About everything beyond that: I really don't care what happens: as long as I have simple functions that I can copy/paste and there aren't a lot of dependencies (which includes configuration for these functions I guess). The functions I'm talking about don't include is_array or exit or stuff like that, but I guess I've been clear on that.
Kevin van Zonneveld
on 2009-01-15 11:15:30
@ Brett Zamir: It would be cool to see other implementations coming to live. As long as I can focus on a simple robust base, people will have something consistent to build their spinoffs on.
So like I said: Personally I would like to focus on the main php.js library. Still a lot of work to be done there.
But I encourage anyone who takes that and puts it to other use. Even you :)
Brett Zamir
on 2009-01-14 16:23:56
Hi Kevin and Onno,
My feeling is that it's a toss-up. It doesn't bother me though because I really feel that after implementing more of the functions, it will be good to make a customizable version (on my own if you're not interested), since different people may want to handle things differently.
It's not like people can't study a little bit to set up something as potentially useful as this (and they should know what the code is doing before relying on it). A few main global configuration options (though ideally over-rideable on a function-by-function or function-group basis) like
1) When if at all to treat objects as associative arrays
2) Whether to follow PHP strictly or enable some useful customizations (not too many, but a few
that are just too natural/useful to pass up); basically the things in the functions which told people that they could uncomment the given lines (or the ones we wanted to add but felt would deviate too much from PHP--e.g., a file_get_contents() that could be configured to work with asynchronous Ajax, with Firefox (or possibly Explorer) local file access code, etc.)
Kevin van Zonneveld
on 2009-01-14 14:59:54
@ Onno Marsman & Brett Zamir:
What if we traverse the variable and verify that hasOwnProperty returns true for every element, and only then return true for is_array?
That way you can be pretty sure that this object is just a storage container, and nothing fancy otherwise.
Kevin van Zonneveld
on 2008-12-31 10:56:27
@ Onno Marsman: You are totally right. How about the current comment.
@ Brett Zamir: I didn't even know that, I'm amazed actually. Google's got some work to do on improving her engine :)
About the frameworks: Besides the obvious naming conflicts, the main reason I created the namespaced version was for others to be able to more easily extend & build on top of it.
Onno Marsman
on 2008-12-30 20:20:20
Ok, than we'll just leave it to return true on objects.
I do have a tiny little problem (I just can't help myself, sorry) with the comments: "Uncomment to disable support" It's not that it's not supported if you do that, it just behaves differently with all the pros en cons we discussed. If you do feel that it would be disabling support for ..., it wouldn't make any sense to put it there: who would want to disable support for something?
Brett Zamir
on 2008-12-30 17:15:00
Well, it's sure a good sign that people are interested in your project, if it's the third item on Google showing up for "PHP is_array" (after the PHP site and a mirror). Congratulations, wow! And that's without "JavaScript" even in the query (its the first with that one).
I think that's entirely reasonable to avoid the configuration, though I think it could be interesting to integrate it into a separate framework. Heck, maybe I might try something with it later on because I do think it could be very useful.
Kevin van Zonneveld
on 2008-12-30 15:30:29
@ Onno marsman, T. Wild, Brett Zamir: Thanks your insightful comments. Appreciated.
-- PHP.JS: Brett you have laid out what the project is about, and a couple of your paragraphs should probably make it to the phpjs.org site. Thanks. But in this particular case, you're preaching to the choir ;) We have all invested our precious free time in this project, because we are already convinced of it's purpose (and as it turns out, even more people see even more purposes for it, I have even heard people are trying to bring our PHP power to Adobe AIR ;)
-- Configurable PHP.JS:
My vision on the project: I think we should Not try to create a Framework. Let us stick with creating a Library. Others are invited to take our (namespaced / compiled) Library and extend it in whatever way they see fit, we should focus on delivering raw PHP power, as close to the original PHP as reasonably possible. This goal should not provide the need for configuration.
If it's even possible to have a setup file for a library (and still call it that), it would over-complicate & potentially make things unstable. I side with Onno on that one. Besides: there's lower hanging fruit still to be plucked.
-- InstanceOf:
T.Wild thanks for your url http://javascript.crockford.com/remedial.html . In these ways, working on PHP.JS has helped me to get a better understanding of both languages. That's very cool. I've changed the gettype function to fix the type problems stated in your find. I also implemented (& commented) it in the is_array function.
-- is_array:
We once made the decision that PHP.JS should accept associative arrays. I still think we can not make an exception now. Having said we should mimic PHP as much as reasonably possible, I would very much like this code:
var combined;
var keys = ['0', '1', '2'];
var vals = ['a', 'b', 'c'];
combined = array_combine(keys, vals);
if (is_array(combined)) {
print_r(combined);
}
to produce:
Array
(
[0] => a
[1] => b
[2] => c
)
And not ''. I realize that it's choosing between two evils. Maybe it's because I'd rather look at it from an enabling point-of-view, but in my opinion, having it return true on objects (!= 'classes') still is the lesser evil.
-- Paragraphing: There was a bug in my blog that stopped newlines whenever a CODE block was used. Fixed.
Onno Marsman
on 2008-12-29 10:39:53
Ah thanks, now at last I can make my posts readable. Let's see if this works...
About configuration: there's the danger of a lot of discussions being settled with "let's make it configurable" and that will make a lot of things unclear. Without wanting to start a discussion about that topic, in my opinion, this is exactly where most open source PHP CMS products known to me take a wrong turn. You get a lot of imaginary spin offs only by personal preference configuration which have to be maintained, and this causes a lot of bugs: a programmer tends to find and solve a bug only with his preferable configuration.
Especially with a project like this which is generally very simple, I think we should put a lot of effort in keeping it simple. If we have to make decisions we can't all agree with: too bad. Even if I would be the only one to think something should be solved differently and therefor it wouldn't be done that way, I probably wouldn't agree on making it configurable. This would be the case in the discussion about is_array right here: it's just not important enough.
I'm not saying configuration shouldn't be there at all. There might be some cases where configuration can be a good thing, although I can't think of one right now. Anyway, I think, we shouldn't use it for settling a discussion, and only use it when there is really no alternative.
About configuration by function parameters: like you said, this is a really bad idea and shouldn't be considered an option indeed.
Of course, about all these issues, I can only speak for myself.... I wonder what Kevin has to say about all of these things. He has a lot of reading to do ;)
Brett Zamir
on 2008-12-29 01:29:54
Onno: I thought so, but you could have been just doing it as a learning exercise. But, honestly, I wasn't targeting it at you really, I just felt I had to get that off my chest. :) Sorry about that.
I don't think that configuration is making things complicated unless the default behavior is unreasonable. Although it's usually nicer to do it by passing in an argument (if you like the PHP-style that is), since we don't really have that option, I think offering a choice is convenient and allows the library to be shared more widely. Imagine, for example, just keeping your PHP functions followed by configuration setup (if you felt the need to customize) all in one file. You could just reuse that without needing to worry about it.
What do you think about the idea of adding a module property and constants?
For paragraphing, as I only discovered this last post, was to make two lines between each.
Onno Marsman
on 2008-12-28 22:46:22
Brett: I'm of course talking about this function (and some other) and not the complete library, why else would I bother to participate in any way? You're defending the need of the whole library to me: you really don't need to, I share your opinion about that obviously.
--------
The in_array function seems useful to me too when you consider the whole frame/window issue, but that's a problem I don't think I will encounter very often. And when it would return true on objects (as it does now) that whole problem wouldn't even exist, and the function would seem useless to me anyway. And that's why I'm saying I probably would never use this function. My point on configuration making things complicated remains.
------
One more question to you, Brett: could you please tell me how to post in paragraphs on this site? My posts continue to result in large ugly blobs of text.
Brett Zamir
on 2008-12-28 14:16:37
Hi Onno: Well, for this function alone it would no doubt be overkill (the OOP way), but I don't think that PHP-JS is merely useful in helping students of PHP transition to JS, though that is a good benefit.
What is useful, I think, is that PHP has defined a vocabulary for a wide range of standard processing people want to do on Strings, Arrays, etc., functions which are completely lacking in JavaScript--a language that was standardized early on, and had little time to acquire even basic utility facilities, despite it being a flexible language).
PHP provides a kind of expressive vocabulary to be able to do things, and with which many users may already be familiar with the terminology. No doubt a large part of what people like about PHP is its large number of functions.
And for is_array(), I think many experienced programmers would be glad to save themselves the trouble of having to type the same long fail-safe string over and over again that you all were discussing (to avoid the different window/frame problem).
Personally speaking, I'm more drawn to the utility (and elegance) of other functions like array_values() or array_keys(), or even in_array(). I don't want to have to write a for loop every time I need one of them or even when I can use "indexOf() !== -1", in_array() is so much more elegant. Seriously, what's wrong with saving yourself time and making your code more intelligible?
Of course, some will look down on this because either this is not the "JavaScript way" (if it's OOP, saves lines of code, and doesn't have any negative side effects, I don't see how it isn't) or because it pays homage to a language which is just too darn easy to learn and do useful things with.
 If it's useless and difficult, then it deserves praise. Or when people prefer the status quo of not having an official world auxiliary language because they think it is charming that we can't communicate with each other (or just expect that everyone should spend all of their time mastering various languages, rather than working for a global agreement to have one language (whether English, Esperanto, or whatever could garner the most support) be taught along with native languages in schools around the world). Does humanity really need scores of words for "apple" when we could settle on one language in addition to our native one? (thousands of words, I know, but I'm only talking about reducing lingua francas, not native languages) Does inter-communication need to be only for those with privilege and too much free time?
Why does a JavaScript library (that has no JavaScript standard to work from) need to start from scratch as far as terminology as well as functionality? Isn't it helpful to be able to piggy-back on something already existing?
Sorry for this diatribe (I'm not at all responding to your honest question), but this just raised the topic for me of all the maligning people do
in other discussions I've had because human beings like to lord over the "right way", and conversely, proponents of practicality are often too cowed to defend the useful albeit ordinary, while others are afraid to think for themselves and resist the impulse to second-guess oneself when everyone else is criticizing something you find useful. Criticism itself is usually such a waste of time, where we should be honestly discussing in a humble manner (like your nice polite but frank question) which way is better.
I'm doing JavaScript for full-time paid work (building Firefox extensions), and I've unabashedly been using some of these utilities. I particularly like array_unique(), trim, and Mozilla equivalents I've made for file_get_contents() and file_put_contents().
Oh, and I see I'm using your min() function too! :) Given that you found a need to write a good many lines of code for that function, do you really want to rewrite that each time you need it or give it a non-PHP name? :)
Onno Marsman
on 2008-12-28 11:13:56
Brett: Isn't this making things a bit to complicated for something that's just meant to help a PHP programmer make the step to JS? I mean: no experienced JS programmer is ever gonna use this function anyway and I don't think a not so experienced one would wanna find out how to configure something like this. I think it would even be easier and clearer to fall back to "instanceof Array" or "instanceof Object", whichever one they need.
PHP doesn't have this kind of configuration either and if we would introduce it I doubt anybody would use it.
Brett Zamir
on 2008-12-28 02:54:42
Sorry, my OOP code had a bug...Here's a fix:
function PHP_JS (config) {
this.JS = {};
for (var php_js_method in this) { // Add JS config property for all PHP-JS functions
if (typeof this[php_js_method] === 'function') {
this.JS[php_js_method] = {};
}
}
for (var method in config) {
var configObj = config[method];
this.JS[method] = configObj;
}
}
PHP_JS.prototype = {
is_array : function (mixed_var) {
if (this.JS.is_array.objectsAsArrays) {
return (mixed_var instanceof Object);
}
return mixed_var && !(mixed_var.propertyIsEnumerable('length')) && typeof mixed_var === 'object' && typeof mixed_var.length === 'number';
}
}
var PHP1 = new PHP_JS({is_array:{objectsAsArrays:true}});
var PHP2 = new PHP_JS({is_array:{objectsAsArrays:false}});
alert( PHP1.is_array({}) ); // true
alert( PHP2.is_array({}) ); // false
PHP1.JS.is_array.objectsAsArrays = false; // Can still reconfigure if needed too
PHP2.JS.is_array.objectsAsArrays = true;
alert( PHP1.is_array({}) ); // false
alert( PHP2.is_array({}) ); // true
Brett Zamir
on 2008-12-28 02:42:38
In order for PHP-JS to work as a bona-fide framework (which I think it could well become), there is a need for configurability, as seen in this discussion. And while a decision must still be made as to default behavior, I think that we can take advantages features of JavaScript which PHP does not have, in order to allow that configurability without adding additional arguments to the functions (which might have additional ones assigned by PHP in the future): adding properties to the functions themselves. (My apologies if others have suggested this.)
My suggestion is to reserve "JS" as an object for configurability. For example, one might do:
function is_array (mixed_var) {
if (arguments.callee.JS.objectsAsArrays) {
return (mixed_var instanceof Object);
}
return mixed_var && !(mixed_var.propertyIsEnumerable('length')) && typeof mixed_var === 'object' && typeof mixed_var.length === 'number';
}
is_array.JS = {};
is_array.JS.objectsAsArrays = true;
alert( is_array({}) ); // true
is_array.JS.objectsAsArrays = false;
alert( is_array({}) ); // false
The internal code would simply check for "if ({func_name}.JS.{prop_name})", (adding the empty JS object right after the function declaration) and act accordingly. I believe this could really be useful, especially for functions with no easy parallel in native JavaScript, but where the nature of JavaScript suggests different possible behaviors for the functions (or for adding other ideas PHP didn't think of).
We might even handle this in an OOP way (to more easily allow different configurations for the functions in different contexts), if the "namespace" for our PHP-JS objects were to be given by a constructor function. For example,
var PHP1 = new PHP_JS({is_array:{objectsAsArrays:true}});
var PHP2 = new PHP_JS({is_array:{objectsAsArrays:false}});
alert( PHP1.is_array({}) ); // true
alert( PHP2.is_array({}) ); // false
PHP2.JS.is_array.objectsAsArrays = true; // Can still reconfigure if needed too
alert( PHP2.is_array({}) ); // true
function PHP_JS (config) {
this.JS = {};
for (var php_js_method in this) { // Add JS config property for all PHP-JS functions
if (typeof this[php_js_method] === 'function') {
this.JS[php_js_method] = {};
}
}
for (var method in config) {
var configObj = config[method];
this.JS[method] = configObj;
}
}
PHP_JS.prototype = {
is_array : function (mixed_var) {
if (arguments.callee.JS.objectsAsArrays) {
return (mixed_var instanceof Object);
}
return mixed_var && !(mixed_var.propertyIsEnumerable('length')) && typeof mixed_var === 'object' && typeof mixed_var.length === 'number';
}
}
Whether using the OOP approach or not, your configuration questions (objectsAsArrays, functionsDisallowed, etc.) could be handled.
For either of these approaches (of adding properties to the functions or namespace object), PHP constants could be added relating to that function (thus not requiring defining every possible PHP constant or polluting the global namespace further), or meta-data could be attached relating to that function vis-a-vis PHP such as to indicate to which module it belongs (or put the constants within the module information). Thus, a property could be used to indicate to which PHP module a given function belonged (if one was not already using namespaces to do so). Then one could do things like: extension_loaded(), get_loaded_extensions(), get_extension_funcs(), and get_defined_constants(true) as these functions could reflect upon the meta-data stored for each function.
Although the following is not strictly PHP behavior since Array functions are not an extension in PHP (though we can override this with configuration as described above), we could do things like:
if (!extension_loaded('array')) {
function is_array () {
....
}
function in_array () {
....
}
....etc.
}
Onno Marsman
on 2008-12-27 23:07:02
Wow, that's really weird! I guess your find is a better implementation than "instanceof Array" then. I'm curious about what Kevin thinks about all of this now.
T.Wild
on 2008-12-27 18:21:00
To be honest, Onno, put like that I would have to agree. Better to have it return false and know why then work around it, than have something you think works but be unable to explain why it goes wrong. I still feel that closer PHP behavior should be the goal, and returning true on associative arrays [objects] does this, but I guess you are unlikely to ever get this because of the basic fact that arrays are objects. So what's my decision? I'd have to say the former, but I'm left sitting on the fence somewhat. :)
------------------------------------
Now, if this function does get converted to returning true on TRUE arrays only, when I've been looking around the internet I found this version of is array:
http://www.hunlock.com/blogs/Mastering_Javascript_Arrays#quickIDX34
function isArray(testObject) {
return testObject && !(testObject.propertyIsEnumerable('length')) && typeof testObject === 'object' && typeof testObject.length === 'number';
}
I did wonder why something like this was needed but i found an explanation on this site:
http://javascript.crockford.com/remedial.html
[value instanceof Array] will only recognize arrays that are created in the same context (or window or frame). JavaScript does not provide an infallible mechanism for distinguishing arrays from objects, so if we want to recognize arrays that are constructed in a different frame, then we need to do something more complicated.
P.S. I haven't found any real use for this outside PHP either.
Onno Marsman
on 2008-12-27 11:34:14
@T.Wild: Returning true on objects doesn't mimic PHP any better than returning false would. You're looking at it from a "when should it return true" point of view. You could also look at it from a "when should it return false" point of view. From the "return false" point of view I can't really explain the current "return true on object and array" implementation, while "return true only on arrays" can be explained, I think, from both point of views.
About finding a reliable method: I'm pretty sure there isn't one.
Ah well, I would never use this function anyway and would do it the JS way, so I won't make any more fuss about this. I just would hate to see some functions of this library slip off into a state of "behaves a little but more like PHP on some fronts but is really confusing so nobody would ever dare to use it"
T.Wild
on 2008-12-24 11:42:38
I guess I'm just going to add fuel to the fire on this but IMO what JavaScript sees as an array/object isn't the issue but what PHP would since that's what we're trying to imitate is it not?
*
I agree in this sort of situation you just don't know what an object is intended as, but i think it's still better to return true for both arrays AND objects at least until a reliable method can be found to tell the difference between an object and an 'associative array', if one exists.
Onno marsman
on 2008-12-17 22:22:54
How should I post in paragraphs?[br]
[br]
test. If this worked... never mind ;)
Onno Marsman
on 2008-12-17 22:21:21
I guess you're missing my point.
I'm saying PHP's is_array checks the type of the variable, I think so should php.js' is_array.<br><br>
I mean: think of when you would you use this function. I think it would only make sense if you'd wanna check the type of a variable.<br><br>
For functions that expect arrays it's simple: we just treat objects as arrays. Here we just don't know what to expect and there really is no way of knowing whether an object is intended as an array or not.<br><br>
Remember the post from someone that wanted to create an array syntax like this:
array(" 'first' => 'kevin' ", " 'last' => 'Zonnevelt' " );
You agreed with me it would weird to create a new syntax that is not really the same as php, while js already has a syntax that is not really the same as php.<br>
I guess you could say the same about this issue: why create a new definition of what an array is that is not really the same as in php, while js already has a definition of what an array is that is not really the same as in php.
Kevin van Zonneveld
on 2008-12-17 12:43:45
@ Onno Marsman: Yes, "associative array in JS is an object so it's not an array". But we're trying to implement PHP's is_array, and not JavaScript's definition of it.
Saying that PHP.JS should support associative arrays (objects), and making an exception for the most profound function in this category: is_array, is not making any sense.
What does make sense to me, is your argument that an array of functions is also an array. Thus scanning for functions to make a slight distinction between 'class-like-objects' and 'array-like-objects', can not be achieved that way.
Insert insightfull comment here ;)
Onno Marsman
on 2008-12-10 18:52:33
And of course the current implementation is still the same as the following:
function is_array( mixed_var ) {
return (mixed_var instanceof Object);
}
Onno Marsman
on 2008-12-10 18:50:25
You know I agree with you that php.js should support associative arrays. But I stay with my argument that is_array should return whether a variable is an array. An associative array in JS is an object so it's not an array.
About your example: I would argue what you are suggesting: check for false.
About scanning for functions: that results in some weird situations. We'd also have to change the implementation of is_object and it could theoretically result in situations where is_array returns true on a variable which after a few manipulations returns false. Furthermore: what to do with something like this:
var a = [function() { }];
Is this an object or an array, or both?
Or what if I would really just want to store some functions in an associative array? It is possible.
What I'm saying that the boundary just wouldn't be clear and that would just result in people not trusting these functions.
We should keep it simple: is_array is about type checking and returns true when it is an array. It's a very clear boundary, it is much easier to explain, defend and implement. Of course that doesn't mean we shouldn't support associative arrays.
Kevin van Zonneveld
on 2008-12-10 17:10:08
@ Onno Marsman: Thanks for your input, the thought crossed my mind as well. Well, this is going to be dirty, so please buckle up Onno.. Please bear the following code:
var myResult, input = {'firstname': 'Onno', 'surname': 'Marsman'};
myResult = filterData(input); // Will only return array (object) on success
if (!is_array(myResult)) {
alert('Data could not be filtered!');
} else {
for (key in myResult) {
// process data
}
}
You can bet that people are going to use is_array in such ways.
Though you may argue that people 'd better use:
if (false === myResult) {
.. to check if filterData() worked correctly - and I would have agree with you, that doesn't mean that I want the first code to fail in php.js, just because we say that's not good coding habit. php.js isn't foolproof but we should try to make it whenever we face decisions like this.
Although it may even mean we have to scan for functions within objects to distinct them from associative arrays, I still think we have to stick with our idea of supporting associative arrays, and not make exceptions in this function.
I really do agree that is_object & is_array should differ though. So I will work on the function scanning. If you have any ideas on that (or still don't agree with me) please let me know.
Onno Marsman
on 2008-12-04 21:31:07
Isn't this the same as
return (mixed_var instanceof Object);
or
return (typeof mixed_var=='object');
?
Also: If mixed_var is an object which has functions then I don't think this function should return true. We could check for that, but in turn it makes you wonder what to do with the implementation of is_object. Does an object needs to have a function? I don't think so. This would mean that is_object(v) and is_array(v) can both be true at the same time, that doesn't make any sense when you think PHP.
In my opinion we're taking this to far. I think is_array is clearly meant to only check the type of the variable. I don't think we'll miss out an anything if it doesn't return true on associative arrays. In JS they just aren't arrays but objects so therefor imho for associative arrays is_array should return false and is_object should return true.
Kevin van Zonneveld
on 2008-12-01 08:34:12
@ Manish: In php.js, javascript objects are indeed like php associative arrays
Manish
on 2008-11-25 18:41:59
function is_array(input)
{
if( typeof input == 'object' && input instanceof Array )
{
return true;
}
return false;
}
Kevin van Zonneveld
on 2008-07-18 08:59:25
I'm nowhere near as good as I would like to be. But I'm trying. Glad you find these pages useful though.
Marce
on 2008-07-07 01:32:00
Tranks kevin, this function is good :), you are very good programer.
Mat
on 2008-06-19 11:07:36
Great!
Kevin van Zonneveld
on 2008-01-04 13:51:40
@ Andrey: Thank you I've updated the function!
Andrey
on 2008-01-04 09:21:14
I found a more simple sample:
function is_array(a) {
return (a instanceof Array);
}
I. Stan
on 2008-01-04 08:22:01
Wouldn't this be better or is it not cross browser? I tested it successfully in IE6, FF2, Opera9 and Safari for Windows.
function is_array(a) {
return (a.constructor === Array) ? true : false;
}


|
Figure 1
|
Nanowire twin superlattice. (a) BF TEM image of a typical TS ... |
|
Figure 2
|
Twin superlattice phonon modes and hexagonal symmetry. (a) C ... |
|
Figure 3
|
Tunability of the phononic properties in twin superlattices. ... |
|
Figure 4
|
Dependence of the TSL phonon modes on the period lengths. (a ... |
|
Figure 5
|
Dependence of TO and E 2 H modes on TSL period. (a) Calculat ... |


The Economic Times is an Indian English-language business-focused daily newspaper. It is owned by The Times Group . The Economic Times began publication in 1961. As of 2012, it is the world's second-most widely read English-language business newspaper, after The Wall Street Journal, with a readership of over 800,000


Already Read
- Slaughterhouse Five
- The 3 body problem. (book 1)
- Thinking, Fast and Slow
- Siddhartha by Hermann Hess - not bad, good story of the buddha, recommended by joe pontes.
- Pastwatch - interesting take on an alternate history of the world if Columbus acted differently
- Kings of the Wyld. (Schuft recommendation, so of course it was good) - fun fantasy book, narrator voice was hard to get used to though
- The birth of plenty – good, but you can just read the 4 bullet summary of it. Wealth happened to humans once we had property rights, rationality, something something …
- Soul of New Machine by Tracy Kidder (jeff recommended) - Good story written in 1981 about a team in Data General that built a 32 bit computer against odds. Really paints the landscape of Digital/DEC/Massacusetts early computer companies.
- Winterdance - AWESOME. 5 stars! Hilarious, exciting story of the iditerod.
- Ender's Game, then Ender's Shadow - top 5 favorite books of all time
- Accelerando. Nope. Too boring, didnt finish it.
- Old Man's War by scalsi – good sci fi, felt like a short story but long, really enjoyed it
- Atomic Habits - Frank recommended – 5 stars! Summarizes TAP and CFAR tricks well.
- Lord of the Flies - meh, narrator was boring. I remember it being a more interesting story when first reading it in high school. Story was so-so the 2nd time around.
- Scythe - AWESOME. 5 stars!
- Thunderhead and The Toll. Follow-up to Scythe. Frickin’ amazing.
- The Happiness Hypothesis by Jonathan Haidt - speaker bored me, read a summary of the key bullet points of each chapter some day to refresh the points.
- A Fire Upon the Deep - meh
- Beneath a Scarlet Sky – 1939 italy historical fiction. Outstanding. Teenagers should read it.
- The Achievement Trap, recommended by Iana. Decent and quick read.
- Snowcrash - classic sci-fi, pretty good, holds up
- Girl on the Train (boring and too long, i didnt care about any of the characters)
- Lessons of History by Durant (this book is terrible)
- 3 Body Problem (book 1 of 3) - pretty interesting
- Kurt Vonnegut Cats Cradle - A masterpiece.
- Homo Deus
- Sapiens
- Scale by Geoffrey West. Just read a summary online, or listen to Sam Harris’ podcast with him. The book is too long, the author spends too much time name-dropping and propping himself up. Interesting scaling relationships exist in the world. Filled with interesting trivia, though.
- Algorithms to Live By. Part of Book Club - really good! approachable content.
- Straight from the Gut by Jack Welch. Fun to listen to. Really paints the picture of ‘80's corporate politics.
- Atlas Shrugged
- Niall ferguson the ascent of money.
- Washington and Hamilton. Increased my appreciation for Washington's character in the early formation of the country.
- History of Warfare by John Keegan. Kind of long.
- The art of explanation. Decent.
- The other side of history.
- A Short History of Nearly Everything by Bill Bryson. Fun!
- History of the World in 6 Glasses. Fun!
- Focusing audiobook by Eugene Gendlin. I tried the techniques, but probably not enough, so I didn't get value from it. Other than learning that most psychotherapy is bunk.
- Art of War by Sun Tzu. People rave about it. I thought it was OK. Some interesting points about warfare, mostly just fascinating how it has held up all these years.
- Guns Germs Steel Jared Diamond. Awesome, awesome, awesome. 5 stars! Required reading at Cornell.
- Charisma Myth (5 stars, read again)
- Peter Singer's TED talk on “The why and how of effective altruism”
- Mythical Man Month, Fred Brooks
- Becoming a Technical Leader, Gerald Weinberg
- Worm. 5 Stars! Frickin’ amazing.
- Pact. Not as good as Worm.
And the best book of all time: Harry Potter and the Methods of Rationality


Mondriaanlike painting on demand
This is a little project I'm working on to teach myself working with D3 and generated images.
Every time you refresh the screen a brand new painting is generated. You can do with it whatever you like, as long as you credit this page or keep the signature in the image.
Oh, and don't forget to read the page title ;-/


| I l@ve RuBoard |
12.7 Sending Files to Clients and ServersIt's time to explain a bit of HTML code we've been keeping in the shadows. Did you notice those hyperlinks on the language selector example's main page for showing the CGI script's source code? Normally, we can't see such script source code, because accessing a CGI script makes it execute (we can see only its HTML output, generated to make the new page). The script in Example 12-23, referenced by a hyperlink in the main language.html page, works around that by opening the source file and sending its text as part of the HTML response. The text is marked with
 as pre-formatted text, and escaped for transmission inside HTML with cgi.escape. Example 12-23. PP2E\Internet\Cgi-Web\Basics\languages-src.cgi#!/usr/bin/python ################################################################# # Display languages.cgi script code without running it. ################################################################# import cgi filename = 'languages.cgi' print "Content-type: text/html\n" # wrap up in html print "<TITLE>Languages</TITLE>" print "
Source code: '%s'
" % filename print '

' print cgi.escape(open(filename).read( )) print '

' When we visit this script on the Web via the hyperlink or a manually typed URL, the script delivers a response to the client that includes the text of the CGI script source file. It appears as in Figure 12-25. Figure 12-25. Source code viewer pageNote that here, too, it's crucial to format the text of the file with cgi.escape, because it is embedded in the HTML code of the reply. If we don't, any characters in the text that mean something in HTML code are interpreted as HTML tags. For example, the C++ < operator character within this file's text may yield bizarre results if not properly escaped. The cgi.escape utility converts it to the standard sequence < for safe embedding. 12.7.1 Displaying Arbitrary Server Files on the ClientAlmost immediately after writing the languages source code viewer script in the previous example, it occurred to me that it wouldn't be much more work, and would be much more useful, to write a generic version -- one that could use a passed-in filename to display any file on the site. It's a straightforward mutation on the server side; we merely need to allow a filename to be passed in as an input. The getfile.cgi Python script in Example 12-24 implements this generalization. It assumes the filename is either typed into a web page form or appended to the end of the URL as a parameter. Remember that Python's cgi module handles both cases transparently, so there is no code in this script that notices any difference. Example 12-24. PP2E\Internet\Cgi-Web\Basics\getfile.cgi#!/usr/bin/python ################################################################# # Display any cgi (or other) server-side file without running it. # The filename can be passed in a URL param or form field; e.g., # http://server/~lutz/Basics/getfile.cgi?filename=somefile.cgi. # Users can cut-and-paste or "View source" to save file locally. # On IE, running the text/plain version (formatted=0) sometimes # pops up Notepad, but end-of-lines are not always in DOS format; # Netscape shows the text correctly in the browser page instead. # Sending the file in text/html mode works on both browsers--text # is displayed in the browser response page correctly. We also # check the filename here to try to avoid showing private files; # this may or may not prevent access to such files in general. ################################################################# import cgi, os, sys formatted = 1 # 1=wrap text in html privates = ['../PyMailCgi/secret.py'] # don't show these html = """ <title>Getfile response</title>
Source code for: '%s'

%s

""" def restricted(filename): for path in privates: if os.path.samefile(path, filename): # unify all paths by os.stat return 1 # else returns None=false try: form = cgi.FieldStorage( ) filename = form['filename'].value # url param or form field except: filename = 'getfile.cgi' # else default filename try: assert not restricted(filename) # load unless private filetext = open(filename).read( ) except AssertionError: filetext = '(File access denied)' except: filetext = '(Error opening file: %s)' % sys.exc_value if not formatted: print "Content-type: text/plain\n" # send plain text print filetext # works on NS, not IE else: print "Content-type: text/html\n" # wrap up in html print html % (filename, cgi.escape(filetext)) This Python server-side script simply extracts the filename from the parsed CGI inputs object, and reads and prints the text of the file to send it to the client browser. Depending on the formatted global variable setting, it either sends the file in plain text mode (using text/plain in the response header) or wrapped up in an HTML page definition (text/html). Either mode (and others) works in general under most browsers, but Internet Explorer doesn't handle the plain text mode as gracefully as Netscape -- during testing, it popped up the Notepad text editor to view the downloaded text, but end-of-line characters in Unix format made the file appear as one long line. (Netscape instead displays the text correctly in the body of the response web page itself.) HTML display mode works more portably with current browsers. More on this script's restricted file logic in a moment. Let's launch this script by typing its URL at the top of a browser, along with a desired filename appended after the script's name. Figure 12-26 shows the page we get by visiting this URL: http://starship.python.net/~lutz/Basics/getfile.cgi?filename=languages-src.cgi Figure 12-26. Generic source code viewer pageThe body of this page shows the text of the server-side file whose name we passed at the end of the URL; once it arrives, we can view its text, cut-and-paste to save it in a file on the client, and so on. In fact, now that we have this generalized source code viewer, we could replace the hyperlink to script languages-src.cgi in language.html, with a URL of this form: http://starship.python.net/~lutz/Basics/getfile.cgi?filename=languages.cgi For illustration purposes, the main HTML page in Example 12-16 has links both to the original source code display script, as well as to the previous URL (less the server and directory paths, since the HTML file and getfile script live in the same place). Really, URLs like these are direct calls (albeit, across the Web) to our Python script, with filename parameters passed explicitly. As we've seen, parameters passed in URLs are treated the same as field inputs in forms; for convenience, let's also write a simple web page that allows the desired file to be typed directly into a form, as shown in Example 12-25. Example 12-25. PP2E\Internet\Cgi-Web\Basics\getfile.html<title>Getfile: download page</title>  <form method=get action="getfile.cgi">
Type name of server file to be viewed

<input type=text size=50 name=filename>
<input type=submit value=Download> </form>
View script code  Figure 12-27 shows the page we receive when we visit this file's URL. We need to type only the filename in this page, not the full CGI script address. Figure 12-27. source code viewer selection pageWhen we press this page's Download button to submit the form, the filename is transmitted to the server, and we get back the same page as before, when the filename was appended to the URL (see Figure 12-26). In fact, the filename will be appended to the URL here, too; the get method in the form's HTML instructs the browser to append the filename to the URL, exactly as if we had done so manually. It shows up at the end of the URL in the response page's address field, even though we really typed it into a form.[13]
<IP_ADDRESS> Handling private files and errorsAs long as CGI scripts have permission to open the desired server-side file, this script can be used to view and locally save any file on the server. For instance, Figure 12-28 shows the page we're served after asking for file path ../PyMailCgi/index.html -- an HTML text file in another application's subdirectory, nested within the parent directory of this script.[14] Users can specify both relative and absolute paths to reach a file -- any path syntax the server understands will do.
Figure 12-28. Viewing files with relative pathsMore generally, this script will display any file path for which the user "nobody" (the username under which CGI scripts usually run) has read access. Just about every server-side file used in web applications will, or else they wouldn't be accessible from browsers in the first place. That makes for a flexible tool, but it's also potentially dangerous. What if we don't want users to be able to view some files on the server? For example, in the next chapter, we will implement an encryption module for email account passwords. Allowing users to view that module's source code would make encrypted passwords shipped over the Net much more vulnerable to cracking. To minimize this potential, the getfile script keeps a list, privates, of restricted filenames, and uses the os.path.samefile built-in to check if a requested filename path points to one of the names on privates. The samefile call checks to see if the os.stat built-in returns the same identifying information for both file paths; because of that, pathnames that look different syntactically but reference the same file are treated as identical. For example, on my server, the following paths to the encryptor module are different strings, but yield a true result from os.path.samefile: ../PyMailCgi/secret.py /home/crew/lutz/public_html/PyMailCgi/secret.py Accessing either path form generates an error page like that in Figure 12-29. Figure 12-29. Accessing private filesNotice that bona fide file errors are handled differently. Permission problems and accesses to nonexistent files, for example, are trapped by a different exception handler clause, and display the exception's message to give additional context. Figure 12-30 shows one such error page. Figure 12-30. File errors displayAs a general rule of thumb, file-processing exceptions should always be reported in detail, especially during script debugging. If we catch such exceptions in our scripts, it's up to us to display the details (assigning sys.stderr to sys.stdout won't help if Python doesn't print an error message). The current exception's type, data, and traceback objects are always available in the sys module for manual display.
12.7.2 Uploading Client Files to the ServerThe getfile script lets us view server files on the client, but in some sense, it is a general-purpose file download tool. Although not as direct as fetching a file by FTP or over raw sockets, it serves similar purposes. Users of the script can either cut-and-paste the displayed code right off the web page or use their browser's View Source option to view and cut. But what about going the other way -- uploading a file from the client machine to the server? As we saw in the last chapter, that is easy enough to accomplish with a client-side script that uses Python's FTP support module. Yet such a solution doesn't really apply in the context of a web browser; we can't usually ask all of our program's clients to start up a Python FTP script in another window to accomplish an upload. Moreover, there is no simple way for the server-side script to request the upload explicitly, unless there happens to be an FTP server running on the client machine (not at all the usual case). So is there no way to write a web-based program that lets its users upload files to a common server? In fact, there is, though it has more to do with HTML than with Python itself. HTML <input> tags also support a type=file option, which produces an input field, along with a button that pops up a file-selection dialog. The name of the client-side file to be uploaded can either be typed into the control, or selected with the pop-up dialog. The HTML page file in Example 12-26 defines a page that allows any client-side file to be selected and uploaded to the server-side script named in the form's action option. Example 12-26. PP2E\Internet\Cgi-Web\Basics\putfile.html<title>Putfile: upload page</title>  <form enctype="multipart/form-data" method=post action="putfile.cgi">
Select client file to be uploaded

<input type=file size=50 name=clientfile>
<input type=submit value=Upload> </form>
View script code  One constraint worth noting: forms that use file type inputs must also specify a multipart/form-data encoding type and the post submission method, as shown in this file; get style URLs don't work for uploading files. When we visit this page, the page shown in Figure 12-31 is delivered. Pressing its Browse button opens a file-selection dialog, while Upload sends the file. Figure 12-31. File upload selection pageOn the client side, when we press this page's Upload button, the browser opens and reads the selected file, and packages its contents with the rest of the form's input fields (if any). When this information reaches the server, the Python script named in the form action tag is run as always, as seen in Example 12-27. Example 12-27. PP2E\Internet\Cgi-Web\Basics\putfile.cgi#!/usr/bin/python ####################################################### # extract file uploaded by http from web browser; # users visit putfile.html to get the upload form # page, which then triggers this script on server; # note: this is very powerful, and very dangerous: # you will usually want to check the filename, etc. # this will only work if file or dir is writeable; # a unix 'chmod 777 uploads' command may suffice; # file path names arrive in client's path format; ####################################################### import cgi, string, os, sys import posixpath, dospath, macpath # for client paths debugmode = 0 # 1=print form info loadtextauto = 0 # 1=read file at once uploaddir = './uploads' # dir to store files sys.stderr = sys.stdout # show error msgs form = cgi.FieldStorage( ) # parse form data print "Content-type: text/html\n" # with blank line if debugmode: cgi.print_form(form) # print form fields # html templates html = """ <title>Putfile response page</title>
Putfile response page
 %s """ goodhtml = html % """
Your file, '%s', has been saved on the server as '%s'.
An echo of the file's contents received and saved appears below.

%s

 """ # process form data def splitpath(origpath): # get file at end for pathmodule in [posixpath, dospath, macpath]: # try all clients basename = pathmodule.split(origpath)[1] # may be any server if basename != origpath: return basename # lets spaces pass return origpath # failed or no dirs def saveonserver(fileinfo): # use file input form data basename = splitpath(fileinfo.filename) # name without dir path srvrname = os.path.join(uploaddir, basename) # store in a dir if set if loadtextauto: filetext = fileinfo.value # reads text into string open(srvrname, 'w').write(filetext) # save in server file else: srvrfile = open(srvrname, 'w') # else read line by line numlines, filetext = 0, '' # e.g., for huge files while 1: line = fileinfo.file.readline( ) if not line: break srvrfile.write(line) filetext = filetext + line numlines = numlines + 1 filetext = ('[Lines=%d]\n' % numlines) + filetext os.chmod(srvrname, 0666) # make writeable: owned by 'nobody' return filetext, srvrname def main( ): if not form.has_key('clientfile'): print html % "Error: no file was received" elif not form['clientfile'].filename: print html % "Error: filename is missing" else: fileinfo = form['clientfile'] try: filetext, srvrname = saveonserver(fileinfo) except: errmsg = '
Error

%s
%s' % (sys.exc_type, sys.exc_value) print html % errmsg else: print goodhtml % (cgi.escape(fileinfo.filename), cgi.escape(srvrname), cgi.escape(filetext)) main( ) Within this script, the Python-specific interfaces for handling uploaded files are employed. They aren't much different, really; the file comes into the script as an entry in the parsed form object returned by cgi.FieldStorage as usual; its key is clientfile, the input control's name in the HTML page's code. This time, though, the entry has additional attributes for the file's name on the client. Moreover, accessing the value attribute of an uploaded file input object will automatically read the file's contents all at once into a string on the server. For very large files, we can instead read line by line (or in chunks of bytes). For illustration purposes, the script implements either scheme: based on the setting of the loadtextauto global variable, it either asks for the file contents as a string, or reads it line by line.[16] In general, the CGI module gives us back objects with the following attributes for file upload controls:
There are additional attributes not used by our script. Files represent a third input field object; as we've also seen, the value attribute is a string for simple input fields, and we may receive a list of objects for multiple-selection controls. For uploads to be saved on the server, CGI scripts (run by user "nobody") must have write access to the enclosing directory if the file doesn't yet exist, or to the file itself if it does. To help isolate uploads, the script stores all uploads in whatever server directory is named in the uploaddir global. On my site's Linux server, I had to give this directory a mode of 777 (universal read/write/execute permissions) with chmod to make uploads work in general. Your mileage may vary, but be sure to check permissions if this script fails. The script also calls os.chmod to set the permission on the server file such that it can be read and written by everyone. If created anew by an upload, the file's owner will be "nobody," which means anyone out in cyberspace can view and upload the file. On my server, though, the file will also be only writable by user "nobody" by default, which might be inconvenient when it comes time to change that file outside the Web (the degree of pain can vary per operation).
If both client and server do their parts, the CGI script presents us with the response page shown in Figure 12-32, after it has stored the contents of the client file in a new or existing file on the server. For verification, the response gives the client and server file paths, as well as an echo of the uploaded file with a line count (in line-by-line reader mode). Figure 12-32. Putfile response pageIncidentally, we can also verify the upload with the getfile program we wrote in the prior section. Simply access the selection page to type the pathname of the file on the server, as shown in Figure 12-33. Figure 12-33. Verifying putfile with getfile -- selectionAssuming uploading the file was successful, Figure 12-34 shows the resulting viewer page we will obtain. Since user "nobody" (CGI scripts) was able to write the file, "nobody" should be able to view it as well. Figure 12-34. Verifying putfile with getfile -- responseNotice the URL in this page's address field -- the browser translated the / character we typed into the selection page to a %2F hexadecimal escape code before adding it to the end of the URL as a parameter. We met URL escape codes like this earlier in this chapter. In this case, the browser did the translation for us, but the end result is as if we had manually called one of the urllib quoting functions on the file path string. Technically, the %2F escape code here represents the standard URL translation for non-ASCII characters, under the default encoding scheme browsers employ. Spaces are usually translated to + characters as well. We can often get away without manually translating most non-ASCII characters when sending paths explicitly (in typed URLs). But as we saw earlier, we sometimes need to be careful to escape characters (e.g., &) that have special meaning within URL strings with urllib tools. <IP_ADDRESS> Handling client path formatsIn the end, the putfile.cgi script stores the uploaded file on the server, within a hardcoded uploaddir directory, under the filename at the end of the file's path on the client (i.e., less its client-side directory path). Notice, though, that the splitpath function in this script needs to do extra work to extract the base name of the file on the right. Browsers send up the filename in the directory path format used on the client machine; this path format may not be the same as that used on the server where the CGI script runs. The standard way to split up paths, os.path.split, knows how to extract the base name, but only recognizes path separator characters used on the platform it is running on. That is, if we run this CGI script on a Unix machine, os.path.split chops up paths around a / separator. If a user uploads from a DOS or Windows machine, however, the separator in the passed filename is \, not /. Browsers running on a Macintosh may send a path that is more different still. To handle client paths generically, this script imports platform-specific, path-processing modules from the Python library for each client it wishes to support, and tries to split the path with each until a filename on the right is found. For instance, posixpath handles paths sent from Unix-style platforms, and dospath recognizes DOS and Windows client paths. We usually don't import these modules directly since os.path.split is automatically loaded with the correct one for the underlying platform; but in this case, we need to be specific since the path comes from another machine. Note that we could have instead coded the path splitter logic like this to avoid some split calls: def splitpath(origpath): # get name at end basename = os.path.split(origpath)[1] # try server paths if basename == origpath: # didn't change it? if '\\' in origpath: basename = string.split(origpath, '\\')[-1] # try dos clients elif '/' in origpath: basename = string.split(origpath, '/')[-1] # try unix clients return basename But this alternative version may fail for some path formats (e.g., DOS paths with a drive but no backslashes). As is, both options waste time if the filename is already a base name (i.e., has no directory paths on the left), but we need to allow for the more complex cases generically. This upload script works as planned, but a few caveats are worth pointing out before we close the book on this example:
If you run into any of these limitations, you will have crossed over into the domain of suggested exercises. 12.7.3 More Than One Way to Push Bits Over the NetFinally, let's discuss some context. We've seen three getfile scripts at this point in the book. The one in this chapter is different than the other two we wrote in earlier chapters, but it accomplishes a similar goal:
The CGI- and HTTP-based putfile script here is also different from the FTP-based putfile in the last chapter, but it can be considered an alternative to both socket and FTP uploads. To help underscore the distinctions, Figure 12-35 and Figure 12-36 show the new putfile uploading the original socket-based getfile.[17]
Figure 12-35. A new putfile with the socket-based getfile uploadedReally, the getfile CGI script in this chapter simply displays files only, but can be considered a download tool when augmented with cut-and-paste operations in a web browser. Figures Figure 12-37 and Figure 12-38 show the CGI getfile displaying the uploaded socket-based getfile. Figure 12-36. A new putfile with the socket-based getfileFigure 12-37. A new getfile with the socket-based getfileFigure 12-38. A new getfile with the socket-based getfile downloadedThe point to notice here is that there are a variety of ways to ship files around the Internet -- sockets, FTP, and HTTP (web pages) can all move files between computers. Technically speaking, we can transfer files with other techniques and protocols, too -- POP email, NNTP news, and so on. Each technique has unique properties but does similar work in the end: moving bits over the Net. All ultimately run over sockets on a particular port, but protocols like FTP add additional structure to the socket layer, and application models like CGI add both structure and programmability. |
| I l@ve RuBoard |


nbdev + GitHub Codespaces: A New Literate Programming Environment
Today, we are going to show you how to set up a literate programming environment, allowing you to use an IDE (VS Code) and an interactive computing environment (Jupyter), without leaving your browser, for free, in under 5 minutes. You’ll even see how VSCode and Jupyter work together automatically! But first, what is literate programming? And how did I go from skeptic to a zealot of literate programming?
Introduction
Literate programming is a programming paradigm introduced by Donald Knuth in which a computer program is given an explanation of its logic in a natural language, such as English, interspersed with snippets of macros and traditional source code, from which compilable source code can be generated. According to Knuth, literate programming provides higher-quality programs by forcing programmers to explicitly state the thoughts behind the program. This process makes poorly thought-out design decisions more obvious. Knuth also claims that literate programming provides a first-rate documentation system, which is not an add-on, but is grown naturally in the process of exposition of one’s thoughts during a program’s creation. 1
When I first learned about literate programming, I was quite skeptical. For the longest time, I had wrongly equated Jupyter notebooks with literate programming. Indeed, Jupyter is a brilliant interactive computing system, which was awarded the Association of Computing Machinery (ACM) Software System Award, and is loved by many developers. However, Jupyter falls short of the literate programming paradigm for the following reasons:2
- It can be difficult to compile source code from notebooks.
- It can be difficult to diff and use version control with notebooks because they are not stored in plain text.
- It is not clear how to automatically generate documentation from notebooks.
- It is not clear how to properly run tests suites when writing code in notebooks.
My skepticism quickly evaporated when I began using nbdev, a project that extends notebooks to complete the literate programming ideal. I spent a month, full time, using nbdev while contributing to the python library fastcore, and can report that Donald Knuth was definitely onto something. The process of writing prose and tests alongside code forced me to deeply understand why the code does what it does, and to think deeply about its design. Furthermore, the reduced cognitive load and speed of iteration of having documentation, code, and tests in one location boosted my productivity to levels I have never before experienced as a software developer. Furthermore, I found that developing this way bolstered collaboration such that code reviews not only happened faster but were more meaningful. In short, nbdev may be the most profound productivity tool I have ever used.
As a teaser, look how easy it is to instantiate this literate programming environment, which includes a notebook, a docs site and an IDE with all dependencies pre-installed! :point_down:
{% include video.html url=“https://github.com/machine-learning-apps/demo-videos/raw/master/codespaces-nbdev/e2e_small.mp4” %}
Features of nbdev
As discussed in the docs, nbdev provides the following features:
- Searchable, hyperlinked documentation, which can be automatically hosted on GitHub Pages for free.
- Python modules, following best practices such as automatically defining
__all__
with your exported functions, classes, and variables. - Pip and Conda installers.
- Tests defined directly in notebooks which run in parallel. This testing system has been thoroughly tested with GitHub Actions.
- Navigate and edit your code in a standard text editor or IDE, and export any changes automatically back into your notebooks.
Since you are in a notebook, you can also add charts, text, links, images, videos, etc, that are included automatically in the documentation of your library, along with standardized documentation generated automatically from your code. This site is an example of docs generated automatically by nbdev.
GitHub Codespaces
Thanks to Conda and nbdev_template, setting up a development environment with nbdev is far easier than it used to be. However, we realized it could be even easier, thanks to a new GitHub product called Codespaces.
- An environment that has files from the repository mounted into the environment, along with your GitHub credentials.
- A development environment with dependencies pre-installed, backed by Docker.
- The ability to serve additional applications on arbitrary ports. For nbdev, we serve a Jupyter notebook server as well as a Jekyll based documentation site.
- A shared file system, which facilitates editing code in one browser tab and rendering the results in another.
- … and more.
Codespaces enables developers to immediately participate in a project without wasting time on DevOps or complicated setup steps. Most importantly, CodeSpaces with nbdev allows developers to quickly get started with creating their own software with literate programming.
A demo of nbdev + Codespaces
This demo uses the project fastai/fastcore, which was built with nbdev, as an example. First, we can navigate to this repo and launch a Codespace:
{% include video.html url=“https://github.com/machine-learning-apps/demo-videos/raw/master/codespaces-nbdev/1_open.mp4” %}
If you are launching a fresh Codespace, it may take several minutes to set up. Once the environment is ready, we can verify that all dependencies we want are installed (in this case fastcore
and nbdev
):
{% include video.html url=“https://github.com/machine-learning-apps/demo-videos/raw/master/codespaces-nbdev/2_verify.mp4” %}
Additionally, we can serve an arbitrary number of applications on user-specified ports, which we can open through VSCode as shown below:
{% include video.html url=“https://github.com/machine-learning-apps/demo-videos/raw/master/codespaces-nbdev/3_nb_small.mp4” %}
In this case, these applications are a notebook and docs site. Changes to a notebook are reflected immediately in the data docs. Furthermore, we can use the cli command nbdev_build_lib
to sync our notebooks with python modules. This functionality is shown below:
{% include video.html url=“https://github.com/machine-learning-apps/demo-videos/raw/master/codespaces-nbdev/4_reload_small.mp4” %}
This is amazing! With a click of a button, I was able to:
- Launch an IDE with all dependencies pre-installed.
- Launch two additional applications: a Jupyter Notebook server on port 8080 and a docs site on port 4000.
- Automatically update the docs and modules every time I make a change to a Jupyter notebook.
This is just the tip of the iceberg. There are additional utilities for writing and executing tests, diffing notebooks, special flags for hiding, showing, and collapsing cells in the generated docs, as well as git hooks for automation. This and more functionality is covered in the nbdev docs.
Give It A Try For Yourself
To try out nbdev yourself, take this tutorial, which will walk you through everything you need to know. The tutorial also shows you how to use a repository template with the configuration files necessary to enable Codespaces with nbdev.
You Can Write Blogs With Notebooks, Too!
This blog post was written in fastpages which is also built on nbdev! We recommend fastpages if you want an easy way to blog with Jupyter notebooks.
Additional Resources
- The GitHub Codepaces site.
- The official docs for Codespaces.
- The nbdev docs.
- The nbdev GitHub repo.
- fastpages: The project used to write this blog.
- The GitHub repo fastai/fastcore, which is what we used in this blog post as an example.
Footnotes
Wikipedia article: Literate Programming↩
This is not a criticism of Jupyter. Jupyter doesn’t claim to be a full literate programming system. However, people can sometimes (unfairly) judge Jupyter according to this criteria.↩


--- layout: post title: HTML - How do I disable text selection with CSS or JavaScript? - Stack Overflow date: '2020-03-03T23:41:00.001+05:30' author: Sahil Rajput tags: modified_time: '2020-03-03T23:41:51.778+05:30' blogger_id: tag:blogger.com,1999:blog-5250005448924290719.post-4680009382304249715 blogger_orig_url: https://www.jaadujinn.ml/2020/03/html-how-do-i-disable-text-selection.html ---


| Number of Classes | Line Coverage | Mutation Coverage |
|---|---|---|
| 12 | 33% | 23% |
| Name | Line Coverage | Mutation Coverage |
|---|---|---|
| AbstractDateTime.java | 41% |
45% |
| AbstractDuration.java | 5% |
0% |
| AbstractInstant.java | 26% |
25% |
| AbstractInterval.java | 9% |
7% |
| AbstractPartial.java | 35% |
32% |
| AbstractPeriod.java | 53% |
43% |
| BaseDateTime.java | 90% |
100% |
| BaseDuration.java | 14% |
8% |
| BaseInterval.java | 20% |
14% |
| BasePartial.java | 53% |
23% |
| BasePeriod.java | 46% |
43% |
| BaseSingleFieldPeriod.java | 0% |
0% |


[]. OpenUrl binding mutations interactions CrossRef affinity data protein-protein SKEMPI Web mutant mutation Science protein Abstract kcal.mol FREE Text single (e.g. double database entries interaction using Moal PDB changes proteins Protein affinities group Fernandez-Recio energy human interface Biol. Biol., Chem., homologous receptor reported Binding Feb Mol. ]), according design effects experimental including number structural Jul Nov Proteins, complex interactions, interactions. mutants order residues studies Bates Bioinformatics, common sequence use Acad. Affinity Aug Jan Natl. Proc. Schreiber Sci. Structural U.S.A., Zhang benchmark cases classified computational correspond different entry files kinetics method new residue residues, sign structure used Acids Apr Bonvin Chem. Data Energy Figure Free Lee Mar Michael Nucleic Oct Protein-Protein Res., SKEMPI. Torchala Weng adenovirus alanine antibody biases chains contain cycles cycles, data, destabilising higher investigations location methods mutants, mutation, mutations, ranging rate recognition regions stabilising study thermodynamic wild-type Baker Comput. Garcia Interactions Jimenez-Garcia Jun Ras Sci., Vreven Wang amino analysis antibodies atom available, background buried category. cell checks clusters derived effect energies free include inhibition inhibitory instance, involve kinetic limit literature manually molecular non-hydrogen numbering parameters point proteins, range reduce relationships sites sources specificity systematic text thermodynamics these, triple viral web Δlog −),


CosmoGRaPH
v0.0
Main Page
Classes
Files
Class List
Class Hierarchy
Class Members
Class Hierarchy
Go to the textual class hierarchy


Ocean [ar43], ocean, in The Inner Sea
Last updated Turn #143
Ocean [ar43], ocean, in The Inner Sea
------------------------------------------------------------------------
15: Pleasure Sloop [v5n], ship, 30 hulls, 1 rowing port, 90 sails, arrived
15: from Ocean [ar44], owner:
15: Dorothy [v1b], Pen, with one worker, 94 sailors
15: Apollo [b5e], Imperial Empire, with 11 workers, six sailors, 63 lt.
15: xbowmen, accompanied by:
15: Lutra [a4w], Imperial Empire, with 12 paladins, 24 pikemen
15: Lungor [y4r], Imperial Empire
15: Hera [g3f], Imperial Empire, with five soldiers, 34 pikemen
15: Thor [r4g], Imperial Empire, with 38 pikemen
15: Eos [a2t], Imperial Empire, with ten workers, 48 lt. xbowmen
15: Khaki Blazer [w4j], Imperial Empire, with eight soldiers,
15: six pikemen, 31 lt. foot
15: Banian [e7n], Imperial Empire, duke, the High Priest of the
15: Church of Eres [151], with two soldiers, ten angels
15: Winstin [o7y], Mandor Confederacy, prisoner
15: Black Blazer [s8u], Mandor Confederacy, prisoner
15: Pink Blazer [n8e], Mandor Confederacy, prisoner
15: Baltor [v5s], Mandor Confederacy, prisoner
15: Merbit [e2m], Mandor Confederacy, prisoner
16: Pleasure Sloop [v5n], ship, 30 hulls, 1 rowing port, 90 sails,
16: departed for Ocean [as43].
Routes leaving Ocean:
North, to Ocean [aq43], 6 days
East, to Ocean [ar44], 5 days
South, to Ocean [as43], 5 days
West, to Ocean [ar42], 6 days
It is raining.


boto v2.7.0
The 2.7.0 release of boto is now available on PyPI.
You can get a comprehensive list of all commits made between the 2.6.0 release
and the 2.7.0 release at https://github.com/boto/boto/compare/2.6.0...2.7.0.
This release includes:
- Added support for AWS Data Pipeline - commit 999902
- Integrated Slick53 into Route53 module - issue 1186
- Add ability to use Decimal for DynamoDB numeric types - issue 1183
- Query/Scan Count/ScannedCount support and TableGenerator improvements -
issue 1181
- Added support for keyring in config files - issue 1157
- Add concurrent downloader to glacier - issue 1106
- Add support for tagged RDS DBInstances - issue 1050
- Updating RDS API Version to 2012-09-17 - issue 1033
- Added support for provisioned IOPS for RDS - issue 1028
- Add ability to set SQS Notifications in Mechanical Turk - issue 1018
Commits
There were 447 commits in this release from 60 different authors. The authors
are listed below, in alphabetical order:
- acrefoot
- Alex Schoof
- Andy Davidoff
- anoopj
- Benoit Dubertret
- bobveznat
- dahlia
- dangra
- disruptek
- dmcritchie
- emtrane
- focus
- fsouza
- g2harris
- garnaat
- georgegoh
- georgesequeira
- GitsMcGee
- glance-
- gtaylor
- hashbackup
- hinnerk
- hoov
- isaacbowen
- jamesls
- JerryKwan
- jimfulton
- jimbrowne
- jorourke
- jterrace
- jtriley
- katzj
- kennu
- kevinburke
- khagler
- Kodiologist
- kopertop
- kotnik
- Leftium
- lpetc
- marknca
- matthewandrews
- mfschwartz
- mikek
- mkmt
- mleonhard
- mraposa
- oozie
- phunter
- potix2
- Rafael Cunha de Almeida
- reinhillmann
- reversefold
- Robie Basak
- seandst
- siroken3
- staer
- tpodowd
- vladimir-sol
- yovadia12


Chat with a
Robot
This is a
robot
Say hello to the Robot (They speak in numbers).
single numbers only pls
Speak to me
Robot


Shimmer Synthesis Actor
The Shimmer Actor produces a sound with harmonic spectrum
by randomly walking the frequencies of several sine waves
through an overtone series. The effect can be "shimmery".
(It's a cool sound I discovered with an Atari ST and a Yamaha FB01 in 1986.)
To use it, load shimmer.so and create an actor of type ShimmerActor.
ShimmerActor messages
In addition to the messages understood by all generator actors, the ShimmerActor
understands the following messages:
-
SetNumPartials hActor x
-
Set the default number of partials (i.e., sine waves)
for new instances created by this actor to x.
-
SetAllNumPartials hActor x
-
Set the number of partials of all children to x,
and set the default number of partials for all future children to x.
-
SetFreq hActor x
-
Set the default fundamental frequency for all future children to x Hz.
-
SetAllFreq hActor x time
-
Set the fundamental frequency of all children to x Hz, and also
set the default fundamental frequency for all future children to x
Hz. If time is specified, children will modulate to the new frequency
over the specified duration. Default frequency is always set immediately
regardless of time.
-
SetWalkspeed hActor x
-
Set the default random-walk speed for all future children to x
seconds (i.e., allow the partials to change frequency every x
seconds).
-
SetAllWalkspeed hActor x time
-
Set the random-walk speed of all children to x seconds, and also
set the default for all future children to x.
If time is specified, children will modulate to the new value
over the specified duration. Default value is always set immediately
regardless of time.
-
SetAvgFreq hActor x
-
Set the default average frequency of the partials to x Hz.
-
SetAllAvgFreq hActor x time
-
Set the average frequency of all children to x seconds, and also
set the default for all future children to x.
If time is specified, children will modulate to the new value
over the specified duration. Default value is always set immediately
regardless of time.
-
SetRange hActor x
-
Set the default frequency range of the partials to x,
i.e., keep partials between average_frequency/x and average_frequency*x.
x should be greater than 1.
-
SetAllRange hActor x time
-
Set the frequency range of all children to x, and also
set the default for all future children to x.
If time is specified, children will modulate to the new value
over the specified duration. Default value is always set immediately
regardless of time.
ShimmerActor handler messages
In addition to the messages understood by all handlers, the handler for
the shimmer synthesis algorithm understands the following messages.
In all of the following, if the parameter time
is specified, the value in question will become the new value
over the specified duration (instead of instantaneously).
-
SetFreq hSound x time
-
Set the fundamental frequency to x Hz.
-
SetLogFreq hSound x time
-
Set the fundamental frequency to exp(x) Hz.
-
SetAvgFreq hSound x time
-
Set the average frequency to x Hz.
-
SetLogAvgFreq hSound x time
-
Set the average frequency to exp(x) Hz.
-
SetFreqRange hSound x time
-
Set the frequency range to x.
-
SetLogFreqRange hSound x time
-
Set the frequency range to exp(x).
-
SetWalkSpeed hSound x time
-
Set the random walk speed to x seconds.
-
SetLogWalkSpeed hSound x time
-
Set the random walk speed to exp(x) seconds.
-
SetNumPartials hSound x
-
Set the number of partials to x.


| Platform versatility |
+ |
+ |
+ |
| Induction of cellular and humoral immune responses |
+ |
+ |
+ |
| Fully synthetic vaccine production possible |
– |
+ |
+ |
| Delivery as minimal vaccine construct possible
*
|
– |
± |
+ |
| Repeated vaccine applications possible |
± |
+ |
+ |
| Vaccine safety |
± |
+ |
++ |
| Immunogenicity demonstrated in clinical studies |
+ |
± |
± |


(function(canto34){
Canto 34 is a library for building recursive-descent parsers.
When it comes to writing a parser, you get two main choices. Write your own, or use a parser generator like PEGJS or Jison. I've never really had much success with parser generators, and it's always seemed pretty easy to write a recursive-descent parser yourself, if you have some basic tools like a regex-based lexer, and some basic functions for matching tokens and reporting errors. Canto34 gives you the functions you need to write a recursive descent parser yourself.
(function(canto34){
your code goes here
A Lexer takes a string and chops it into pieces. A Canto34 Lexer is a series of pattern objects, like
{
name: "whitespace",
regexp: "[ \t\r\n]+",
ignore: true
}
canto34.Lexer = function() {
this.patterns = [];
};
var PatternDefinitionException = function(message) {
this.message = message;
}
canto34.Lexer.prototype = {
addPattern: function(pattern) {
if (!pattern.name) {
throw new PatternDefinitionException("Patterns must have a 'name' property");
}
if (!pattern.regexp) {
throw new PatternDefinitionException("Patterns must have a 'regexp' property");
}
if (pattern.regexp instanceof RegExp) {
throw new PatternDefinitionException("Patterns 'regexp' property must be an instance of RegExp");
}
}
};
})(typeof exports === 'undefined'? this['canto34']={}: exports);


Tilsa1905.github.io
Manuals list - Music and audio equipment - Manuals Warehouse. Manuals Warehouse is your source for copies of owners manuals, service manuals and other documentation on audio, music, stage and studio equipment. Clavia Nord Electro 5D 61 Handbücher.


Home Town -
Healdsburg, CA
Currently Reside -
Santa Rosa, CA
I like to
- Play Piano
- Game
- Listen to Music
- Code
- Listen to Classical Music while Coding
Education
- Attended UC Santa Barbara for 3 years
- Currently attending DevBootcamp
What a quirk:
I have a
TARDIS shower curtain. When I take a shower I am transported through time and space.


Class ReadRowsPage (2.4.0)
ReadRowsPage(stream_parser, message)
An iterator of rows from a read session message.
Parameters
| Name | Description |
| stream_parser |
google.cloud.bigquery_storage_v1.reader._StreamParser
A helper for parsing messages into rows. |
| message |
google.cloud.bigquery_storage_v1.types.ReadRowsResponse
A message of data from a read rows stream. |
Inheritance
builtins.object > ReadRowsPageProperties
num_items
int: Total items in the page.
remaining
int: Remaining items in the page.
Methods
__iter__
__iter__()
A ReadRowsPage
is an iterator.
__next__
__next__()
Get the next row in the page.
next
next()
Get the next row in the page.
to_arrow
to_arrow()
Create an pyarrow.RecordBatch
of rows in the page.
| Type | Description |
| pyarrow.RecordBatch | Rows from the message, as an Arrow record batch. |
to_dataframe
to_dataframe(dtypes=None)
Create a pandas.DataFrame
of rows in the page.
This method requires the pandas libary to create a data frame and the fastavro library to parse row messages.
.. warning:: DATETIME columns are not supported. They are currently parsed as strings in the fastavro library.
| Name | Description |
| dtypes |
Map[str, Union[str, pandas.Series.dtype]]
Optional. A dictionary of column names pandas |
| Type | Description |
| pandas.DataFrame | A data frame of all rows in the stream. |