Flowplayer question mark - flowplayer

How can I add a file with a question mark to flowplayer?
I need something like this:
http://maindomain.dev/file.flv?a=someparameter&b=secondparameter
if I add a link to flowplayer does not work.

A question mark URL encodes as %3F. But you should use a proper encoder for the whole thing rather than manually encoding a specific character.
Depending on the server-side technology you're using to build the Urls, tyhere should be a function like UrlEncode() which should handle all this for you. Failing that, Javascript has encodeUriComponent()

Related

Go rendering URL RowQuery string in a template - different behaviours

I 'm new to go and I got my mind stuck with something pretty trivial, so I ask for your help, maybe anyone knows why this behaviour happens:
I want to output the query params string of an url object in a template, but apparently because of the "?" char placed in front of the variable, the (whole) output is url encoded. Does question mark has a special meaning in go templates?
instead of param1=value1&value2=param2, output is param1%3dvalue1%26value2%3dparam2
Example in go playground
The Go documentation of the html/template package explains the behaviour (https://golang.org/pkg/html/template/):
The security model used by this package assumes that template authors are trusted, while Execute's data parameter is not. More details are provided below.
The thing about this is that you should really think twice about why you don't want Go to apply this security behaviour to your template.
Then, if you're really sure you don't want to escape the string use template.URL intead of a string: https://play.golang.org/p/kfv2tH6WDG

conditional include in asciidoc

I am using Spring RestDoc together with AsciiDoc to describe my rest api. RestDoc generates different files depending if there are request parameters described / response fields etc. I would like to have one template conditionally including whatever file exists.
something like this:
Request:
include::{reqresPath}/http-request.adoc[]
Response:
include::{reqresPath}/http-response.adoc[]
Parameters:
ifeval::[{{reqresPath}/request-parameters.adoc}.exists]
include::{reqresPath}/request-parameters.adoc[]
endif::[]
ifeval::[{{reqresPath}/request-parameters.adoc}.exists]
include::{reqresPath}/request-parameters.adoc[]
endif::[]
or at least exclude warnings in case of a missing file. But I could not figure out how to suppress these.
As of today, where is no operator for ifeval available, which can be used to check the existence of a file.
The way I would go is to write an extension for Asciidoctor, which can also be done by using Java. If your projects is big enough, I would suggest to go for this solution.
The most extreme way is to make a custom TemplatedSnippet which is generating an empty snippet to be included...
I hope there is a better way to do this.
Edit:
Take a look of http://asciidoctor.org/docs/user-manual/#by-tagged-regions

Get real path for google images

I am trying to fetch google trends page and the images that are shown are something in the code are actually like this
http://t2.gstatic.com/images?q=tbn:ANd9GcReZ5l9k236B8fRJQo2XuoaB30s-4wsUPZEYOWurvMjArDatu0vN_z2pHt4VAn_7Za_6xozCU3W
Since i need the real path to the image with its extension, is there any way to retrieve it?
Thank you.
First off, this sounds like you're trying to screenscrape. Your life might be easier if you can review the API for google-trends and use that instead (but I don't know that api well enough to help you on that front; I did add the google-trend (in a to be peer reviewed edit) to your post to try to attract who do.)
Having said that, can you download the image and look at the content-type (assuming that image doesn't redirect to the underlying image in which case your problem should be solved.) You didn't specify what language you were using, so I'm going to assume you're using the right one :).
Example code (python, using requests library):
import requests
r = requests.get("http://gstatic.foo.com/blah/randomkeyboardtypingdetected/")
ctype = r.headers.get("content-type",None)
lookup = {"image/jpeg":"jpg","image/png":"png"} # add others as needed
if ctype and lookup.get(ctype,None):
print lookup.get(ctype)
else:
print "Error, server didn't specify.
It is a real path, image is retrieved dynamically so path is not like regular one with file-name, extension etc.
You can check content type from response headers if you want to determine type of image.

Follow all links in JSON-LD API

Say I want to consume an API that returns JSON-LD and follow all the links. (I'm experimenting with the Hydra API-Demo, but it should work with all JSON-LD APIs, not only Hydra-based ones. Any good APIs out there that I should try?)
So I want to follow all the links and my environment doesn't have native RDF support. Probably, I should first parse it with one of the libs and get it into extended form with jsonld.expand(). Then I just grab all the values with key #id. Is that the recommended way to do it or am I missing some edge-cases?
The purpose of the expansion API is to produce regular, context-free output (expanded form) for algorithmic processing -- which is exactly what it sounds like you want to do. So, yes, you've got the right approach; you shouldn't be missing any edge cases as I've understood you. After you have JSON-LD in expanded form, you can easily follow the #ids (and, if you also need to do some kind of analysis of the vocabulary/ontology, you can follow the properties which will then be fully-expanded URLs).

Rainmeter: How to concatenate strings

I am getting data from a broken RSS feed that gives me wrong link. I wanted to fix this link so I made this code:
<link.*>(.*)&.*tid(.*)</link>
and the link could be like:
www.somedomain.com/?value=50&burrrdurrrr;tid=120
But the real working link is in this form:
www.somedomain.com/?value=50&tid=120
The thing that I'm asking is if my measure thing looks like this:
[FeedURL]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Feed]
StringIndex=2 ;now I only get www.somedomain.com/?value=50
Substitute=#SubstituteFeed#
How am I supposed to concatenate the strings together to complete the url?
I'm guessing rather than &burrrdurrrr;, the link has &, which is how you have to write & in an HTML or XML file.
If that's the case, you just need to set the DecodeCharacterReference option, as described in this handy-looking tutorial. Another option mentioned there is Substitute, which would be able to strip it out even if it really was &burrrdurrrr;.
None of this is a particularly sensible way of dealing with HTML or XML - a much better approach would be a plugin which actually parsed the document structure and let you reference nodes using XPath or CSS rules - but you work with what you've got, I guess. (I've never heard of this "Rainmeter" before, despite its claim to be "the best known and most popular desktop customization program for Windows"; maybe because nobody else calls their program that, instead almost universally using the word "widget"?)

Resources