Showing MarkDown Flutter from source of a link - string

I would like to use flutter_markdown package.. So here is the example:
Markdown(data: markdownSource); where markdownSource here is a String, but what I would like to do is..... I have md String which I store inside https://mylink.co.id/trial.md and is there a way to read https://mylink.co.id/trial.md and show it using Markdown() ?

Yes this can be done. Create the markdown string and save it in a server. Make an API call and get it's content. (don't miss to await this step). Then you can use the response value as data:response

Related

Using a nodejs server to load files with Unicode names

I want to load audio files with names like здраво.mp3, using a NodeJS server. (That's "zdravo" or "hello" in Serbian, if you were wondering).
However, NodeJS makes a request for %D0%B7%D0%B4%D1%80%D0%B0%D0%B2%D0%BE.mp3 instead, which results in the file not being found.
If I drag the file into a browser window from my desktop, the browser is happy to load it as file///path/здраво.mp3, so the issue is not with the way the browser is treating the Unicode string
The HTML page containing the link to the file has this meta tag in the head section...
<meta charset="utf-8" />
... and it is quite happy to display the text "Здраво" on the page, so the Unicode strings are properly formed within the browser.
I am guessing that the browser is converting the name to ISO-8859-1 before sending the request, and that the NodeJS server somehow needs to convert it back to Unicode before looking for it in the file system.
My question is: is there already a module that I can use to do this conversion, and are there examples of how to use it?
SOLUTION: Following the reply from Edwin Dalorzo, here is the one-line fix that I made to my handleRequest() function:
function handleRequest(request, response) {
request.url = decodeURIComponent(request.url) // the fix
var pathname = url.parse(request.url).pathname
It is not clear how you are receiving the encoded string, but for sure you can decode by simply doing:
decodeURIComponent("%D0%B7%D0%B4%D1%80%D0%B0%D0%B2%D0%BE")
And this will give you back your string "здраво"

How to encode a PHP file with base64

:)
I have one ridiculously silly question and most of you would like to reffer me to Google right away, but that didn't helped me out within the first hour. I suppose I didn't knew how to look for. I'm having a PHP file and I'd like to have it in base64 yet I can't get it to work anyhow.
1) I encoded my PHP script to base64(and included the PHP tags). It'll look as following : JTNDJTNGcGhwJTIwVGhpcyUyMGlzJTIwdGhlJTIwUEhQJTIwY29kZSUyMCUzRiUzRQ==
This kind of base64 won't execute so I added the PHP tags to it although the encoded file already had it. Still didn't worked out. Removed the tags from the base64 and tried again, but still didn't worked. Then I tried adding the PHP tags and inside of them added :
eval(gzinflate(base64_decode('base64 here')));
Still didn't worked out anyhow. Is anyone here kind enough to tell the kiddo how to run a base64 encoded PHP file properly?
Would be really appreaciated. :)
A simple code:
$source = "JTNDJTNGcGhwJTIwVGhpcyUyMGlzJTIwdGhlJTIwUEhQJTIwY29kZSUyMCUzRiUzRQ==";
$code = base64_decode($source);
eval($code);
or even shorter:
eval(base64_decode("JTNDJTNGcGhwJTIwVGhpcyUyMGlzJTIwdGhlJTIwUEhQJTIwY29kZSUyMCUzRiUzRQ=="));
Do you want to encrypt your code? If so, this is not the right way. Use a accelerator like this one or this one. They will crypt your codes and make them even faster!
If you are going to use base_64 to encode your php file then the encoded text need to seat in between the php tags including the base_64 tag.
Example:
If your code is:
JTNDJTNGcGhwJTIwVGhpcyUyMGlzJTIwdGhlJTIwUEhQJTIwY29kZSUyMCUzRiUzRQ
Then your code should look like:
<?php eval("?>".base64_decode("JTNDJTNGcGhwJTIwVGhpcyUyMGlzJTIwdGhlJTIwUEhQJTIwY29kZSUyMCUzRiUzRQ")); ?>
Basically your basic code will look like this:
<?php eval("?>".base64_decode("Code Goes here")); ?>
There are more simple tools that can give you this option
Check this out: PHP Encoder & Decoder with Domain Lock

Protecting an applescript script

I'd like to use Applescript to connect to my remote website. However, I don't like the idea of having my password/username in my script in plain text. Is there anyway to encode a password in a local script on my computer?
Thank you,
Eric
Well you're not the first one that asks this question but you have to ask yourself some questions. Like who is gonna use it and from who do I need to protect it.
Step 1:
To make sure that your code is protected you should save two different kind of AppleScripts. The first one is for you, and you only. This version is compiled but be able to open with Script editor again so you can see the source code. The second is a run only script which is much like the first version but your not able to open it in Script editor again as a document to view it's source code.
step 2:
The second thing you don't want is that there is static text about user credentials because, even if it's compiled, you can see static text. Normally you won't see them but when the user credential is an mail address it's an easy find. But before we solve this issue, do you think someone is clever enough to find the user credentials from compiled AppleScript code? If so then the easiest way of encoding is adding a certain value to Unicode values:
property eusn : "¨®¦ÅÞÞÍÉ»ÅÞÞÍÉ"
property epwd : "ÔÅ××ÛÓÖÈ"
set usn to simpleDecryption(eusn)
set pwd to simpleDecryption(epwd)
on simpleEncryption(_str)
set x to id of _str
repeat with c in x
set contents of c to c + 100
end repeat
return string id x
end simpleEncryption
on simpleDecryption(_str)
set x to id of _str
repeat with c in x
set contents of c to c - 100
end repeat
return string id x
end simpleDecryption
Store statics as encrypted strings and when its needed, decrypt them. Remember that properties are persistent, unlike local variables, so don't store plain data in properties in your case.

How can send I the the byte array of a png through an AMF request using soapUI?

I'm currently trying to create a load test for my API using soapUI to send Adobe Message Format requests. I have a request that expects a byte[] data type, but I know next to nothing about Groovy or Java.
I've pieced together information from different threads and I'm trying to create a property expansion along the lines of "${byte[] contents = new File("C:/Users/jloiselle/Desktop/TestDragon.png").getBytes()}" which obviously does not work.
Can anyone help me out or at least point me in the right direction?
Thanks in Advance
You have the correct way of getting the bytes of the file;
new File("C:/Users/jloiselle/Desktop/TestDragon.png").bytes
How are you trying to send this array to the request?
After lookin at the soapUI tutorials again, I realized I was attempting to reference the property incorrectly.
The solution was as follows:
In the script window of my request I added:
def temp = new File("C:/Users/jloiselle/Desktop/TestDragon.png").bytes
parameters['contents'] = temp
Thanks for the verifying the syntax for geting the bytes of a file.

How do I get the HTML in an element using Capybara?

I’m writing a cucumber test where I want to get the HTML in an element.
For example:
within 'table' do
# this works
find('//tr[2]//td[7]').text.should == "these are the comments"
# I want something like this (there is no "html" method)
find('//tr[2]//td[7]').html.should == "these are the <b>comments</b>"
end
Anyone know how to do this?
You can call HTML DOM innerHTML Property:
find('//tr[2]//td[7]')['innerHTML']
Should work for any browser or driver.
You can check all available properties on w3schools
This post is old, but I think I found a way if you still need this.
To access the Nokogiri node from the Capybara element (using Capybara 1.0.0beta1, Nokogiri 1.4.4) try this:
elem = find('//tr[2]//td[10]')
node = elem.native
#This will give you a Nokogiri XML element
node.children[1].attributes["href"].value.should == "these are the <b>comments</b>"
The last part may vary for you, but you should be able to find the HTML somewhere in that node variable
In my environment, find returns a Capybara::Element - that responds to the :native method as Eric Hu mentioned above, which returns a Selenium::WebDriver::Element (for me). Then :text gets the contents, so it could be as simple as:
results = find(:xpath, "//td[#id='#{cell_id}']")
contents = results.native.text
if you're looking for the contents of a table cell. There's no content, inner_html, inner_text, or node methods on a Capybara::Element. Assuming people aren't just making things up, perhaps you get something different back from find depending on what else you have loaded with Capybara.
Looks like you can do (node).native.inner_html to get the HTML content, for example with HTML like this:
<div><strong>Some</strong> HTML</div>
You could do the following:
find('div').native.inner_html
=> '<strong>Some</strong> HTML'
I ran into the same issue as Cyril Duchon-Doris, and per https://github.com/teampoltergeist/poltergeist/issues/629 the way to access the HTML of an Capybara::Poltergeist::Node is via the outerHTML property, e.g.:
find('//tr[2]//td[7]')['outerHTML']
Most of the other answers work only in Racktest (as they use Racktest-specific features).
If your driver supports javascript evaluation (like Selenium) you can use innerHTML :
html = page.evaluate_script("document.getElementById('my_id').innerHTML")
If you're using the Poltergeist driver, these methods will allow you to inspect what matches:
http://www.rubydoc.info/gems/poltergeist/1.5.1/Capybara/Poltergeist/Node
For example:
page.find('[name="form-field"]').native.value == 'something'
try calling find('//tr[2]//td[10]').node on it to get at the actual nokogiri object
Well, Capybara uses Nokogiri to parse, so this page might be appropriate:
http://nokogiri.org/Nokogiri/XML/Node.html
I believe content is the method you are looking for.
You could also switch to capybara-ui and do the following:
# define your widget, in this case in your role
class User < Capybara::UI::Role
widget :seventh_cell, [:xpath, '//tr[2]//td[7]']
end
# then in your tests
role = User.new
expect(role.widget(:seventh_cell).html).to eq(<h1>My html</h1>)

Resources