Software Development and Programming Careers (Official Discussion Thread)

Joined
Nov 18, 2016
Messages
10,336
Reputation
1,530
Daps
33,381
You tried the typically steps?
clean and rebuild project
restart your project

Sounds like you have an uncaught exception or error. Look though the logs and see if you can see what's being thrown. But do what Renkz said first and clean then rebuild the project.

Aight yall I checked the log cat and I got the dreaded
java.lang.OutOfMemoryError. Combined with this message
"Failed to allocate a 7312908 byte allocation with 1872036 free bytes and 1828KB until OOM"

Anyone have any advice for how to deal with this? I'm gonna also try stackoverflow and google in general for info.
 
Joined
Nov 18, 2016
Messages
10,336
Reputation
1,530
Daps
33,381
Shoutout to Renz and Oprah Winfrey for the advice because it led me to a solution on stack overflow. I modified the Android Manifest by including android:largeHeap="true." Every developer needs to bookmark stack overflow and this thread of course.

Seems to be working for now. I hope it stays that way. :sadcam:
 

KritNC

All Star
Joined
Jun 5, 2012
Messages
3,440
Reputation
610
Daps
4,085
Reppin
Costa Rica
I'm assuming you mean the GenServer part?

What I had was my main app/root supervisor in Application.ex:

Code:
defmodule MyApp.Application do
  use Application
  def start(_type, _args) do
    import Supervisor.Spec

    children = [
      #...usual stuff
      supervisor(MyApp.Social.Supervisor, []) # supervisor for all my social media GenServers
    ]
    opts = [strategy: :one_for_one, name: MyApp.Supervisor] # the usual defaults.
    Supervisor.start_link(children, opts)
  end
end


Supervisor I started in the app's root supervisor for social media:
Code:
defmodule MyApp.Social.Supervisor do
  use Supervisor

  ############ Supervisor API##############
 
  def start_link do
    Supervisor.start_link(__MODULE__,[], name: __MODULE__) #This gets called from the Application.ex. This pretty much activates this Supervisor and will restart it on error.
  end

  def init(_) do
    children = [
      worker(MyApp.Social.Twitter, [], id: "tweets") #This calls the start_link function in the child GenServer.
    ]
    supervise(children, strategy: :one_for_one) # again, practically defaults. but :simple_one_for_one maybe when you want to dynamically add workers.

end

The code to run twitter calls, psuedo-code:
Code:
defmodule MyApp.Social.Twitter do
  use GenServer

 
  ##### Public API - The functions other modules can call####

  def start_link do
    GenServer.start_link(__MODULE__, [], name: __MODULE__)
  end

  def pull_tweets(_args) do
    GenServer.call(__MODULE__, :pull_tweets)
  end

  ##### GenServer API - these functions are called based on the Public API ####
 
 # init is automatically ran after start_link is called.
  def init(_state) do
    token = get_twitter_token()       #some function I have for authentication.
    tweets = get_new_tweets(token)
    reschedule()  ####this does the scheduling, we're just setting it on init.
    {:ok, %{token: token, tweets: tweets}}
  end

  #the public function above pull_tweets sends the :pull_tweets message, this function pattern matches on it:
  def handle_call(:pull_tweets, _from, state) do
    tweets = state.tweets
    {:reply, tweets, state}  # tweets is the reply, state isn't being changed.
  end
 
  # sets new tweets every 30 minutes - pattern matches from message send by reschedule()
  def handle_info(:reschedule, state) do
    tweets = get_new_tweets(state.token)
    reschedule() # Reschedule once more
    {:noreply, %{token: state.token, stories: stories}}
  end

 
  ### Helper functions
 
  defp get_new_tweets(token) do
    tweets = make_query_urls
      |> make_tweet_requests(token)    #starts async requests with Task.async on a list of query strings.
      |> Enum.map(&(parse_function(&1) )) # runs Task.await to get responses from each Task.async and decodes the json.
 
   tweets
  end

  defp make_query_urls() do
    #...builds url query strings ...
    return [list of query strings to search]
  end

  defp make_tweet_requests(query_urls, token) do
    tasks =
      Enum.map(query_urls, fn query_url ->
        Task.async(fn -> HTTPoison.get(query_url, headers) end)
      end)
    # tasks is a list of requests started asynchronously.
    tasks
  end
 
  #schedule set to get new tweets every 30 minutes
  defp reschedule() do
     Process.send_after(self(), :reschedule, 1 * 60 * 30000)
  end

end

Pretty much the GenServer makes async requests when the app starts and stores the results, then fetches tweets asynchronously again every 30 minutes and stores the results again.

Then to actually get the tweets, other modules just call MyApp.Social.Twitter.pull_tweets which is the public function on the GenServer. Only two functions in that GenServer are exposed: start_link and pull_tweets, but only the app itself calls start_link.

The social media supervisor is responsible for Facebook, Twitter, Instagram etc. GenServers (Twitter's is shown above). But that one supervisor is in charge of them all - which I may have to change the restart strategy for.

Pretty much each genserver is a separate process that spawns other processes with Task to make async requests. It's pretty much one big ass helper function that stores state.

If you have any questions, just let me know, I've spent months with the language.


Looks like something I built for work a few months ago. I am guessing this post by Jose helped you out as much as it helped me How to run some code every few hours in Phoenix framework?
 

TrebleMan

Superstar
Joined
Jul 29, 2015
Messages
5,592
Reputation
1,180
Daps
17,541
Reppin
Los Angeles
Looks like something I built for work a few months ago. I am guessing this post by Jose helped you out as much as it helped me How to run some code every few hours in Phoenix framework?

That's exactly what I used and got that feature from.

Then putting things together I used the ludu.com Elixir/Phoenix tutorial and learnelixir.tv (I had to watch a lot of those videos more than once).

One thing that I will say is annoying is the change from Phoenix 1.2 to 1.3 because it emphasized contexts more (which is good, but something I wish they did earlier).

One reason I'm a little hesitant with Elixir (mainly Phoenix) for now is how drastically the framework changed. I remember watching a talk with Chris Mccord where someone asked him if changes like this would be common. It'll probably settle down in the future, but still has me a little cautious.

There's going to be a Programming Phoenix 1.3 book, but I'll honestly say the prior book had me confused when I first started.

Used this for graphql:
GitHub - absinthe-graphql/absinthe: The GraphQL toolkit for Elixir

The docs it links to are pretty informative, also using absinthe-ecto really made the queries/mutations much more pleasant. learnphoenix.tv shows a quick graphql app.
 
Last edited:

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,292
Reputation
5,551
Daps
83,491
the rails tutorials are way better than the node tutorials, but a lot of the jobs want node
 

KritNC

All Star
Joined
Jun 5, 2012
Messages
3,440
Reputation
610
Daps
4,085
Reppin
Costa Rica
the rails tutorials are way better than the node tutorials, but a lot of the jobs want node
Yea we are switching from Rails to Node at my job. I am excited about it but I am also set myself apart from the rest of the team because I have a strong understanding of Rails so I am going to lose that edge on my coworkers.

Apparently, all of our new dev work will be done in Node but we will keep maintaining our Rails apps as needed by clients.

We have a huge monolithic Rails app with a couple hundred thousand lines of code so I am curious to see how management tries to split this up into microservices w/ node.
 

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,292
Reputation
5,551
Daps
83,491
are you going to be using node and express or some other framework?
 

Obreh Winfrey

Truly Brehthtaking
Supporter
Joined
Nov 18, 2016
Messages
20,706
Reputation
25,201
Daps
131,209
I don't know how to feel about this brehs. I send my interview availability about 2 weeks in advance. Radio silence, then an email out of the blue confirming my interview 2 damn days before it's supposed to happen. I might have to turn them down on this, I don't like short notice operations.
 

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,292
Reputation
5,551
Daps
83,491
I wouldn't turn them down, but I'd keep my options open. At the least, you can get experience conducting interviews by going to it.
 

Obreh Winfrey

Truly Brehthtaking
Supporter
Joined
Nov 18, 2016
Messages
20,706
Reputation
25,201
Daps
131,209
Hmm. I'll mull it over for a little while longer. I think part of the reason I'm thinking of pulling out is because I had what I feel to be a fairly successful interview at a larger company recently and I feel I'll land that position. But that's just me counting my chickens before they hatch.
 

Arithmetic

Veteran
Supporter
Joined
Mar 6, 2015
Messages
49,338
Reputation
14,463
Daps
262,204
air force my dude... but i wont even pretend to know about developing...
Not even talking about developing lol but I know you're getting to the money, and that's what everyone is here for. You said before you're an IT architect. What does it take? I can ask this in the IT thread if you're down to share.
 

dtownreppin214

l'immortale
Supporter
Joined
Apr 30, 2012
Messages
55,308
Reputation
10,501
Daps
190,880
Reppin
Shags & Leathers
So I have a repository on Github with my website in it. I uploaded all the folders/files last night. It's working fine, but I have no clue how I use Git to commit changes/updates. I already have Git installed and setup, what do I do next. PM me if you can help with step by step commands. Thanks.
 

Renkz

Superstar
Supporter
Joined
Jun 12, 2012
Messages
7,814
Reputation
2,310
Daps
18,032
Reppin
NULL
So I have a repository on Github with my website in it. I uploaded all the folders/files last night. It's working fine, but I have no clue how I use Git to commit changes/updates. I already have Git installed and setup, what do I do next. PM me if you can help with step by step commands. Thanks.
I just pm you
 
Top