I'd like to get a few things cleared up about playlist folder handling in Libspotify. A few things seem a bit inconsistent about it (I get the impression folder handling has been hacked in as a bit of an afterthought?)
When I cycle through all the playlists in a container, I notice I get the same sp_playlist handle value for all the folders. This means I can't use any of sp_playlist_xxx functions on folders, right? So I can't register callbacks on them, cannot find out their name, etc?
Instead, I have to use special functions on the PlaylistContainer to get folder names?
Is it dangerous to use sp_playlist_add_ref and sp_playlist_release on handles pointing to folders?
Also, what is the sp_playlistcontainer_playlist_folder_id function intended for?
Your assumptions are mostly correct. Folder placeholders in the playlist container list are just that - placeholders.
Instead, I have to use special functions on the PlaylistContainer to get folder names?
Yes, sp_playlistcontainer_playlist_folder_name().
Is it dangerous to use sp_playlist_add_ref and sp_playlist_release on handles pointing to folders?
Not especially, as long as you don't over-release somewhere, but that's true of everything. You'll just have multiple owning references to the placeholder, which is fine.
Also, what is the sp_playlistcontainer_playlist_folder_id function intended for?
It's a unique ID for the folder, mainly there since you can't use the pointer as a unique identifier since all folders use the same placeholder object. It allows you to compare folders to one another without doing string comparison on the name (which, since multiple folders can have the same name, isn't actually a good idea).
Related
Just like TImageList contains a collection of images, is there a similar component for generic files?
I know I can embed files as resources, but I'd like the convenience of storing different groups of files in different "TFileList" components, and to be able to retrieve files by name or by their position in the list.
Extra points if such a component allowed some sort of design time preview of the file content (just like TImageList lets you see what each image looks like, at design time).
(I come from Delphi where I wrote my own component to do the above, but before I rewrite and port the property editor and all that to Lazarus, maybe there is already something that is tried and tested...)
Thanks!
You can use pre-defined lazarus TFPGList to specialize list of the type, that you want, for example - UTF8String
But, there's no T<>List as a component, only as object.
So, yes, this feature will be useful and i can implement, if have time,
also, there's a very limited RTTI, which has been updated only a few months ago, so you can access Methods and Properties now, so FP is more systemized, than delphi pascal, but also not so enterprise-developed, which limits it to implementations for common opensource and shareware project problems.
Nevertheless, it is more stable and supported, even my friends can contribute.
I want to use Blockly to do some calculations, and then generate text files (as opposed to exporting code to JavaScript, Python, PHP, etc.)
I can’t see an obvious way to create my own blocks to do this in Blockly, so using AppInventor (Version: nb168), I got storing and retrieving files to work, in a crude test app on my Android tablet.
In AppInventor/Designer mode, clicking Storage/File creates a “Non-visible component for storing and retrieving files. Use this component to write or read files on your device.”
Then, in AppInventor/Blocks mode, clicking the “File1” icon gives access to 7 “file type blocks”, e.g. AppendToFile, Delete, ReadFrom, SaveFile, etc.
Is it possible to create similar “file type blocks” to use in Blockly Web?
I have limited programming knowledge, so would appreciate simple answers, please.
Thanks, Pete.
Andrew N Marshall from Google/Blockly has told me this:
"This is absolutely possible ...as long as you willing to work within the browser's security restrictions. The resulting files will be need to be manually "downloaded" one at a time, rather than written directly to the user's file system.
... I would start understanding what JavaScript functions are available to you. Attempt to construct a string and save it via a download dialog...
That means the "file" contents are really just a string in memory, a JavaScript variable. We have lots of "Text" blocks that can do a variety of operations on strings. If those are enough, you'll only need one new block to identify the string variable and initiate the download process.
Otherwise, you'll need to think about what blocks you want, and how they operate. They may operate on a specific variable in the JavaScript VM, not necessary exposed as a variable to Blockly.
Either way, you'll need to learn how to create a block and a Blockly app. We have a code lab that will walk you through all the steps. You'll learn how each block generates a string of code, and in your case, that code will be related to the download code I mentioned earlier."
So I'll press on - I just wanted to be sure my goal is actually achievable before I started.
Thanks, Pete.
I'm quite stuck on an unexpected problem. I'm trying to use Wayfinder to generate a sitemap for a project. The output of the navigation items is as expected, but I need to include a number of documents in addition to the primary navigation elements.
To do this, I have used the includeDocs parameter.
[[Wayfinder? &startId=`0` &includeDocs=`17,18,19,20`]]
When I do this, I get no output at all. Remove includeDocs and I get the standard nav (expected). Use the param and the output is completely empty.
No idea what I'm doing wrong or what (if any) other setting must be defined in order to make this work.
The includeDocs parameter is very misleading. It should rather be named "onlyIncudeDocs" or "restrictTo", since that is what it does. It also requires the docs you include to be directly accessable from your startId, alternatively have the entire path "included".
I would suggest you create weblink resources directly under your startId, and link them to the resources you want to include. That way wayfinder will pick them up by default. (Note that you may need to handle this in your rowTpl for wayfinder, since a weblink stores the actual link in it's content field)
If you also want to include the children of the id's you specify, you would probably be better of slightly revising your resource structure.
In Express.js, is there a standard way to re-order the middleware registered on an express#Router object? I have a situation where it is possible to dynamically register static asset directories that should be served by the app via express.static(). However, the Router#use() method (which I'm using to register the new asset directories) always puts middleware at the end of Router#stack. I want this to be at the beginning. Is there any way to achieve this?
I have a working implementation that basically traverses the current Router's stack in reverse, picks the first middleware called staticMiddleware, and moves it from that location to the front of the array. This works, but is obviously dependent on the internals of Route. I'm hoping there's another, more standard way to achieve the same behavior.
You probably want to just have a custom route at the beginning of the order that can examine the path, compare it to a list of directories you want to serve (that can change over time) and then serve the static content if its path matches.
This would just be a smarter version of express.static() that works off a dynamic path list rather than only a pre-defined path. There isn't much to express.static() so you can just copy it into your function and make it smarter.
It is apparently possible to crack into the stack of middleware and modify the order. I don't know if this is a supported capability or just something unsupported that people have figured out (that could break in the future). Here's one article that discusses this: https://www.exratione.com/2013/03/nodejs-abusing-express-3-to-enable-late-addition-of-middleware/
I've got some source code that has some cross site scripting vulnerabilities in it. There is no input validation that happens when the browser sends data over to the server which is executing server-side Javascript and classic ASP (IIS 7.0).
My question is, is there a way to override the Request.Form("foo") object/method so that I can call a sanitization function too and get rid of prohibited JS/HTML? I don't want to do a find and replace on every single file everywhere Request.Form is called. I was hoping for something more elegant.
Any suggestions are appreciated.
I don't think you can change Request.Form members.
What you can do, as a partial solution, is to create a code that will run first on every page (for example, using an include directive) which loops over Request.Form, Request.QueryString etc., and if it finds suspected code, it terminates the code execution (Response.End). This solution is partial because it doesn't really sanitize input, it just drops execution when it finds suspected text.
Another option: Create an array, parallel to Request.Form. Populate this array with the same members as in Request.Form, but this time sanitized. Then, quickly do a Find-and-Replace over your whole code base, and change Request.Form to your custom array variable.
There is a way to replace the whole Request object with another COM object but its an insane solution and it would still require that all ASP files that use Form contain a common top include file. Its not possible to replace the Request object or one of its members globally at the application level.
The correct solution to the problem, your statement "don't want to do a find and replace on every single file everywhere" notwithstanding, is to perform such global replace.
Despite the number of .asp files that exist the cost is no more than knocking up a simple program to open each ASP file in a folder tree, adding an include line and replacing Request.Form.