mardi 2 janvier 2018

How to use currency data in a php and mysql web Application?

I'm a newbie in web development Currently in building a web application for a company using php and mysql The problem is: The capital is in USD dollar and they sale thier products in AFG, the application should be updated all the time since the currency data may change frequently The only thing I know is that I should use ÀPI but I don't know what else i need, how to get and use it and from where? Any help will be appreciated. Thanks in advance.




Relation between Pull and Component Web Frameworks

I came across this on wikipedia (this happened to be uncited):

"...pull-based architecture, sometimes also called "component-based". These frameworks start with the view layer, which can then "pull" results from multiple controllers as needed. In this architecture, multiple controllers can be involved with a single view. "

Assuming this is correct, why are pull-based frameworks associated with component based? Are there any examples?




how to write code for different code for different platform in react app

I am developing a web application, which I want to make it native. code for camera capture for the web, and native are different, how can I write code which executes for the particular platform?




lundi 1 janvier 2018

CDATA inside JavaScript

There is the simple script in head:

<head>
<script type="text/javascript" src="/themes/default-bootstrap/js/jquery.maskedinput.js"></script>
    <script type="text/javascript">
         $('#div').mask('+7(999) 999-9999');
    </script>
</head>

On the site page script doesnt work, if I run it with console - it works. No errors. jQuery is connected. I try to put the script before :

<head>
     <script type="text/javascript" src="/themes/default-bootstrap/js/jquery.maskedinput.js"></script>
</head>
<body>
     <div id="div"></div>
     <script type="text/javascript">
          $('#div').mask('+7(999) 999-9999');
     </script>
</body>

Also I tried to put script into the file. In Chrome DevTools script shown in one line and looks like that:

<head>
     <script type="text/javascript">/* <![CDATA[ */;$('#div').mask('+7(999) 999-9999');/* ]]> */</script>
</head>

What could be the reason? Can CDATA affect the operation of the script and why it is automatically added?




Flask: how to serve an updating log file line by line?

There are two threads in my Python program, one is for flask, and the other one is for the background task and it will dynamically generate some logs strings into a log file when it is running.

I've tried streaming the file with yield like this:

@app.route('/task_status')
def get_background_task_log():
    def read_task_log():

        # Try load log files
        log_file = open("/tmp/task_log.log", "r")

        # Stream file to the client
        while True:
            new_line = log_file.readline()

            # Stream the file to the client until it ends.
            if "Foo: process finished!" in new_line:
                yield new_line.encode("utf-8")  # Flush the last line
                break

            yield new_line.encode("utf-8")

    return Response(read_task_log(), mimetype="text/plain",
                    headers={"Content-Disposition": "inline; filename=flashrom.log"})

But when Chrome loads /task_status, it just hangs there and wait until the line Foo: process finished come out, instead of show me the content line by line. I've also tried removing the Content-Disposition header and it stays the same.

Meanwhile I've also tried using send_file() but it can only returns a partial log file when I access it from Chrome.

What should I do then?




C# dating site web scraping and will auto go into every profile and send a generic message to every1

Okay guys, I need a little (lot) help here. I'm working on a C# VS17 one click program to log into a dating site (pof) and message every girl on my matches page. I've found out how to login but no tut video on yt has a working way to harvest the profile ids, then go into the profile and submit a generic message, then get out and go onto the next prof id, and so on & so on. I want to keep track of the ids, to not message the same girl twice. I want to send them all a generic message. How could I effectively accomplish this? Thanks for any brain power given!!!




Web API 2 - Error: "No type was found that matches the controller named 'resize'."

I am trying to just do a simple file upload API using Web API.

Here is the Controller:

[RoutePrefix("api/resize")]
public class ResizeController : ApiController
{

    [HttpPost, Route("api/resize/preserveAspectRatio")]
    public async Task<IHttpActionResult> resizePreserveAspectRatio()
    {
        if (!Request.Content.IsMimeMultipartContent())
            throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);

        int maxWidth = 100;
        int maxHeight = 100;

        var provider = new MultipartMemoryStreamProvider();
        await Request.Content.ReadAsMultipartAsync(provider);
        foreach (var file in provider.Contents)
        {
            var filename = file.Headers.ContentDisposition.FileName.Trim('\"');
            var buffer = await file.ReadAsByteArrayAsync();
            //Do whatever you want with filename and its binaray data.


        }

        return Ok();
    }


}

This is my WebApiConfig:

public static class WebApiConfig
{
    public static void Register(HttpConfiguration config)
    {
        // Web API configuration and services

        // Web API routes
        config.MapHttpAttributeRoutes();

        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );
    }
}

When I POST a file with PostMan, here is the error I get:

{
    "Message": "No HTTP resource was found that matches the request URI 'http://localhost:26303/api/resize/preserveAspectRatio'.",
    "MessageDetail": "No type was found that matches the controller named 'resize'."
}

This is not a dupe - was not able to find another article that addresses this specific combination.

Any help is greatly appreciated!