Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Gaurav Arora
    @gauravarora1729
    Running MyappWeb.Endpoint with Cowboy using http://0.0.0.0:4000
    how get this to my instance IP address while running mis phx.server
    Michael
    @mazz
    What’s the error message?
    Ishizaka Tomoya
    @ghostrick
    Hi. Function defined using defp Displays the following error. (dialyzer)
    Function function_name/1 will never be called
    But using def will work fine. Is it possible to operate normally using defp ?
    James Carlson
    @jxxcarlson

    Hello! I am using ExAws to make presigned requests. However, I am having two problems: (a) certain properties, e.g., permissios, are not set on the uploaded image file; (b) the uploaded file is corrupted, i.e., when downloaded cannot be read. Here is the function I use to build the url:

     def make_presigned_url(bucket, path, mime_type) do
        query_params = [{"ContentType", mime_type}, {"ACL", "public-read"}]
        presign_options = [query_params: query_params]
        {:ok, presigned_url} = ExAws.Config.new(:s3) 
          |> ExAws.S3.presigned_url(:put, bucket, path, presign_options)
        presigned_url 
      end

    And here is a typical url produced in this way:

    https://s3.amazonaws.com/noteimages/jxxcarlson/carr_fire_2.jpg?ACL=public-read&ContentType=image%2Fjpeg&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJQYJYCIAWH6DGHIQ%2F20180808%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20180808T205946Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=91f071b815f64076a4

    Finally, here is the code used to upload the file:

    app.ports.uploadImage.subscribe(function (info) {
    
                console.log("url = " + info.url)
    
            var reader = new FileReader();
    
                reader.readAsBinaryString(info.fileValue);
    
                reader.onload = function(e) {
                    $.ajax({
                        url: info.url, // the presigned URL
                        headers: {
                            'Access-Control-Allow-Origin': '*',
                            'Content-Type': 'image/jpeg'
                        },
                        type: 'PUT',
                        processData: false,
                        data: reader.result,
                        success: function() { console.log('Uploaded data successfully.'); }
                    });
                }
            });

    I need help!!! :-)
    Oh -- and despite the fact that a file is uploaded to S3 with nonzero contents, there is an error message:

    XML Parsing Error: no root element found
    Location: https://s3.amazonaws.com/noteimages/jxxcarlson/carr_fire_2.jpg?ACL=public-read&ContentType=image%2Fjpeg&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJQYJYCIAWH6DGHIQ%2F20180808%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20180808T205946Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=91f071b815f64076a4f372f20f49f55805700c4b8ebeb2ef8b4b95d9dd761434
    Line Number 1, Column 1:

    A friend made this comment: looking at hexdumps of those files shows that FF D8 is converted to C3 BF C3 98 which looks like some sort of mangled UTF8 conversion

    Michael
    @mazz
    Upload the file using the AWS uploader and see if you get the same result
    Oliveira
    @jricardooliveira
    Hi all. I'm Joao from Portugal and I'm new to Elixir and Phoenix.
    Does anyone can recommend me (if exists) a lib that acts as a Soap Client ? ... like the ruby gem Savonrb ...
    Michael
    @mazz
    Http://hex.pm might have something
    Subrahmanyam
    @d-subrahmanyam
    hello everyone
    Samoko
    @samoko
    I am new to elixir and trying to do what I think is a simple task without much success. I am trying to post a JSON array through the httpotion module. I build the array as a string of json object without much success. Something like that “[{‘a’:’a1’},’a’:’a2’}]”. The post looks like. HTTPotion.post url, [headers:header, body: body]. Anyone has done something like that before?
    Deric Walintukan
    @dwalintukan
    Hello! I have transactions and transfers tables. The relation is transactions can have many transfers based on transaction.id. How would I go about running an ecto.query to get all the transfers for a given transaction.id and add it to the transaction payload?
    Neya
    @dsignr

    @dwalintukan The easiest way is to use preload, if I understand your question correctly. In your ecto query, just add the preload option like this: preload: [:transfers] and then when you get a transaction by ID, it will automatically have all the associated transfers as well.

    So,

    t = Transaction.get(12) #Get transaction with ID 12
    t.transfers # This should have all its associated transfers
    Michael
    @mazz
    @neya overdependence on preload can be harmful
    I’m pretty sure @dwalintukan can do what he needs to do without preload
    Michael
    @mazz
    @dwalintukan try this:
    Or something like that
    Michael
    @mazz
    Paste it here
    Ecto.Query.from(fer in Transfer, join: tn in Transaction, where: fer.transaction_id == tn.id, order_by: tn.absolute_id, select: %{title: tn.basename, localizedTitle: fer.localizedname, uuid: tn.uuid, languageId: fer.language_id}) |> Repo.all
    Neya
    @dsignr
    @mazz Thanks Michael, I didn’t know that. I guess preload needs careful consideration before usage in production. I learnt something, thank you.
    Michael
    @mazz
    @dsignr np
    Naveen Yadav
    @navyad

    Not sure if this is a place to ask for review.

    Looking for feedback:
    https://github.com/navyad/moviematch

    Someone can have a look at the code, if something can be improved on, I am sure there will be many things.
    In terms of features which can be added or anything genuine feedback
    I am thinking to evolve more this project to cover as much as elixir.

    Stefan Kupresak
    @dev-cyprium

    Hello, everyone! Nice to meet you all.
    I'm having a fair bit of trouble understanding how can I implement a "lazy" version of a function inside a context in elixir (Phoenix)

    Basically, I'd like to add a per-connection cache, which makes sure that the query executes only once, and making it transparernt to the caller.

    For example:
    Context.fetch_data(:args) # would execute a query which would fetch me my data

    -- Now, I'd like to store this for that particular request, so when another line of Context.fetch_data/1 is reached, instead of doing an SQL Query it should just get the data from RAM

    Michael
    @mazz
    You could store query result in a cache like ETS or cachex
    Cachex has an API that will return nil if the data is not cached
    Stefan Kupresak
    @dev-cyprium
    Will that be per request though?
    Michael
    @mazz
    What if you have millions of requests?
    Stefan Kupresak
    @dev-cyprium
    Hmm, that's true having million of requests would be bad. Though, since request lifespan is pretty short, I wanted to somehow tie the Agent with the request process, and have it killed at the end.
    The reason is that the thing I'd like to fetch is deeply inside a loop, and I have an N+1 problem. So what I want actually is only the first call per request to be cached
    Stefan Kupresak
    @dev-cyprium
    So, inside that deeply recursive function there's a context call.
    Context.fetch_data which fetches the data using SQL.
    I would like it ( if possible ) to somehow tie that function with self()
    So my idea was when I use Context.fetch_data, I return a pid of an agent. Which runs the query, if the query hasn't been run, but if the query has been run it doens't do that.
    Finally, when a request comes to an end the process dies, so somehow I'd like to take down the cache with it
    One hack I wanted to use is just attach that data to assigns but - I can't really do that either, since the deep recursion I'm talking about is inside an umbrella project and doens't know
    about conn
    My last resort was just use Redis but I'd really appreciate I solve this with Elixir/Phoenix since my client is against caching query result in Redis
    hopefully my rather verbose explanation makes sense?
    Michael
    @mazz
    You should probably ask that question at elixirforum
    Stefan Kupresak
    @dev-cyprium
    Yeah, I'll give that a try :)
    Josh Beaker
    @SoftwareJosh_twitter
    Hey just made my first monstrosity in elixir
    is anyone willing to review possibly
    this is my 3rd iteration of solution
    each iteration has been halted by elixirs immutable scope
    cause I am dumb
    anyways heres the thing
    It's SUPPOSED to be a solution to https://adventofcode.com/2019/day/3
    jonelrecto
    @jonelrecto
    hi elixir devs. im looking for an api that scan technology/provider used in scanned url..
    Franco Barbeite
    @FrancoB411

    Hey everybody! Anyone know a good way to test multiple sequential terminal inputs and outputs?

    Currently, I'm using capture_io but it only seems to accept one input for IO.gets. I'd like to do several IO.gets one after another.

    Something like what cypress.io does, but for the CLI? Any suggestions?

    ORES
    @ORESoftware