• Breaking News

    Tuesday, January 12, 2021

    I finally made a completed app in c++ learn programming

    I finally made a completed app in c++ learn programming


    I finally made a completed app in c++

    Posted: 11 Jan 2021 10:37 AM PST

    First off I am only here to show off my project so if you care keep reading lol.

    So I am 15 and having been programming in c++ for a while now and I have started many projects however I rarely see them through to the end and even then have never been confidant in the final product. I finally built something cool that is finished and here it is on github. It is a gui based app built off of mailguns api to send email in mass. I was hoping to provide a default server and key in it but apparently I was banned on mailgun. Hopefully in the near future I can get this running on plain stmp however I would have to own a server. Feel free to post my code in r/programminghorror or r/badcode as long as you link it in the comments so i can learn lol.

    submitted by /u/ultimategamester309
    [link] [comments]

    I created a list of resources that I found interesting for programmers

    Posted: 11 Jan 2021 06:29 AM PST

    Hey there. I like to bookmark and keep things I found interesting or that were useful to me at some point. Today I decided to share some of the articles, guides, and tools I liked with you, the list might seem a little random but I try to arrange it the best I can. I hope it may come in handy or at least interesting to some of you :)

    Guide/Courses/Threads

    Advanced Compilers: The Self-Guided Online Course

    The Definitive Guide to Approaching Tough Coding Interview Problems When Blanking Out or Stuck

    Guide to Learn CS Online

    150+ Stanford On-Campus Computer Science Courses Available Online

    A Comprehensive (and Animated) Guide to InnoDB Locking

    Developer Handbook 2020 - An opinionated guide on how to become a professional Web/Mobile App Developer

    A How-To Guide go from Zero to Finding a Job at a FAANG Company

    Object Storage: Everything You Need to Know

    How we built the GitHub globe

    Introducing Cloudflare Pages: the best way to build JAMstack websites

    Fun & Effective Online Learning A better way to learn to code websites, apps, games, and more.

    General

    A collective list of free APIs for use in software and web development

    Roadmap to becoming a web developer in 2021

    Web Authentication Methods Compared

    The code behind Quake's movement tricks explained (bunny-hopping, wall-running, and zig-zagging)

    How I stole the data in millions of people's Google accounts

    Reverse Engineering the source code of the BioNTech/Pfizer SARS-CoV-2 Vaccine

    MIT programmed AI that can design its own robots

    Deep algebra for deep beats: The beautiful sounds of musical programming

    A collection of operating systems, online services and other miscellaneous tools to help the average user fight for their privacy and security online.

    submitted by /u/AdditionPartition
    [link] [comments]

    Python 101 by Mike Driscoll is currently free

    Posted: 11 Jan 2021 06:43 PM PST

    How long did it take you before you coded something useful?

    Posted: 11 Jan 2021 10:22 PM PST

    I am learning coding now and I see how much there is to learn until I can make anything remotely useful.

    How long did it take you until you created something useful even if it was small. Can be an add-on, game mod, app, anything novel really. By useful I mean something that made your life easier, you sold it or made a contribution in some program, or simply something that did not exist before etc. Also please include what language you are referring to.

    submitted by /u/Gatsby_DiCaprio
    [link] [comments]

    Failed My Technical Interview, feeling like not good enough

    Posted: 11 Jan 2021 10:09 PM PST

    Gonna be a long post just needing to vent and hopefully get some insight.

    tldr: Just feel like I'm not cut out for it now after failing my first real interview, didn't go to school for cs.


    Just a bit of background, I did not go to school for CS , or any dev type field. To be honest, I only wanted to make it a career because of my passion for video games so I picked up Gamemaker I got funded on KS about 2 years ago on KS, and realized I probably would need to take up a job since I wont be taking a cut of the cheese and would take care of my employees while also paying my own bills and cover local advertising costs.

    I got into web dev and it seemed pretty easy and fun too, got a very entry level job in it, and have been working there for the past year or 2, while learning and taking in everything. However the current job I'm at they don't seem to really follow modern web dev practices, but it did teach me everything I need to know to get started and make something from A - Z for front and backend albeit even if I don't make the UI designs majority of the time and use templates most of the time.

    I figured it was time to move on since it seems like I probably won't learn much more about the industry with my current employer nor will it improve my living conditions. So I got a reply back from a company which I had an interview today, I always heard that during the interview or technical part is where many people tend to fail.

    NOW: The Whole Interview happened over a google meets. Truth be told I feel like I did very poorly, aside from the fact that I was running on 4 hours of sleep, I didn't read the interviewers questions properly and made plenty of mistakes, granted the guy was nice and patient and allowed me to correct my mistakes while asking if I understood why my code didn't run. It also didn't help that I was insanely nervous and the 2 interviewers seemed like they were on a very strict and busy schedule.

    After a bit of the technical part the CEO got a call on his phone and told me he wanted to talk more about the company. He Showed me the Software and his backend and explained to me the process step by step of his business and what kind of work he expects, it seems he's only got 1 developer currently running everything and needs another guy to delegate the tasks.

    After He Explained everything he asked If I had any questions, which I asked more about his in house software , the location of the job , and if the job was remote. I told him that if he were to hire me I'd have to give a 2 weeks notice for my other 2 jobs that I'm currently working which he did not seem happy about but If I I were to work remotely I can start immediately.

    He left after answering my questions and Told me to follow up with him at the end of the week through Phone. I was left alone with the guy conducting the technical aspects, I was able to correct my other mistakes but the second and third examples is where I messed up on, and again asked if I knew what I had done wrong. After a few seconds I explained to Him why my code messed up and asked if he understood what I meant, to which he promptly replied "Not really but it seems that you get it for the most part, I have to go now so I'll talk with you later".

    He offered me to look through to google the answer, but I was determined to try and solve it myself, I realize the joke of stack overflow , but I felt like if I couldn't do it myself then I def wasn't ready to enter the company maybe it was a mistake not to.

    I emailed both the CEO and the Technical Interviewer back thanking them for their time and apologized for the mistakes, I sent them the fixed working code as well.

    But I was left with a very dreaded feeling in my stomach. It just feels like I'm not cut out for it and doubts began to wash in, asking if I could ever even enter that industry with my limited knowledge and skills. If you want to know, I later researched the interview question and it was called the "two sum" question, which I used the brute force method instead of the more advanced , cleaner and faster stuff shown in the answers.

    Sorry for the vent and rant. Just wanted to know if anyone else felt the way and what they did to cope with it. Although I have the employers number I'm very doubtful I'll get the job due to my failures.

    submitted by /u/Yukihime07
    [link] [comments]

    Holy moly I just started learning and am already super excited

    Posted: 11 Jan 2021 01:18 PM PST

    So I posted here yesterday about qualities of a programmer. Today I started the free Harvard course and the first problem set is to create something on scratch. I finally decided to recreate Pong (idk if it's been done but I just thought of this on my own). I'm working on ball movement and am already super excited to have someone try my program! Just wanted to give a small update lol.

    submitted by /u/qhartz_
    [link] [comments]

    Change output in Python web3

    Posted: 11 Jan 2021 11:40 PM PST

    Hello,

    I'm BM. A very nice and polite guy.

    I get some odd characters in the output here. What I really want is an etherscan hash .

    Actual output:

    b'$\x85.&(\xc2\r%\xdf\xd0v\x03\xba\x94\xfd\xd6\xa1i`\xd9\xc3\x17\x0b\x91\x1a\xa2E\x8c%\xd0\xd7\x1c'

    Desired output: normal hash

    Does anyone know how I can modify the script to get a normal hash instead?

    Script below.

    transaction = dai.functions.transfer('0xafC2F2bBD4173311BE60A7f5d4103b098D2703e8', 0x10).buildTransaction({'chainId': 4, 'gas':70000, 'nonce': w3.eth.getTransactionCount('0x5b580eB23Fca4f0936127335a92f722905286738'

    )})

    signed_txn = w3.eth.account.signTransaction(transaction,'0x2654kjnsdfg')

    txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)

    print (txn_hash)

    submitted by /u/MountBlanc
    [link] [comments]

    After doing something non-programming for a bit can you program at the click of a switch or do you need a few hours to marinate at your chair before you can show anything worthwhile?

    Posted: 11 Jan 2021 11:30 PM PST

    This is geared to those who are in the same boat of unemployment and grinding to their first programming job.

    It definitely takes me a good hour of just being at my comp before I can start actually typing something. But if I don't then program a few days straight from that point the cycle repeats and nothing gets done. But for those few days, it's just a blur of code. And then being burnt out. No caffeine somehow either.

    Something about this routine tells me that maybe my mediocre coding knowledge is keeping me procrastinating?

    And I'm not sure if being able to code in a 9-5 atmosphere 5 days week stamina is achievable and is holding me back.

    Has any veteran, once a newbie, experienced this?

    submitted by /u/DonnieBear9
    [link] [comments]

    What to do when a program isn't working properly, but produces no error and is functionally similar to code that does work?

    Posted: 11 Jan 2021 08:48 PM PST

    What I mean is that I have code that is supposed to run, but is being skipped. I know it is being passed over because code written before and after it runs. It is also written properly. It is written in python, so if it wasn't, it would've stopped me before it even tried. I even made sure manually by copying the code from the book I was reading nearly word for word (just changed some variable names). The same code works with the example materials given, but in my code, it doesn't even run, much less produce an error message telling me that something is amiss. I have been stuck on this for months. I have searched google high and low, but all the tips I come across say the same thing, all the code I see is similar to what I wrote. I cannot afford to come back to it later since it is an important function. So, hear I am asking again: how do I resolve code not running, but not producing an error?

    I would post it here, but the rules say it has to be short and concise and my code is anything but. I don't know how to condense into something smaller since it is made using many function calls that call other functions in turn.

    submitted by /u/Noboty
    [link] [comments]

    Python3 yield generator

    Posted: 11 Jan 2021 10:42 PM PST

    to read a file line by line I use this code :

    with open("sample.txt",'r') as filename:
    for line in filename:
    print(line)

    Is it possible to use a yield generator to do this?

    submitted by /u/Tom_Raines
    [link] [comments]

    Best way to get started in coding/programming/software engineering?

    Posted: 11 Jan 2021 06:25 PM PST

    Hi everyone, so I've always had big interests in tech ever since I was little, I loved messing with computers. But I never really got into the deeper engineering aspects such as coding, programming, web developing etc. well after I started working in my current job for a couple of years, I realized I was wrong to listen to my family to not pursue a career in tech. I realized that if I'm going to be going to a job for the rest of my life, it needs to be something that I'm interested in. And that would be tech.

    So with all that said, I'm wondering what is the best way to get started? School or self teaching? I've done some research, and even subscribed to a pretty cool Instagram software engineer on YouTube, who went to Northwestern and got his bachelor's degree in CS. But in one of his videos he made it clear that almost none of the classes he took was worth it, relevant, nor really helpful when it came to the real world. And like a lot of people have said, there's so much resources online you definitely have all that you need to become familiar with all the fundamentals and get started.

    But then again, since my ultimate goal would be having a career change and transition into a tech company (tech giants would definitely be a goal and dream) I figured school would still be necessary. I know with tech it's different, it's something that relies on natural talent, experience and the right skills instead of a degree. (Especially when google has over 50% of engineers that doesn't even have a degree) But then again, having a degree from a top ranked computer science school would definitely make you stand out, out of the other thousands of qualified applicants, it sure can give you a higher possibility of at least getting an interview and be noticed, and have more opportunities on internships and special projects.

    So I'm just wondering what is the best way for me to start out? Enroll in a school right away or teach myself all that I need to know and then get a degree? A degree isn't cheap, so I wanna weigh everything out. Thanks everyone!

    submitted by /u/calebbogart7
    [link] [comments]

    YouTube programmer fear, quit, exclusion culture?

    Posted: 11 Jan 2021 04:59 PM PST

    I have notices that many software developers on youtube seem to be making videos convincing people to quit trying and to give up on software development and coding. I understand that some people are not cut out to be programmers as it is a tech and analytics heavy job, and doing it for the right reasons /a realistic veiw of the challenges ect; however it seems that with the trend I am seeing these youtubers are making videos on why self taught developers won't make it /why you shouldn't try/ why most fail /why I quit.... Instead of telling them all the things they need to know and explaining it in detail and being encouraging and helpful which some youtubers are. Is it all profit motive, click bait, pay to play (not attacking those who teach other I think that's essential) and fear of competition? I see I.T. /networking/software development /a. I./ industrial programming as the future and we need to let the self taught people into the circle too. (being one myself) being a pragmatic person to me it only makes sense to be honest and helpful upfront rather than fear mongering and elitism. Also so many tutorials I have seen on youtube for programming suck ass too and the videos have no setup or context or Indepth explanation and examples just typing with a bunch of jargon. Have you noticed this what's your point of view? I also notice many code camps are scams including ones in Prague where I am. Shouldn't the swdev community be more helpful, inclusive and friendly? Thoughts?

    submitted by /u/trippycomic
    [link] [comments]

    What language for my mobile app idea?

    Posted: 11 Jan 2021 09:49 PM PST

    For awhile, I was really struggling to figure out what to make my first program because I didn't know what common problem I had to solve. Then, I thought about how I have a hard time remembering to take my medications after I wake up then also before bedtime. There are days I struggle to remember if I took my medication and have accidentally either missed a dose or double dosed. Yes there are pill boxes but sometimes I lose the pillbox or accidentally put the medication in the wrong day or take from the wrong day so this would be a great alternative.

    I would want a morning alarm to go off and say something like "Good Morning! Please take your medication, then touch this area when you're done." There would be some area to touch. Since it would probably be used most by senior citizens, even though I'm not one, the area to touch would be large but not so large that you touch it by accident.

    I want a second alarm to go off at lunch to either congratulate someone for remembering their medication this morning or reminding them that they haven't taken it yet so please do so as soon as possible.

    A third alarm would go off near bedtime and follow the same process as the first alarm but there would be no fourth/reminder alarm in order not to wake someone up.

    I would also like alarm to display messages after pressing the button that confirms medication was taken--random motivational message in the morning and random calming message wishing the person a good night for evening alert.

    In addition to the alarms, I would like the option to program in an emergency medical contact's phone number for text alerts. I would like the app to send a text message to the person's emergency medical contact when the button is pressed to confirm medication has been taken. The app also needs to send a text if the person has not pressed the button by the time it's 30 minutes after the second alarm reminder--same if the process for night time: text once they press the button or text if they have not pressed by 30 minutes after. This will allow the emergency contact to keep updated on the person's safety and contact them if they haven't seen the updates.

    I really have barely any clue on app development. I'm just starting python as my first language currently, using Jose Portilla's classes on Udemy. However, I'd be willing to abandon the language in order to accomplish this goal because this app is important to help my well-being and ease the minds of my relatives.

    submitted by /u/nick4networking
    [link] [comments]

    Possible pathway?

    Posted: 11 Jan 2021 04:28 PM PST

    I posted this in learnjava but got very few responses. Was hoping learnprogramming could offer more support, thanks.

    Hi all,

    This year I've decided I'm going to stop my complaining and put in the work to become some kind of Java developer. Through various online research, I've found some online courses which supposedly will help me achieve my goal. As some background, I have a CS degree too.

    Helsinki Mooc - Java Programming I & II [https://java-programming.mooc.fi/]

    Object-Oriented Java Programming: Data Structures and Beyond Specialization [https://www.coursera.org/specializations/java-object-oriented#courses]

    Learn SQL Basics for Data Science Specialization [https://www.coursera.org/specializations/learn-sql-basics-data-science]

    Java Programming and Software Engineering Fundamentals Specialization [https://www.coursera.org/specializations/java-programming#courses]

    1. The desire (and hopefully attitude) is there, I was hoping to get advice about the courses I've found, what I am missing.
    2. Secondly how to manage them all, for example, Helsinki on Mondays, OOJP on Tuesdays, SQL Wednesdays etc. Or complete one course at a time?
    3. I've been told that I need to learn Spring Boot and the Spring Framework but not sure which is the best resource to do so, Coursera doesn't seem to good in this department.

    All feedback would be greatly appreciated. Happy to answer questions or provide more information if and where needed.

    submitted by /u/HA_RedditUser
    [link] [comments]

    Am I supposed to be able to answer Leetcode problems without compiling to check for bugs?

    Posted: 11 Jan 2021 07:09 PM PST

    I'm constantly compiling to find the index out of bounds bugs or other similar ones I missed. Is that bad? During technical interviews am I expected to write a perfect answer on paper without the ability to press compile to check for bugs?

    submitted by /u/boxyboxers23
    [link] [comments]

    Does each Browser have their own default CSS for each HTML element?

    Posted: 11 Jan 2021 06:25 PM PST

    Does each browser have their own CSS for each HTML element and sometimes browsers can have the same CSS for the same HTML elements? Does each browser have the freedom to pick what type of CSS to do for default rendering for HTML elements?

    submitted by /u/mefanjunaid
    [link] [comments]

    Having an error using print on python

    Posted: 11 Jan 2021 11:51 PM PST

    I'm trying to print a list on python. It is showing me an error message of:

    File "<stdin>", line 11

    print(lista)

    ^

    Syntax error: invalid syntax

    The exact code I used is below:

    lista=[]

    listA=[]

    i=0

    while i<101:

    i=i+1

    if (i%2)==0:

    x=26*i

    else:

    x=26*(i-1)+1

    if (i%5)==0:

    listA.append(x)

    else:

    lista.append(x)

    print(lista)

    I've tried replacing print(lista) with print("apple") and that doesn't work either. But without any of the other code, print("apple") works fine, and when I remove all code in between and use only:

    lista=[]

    print(lista)

    it prints the empty list correctly. Essentially, the print function I used works only when it is not placed after the rest of my code. Can anyone help make sense of this? I'm using python 3.9 right now. I used on online python 3.6 simulator, and the code worked fine. I would appreciate some help on how to fix this

    edit: I used proper indentation but reddit is refusing to let me indent or tab

    submitted by /u/Vast-Treacle9791
    [link] [comments]

    Learning from a physical book: recommendations?

    Posted: 11 Jan 2021 05:27 PM PST

    Hi all,

    I'm looking for a career change in the future from ESL teaching to a more stable job and I have my sights on programming as a goal to manage this.

    At the moment I have quite a lot of free time but no access to a computer during that time. Could anyone recommend a good book I could use to study from in this downtime?

    Thanks!

    submitted by /u/MrC_Bear
    [link] [comments]

    How to get better....

    Posted: 11 Jan 2021 11:15 PM PST

    I have taken a python class, and even tried to study on my own. I always try my best yet I feel as though I get stuck very easily and am unable to figure out problems on my own :(. How can I assure that I become fluent?

    submitted by /u/brandymlover
    [link] [comments]

    Retrieving,rendering, and parsing multiple payloads in android using MVVM pattern and coroutines fails due to the lateinit viewmodel not being initialized.

    Posted: 11 Jan 2021 11:03 PM PST

    Hello all, I've been struggling with an issue in my practice android app to learn android development. I've finished a course on Udemy for android development which taught me the basics. I am trying to incorporate coroutines and other design patterns to try and build my app best way I can.

    My app is a stock/asset app. The app will let the user add assets they want to monitor like stocks, crypto, and ETFs to monitor. It's sort of like Robinhood but without the buying and selling part. The app has registration and sign in capabilities. I use Firebase to deal with login information and for database functionalities. The intended workflow is for a user to sign in, followed by my app retrieving the assets data that the user has decided to watch, and then rendering that data in a graph. The list of the user's assets is housed in the cloud firestore instance. Once this list is retrieved, my application will send an API request to get quotes on the assets the user is watching. After this request comes back, the data will be rendered in the app. I'm trying to keep things simple and render only the stock symbol and price in a recycler view for now.

    The frameworks I'm using are retrofit, GsonConverter, hilt, firebase, and kotlin coroutines.

    I'm going to only include the relevant functions in the code blocks below. Full runnable Code will available in my github repo (https://github.com/chrishernan/BatmanHood.git).

    The issue is in the API fetching and requesting art of the application. My ViewModel is not initialized before the rendering of MainActivity happens.

    MainActivity will deal with creating the ViewModel, RecyclerView and API interface (stockAndIndexApiHelper).

    Once the ViewModel is created with all the user's stock information, it will give the price and stock symbol to the recyclerView to render them.

    MainActivity.kt

    class MainActivity : BaseActivity() { @Inject lateinit var stockAndIndexApiHelper: StockAndIndexApiHelper lateinit var recyclerView : RecyclerView lateinit var viewModel: UserProfileViewModel override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) try { val userProfileModelFactory = UserProfileViewModelFactory( this@MainActivity, stockAndIndexApiHelper) viewModel = ViewModelProvider(this,userProfileModelFactory).get(UserProfileViewModel::class.java) } catch(e : Exception) { Log.d("FACTORY_EXCEPTION",e.cause.toString()) } observeUserProfileModel() initListeners() //Recycler View variables recyclerView = findViewById(R.id.asset_recycler_view) /*recyclerView.adapter = assetRecyclerViewAdapter recyclerView.layoutManager = LinearLayoutManager(this)*/ //Autocomplete variables val autocompleteTextView : AutoCompleteTextView = findViewById(R.id.autcomplete_search_bar) val autocompleteAssetList : MutableList<String> = mutableListOf("Amazon","Apple","Apples for me", "Apricot","Micron","Aircraft","Apple Pie", "Nio","Microsoft","Airbnb","Tesla","Sony","Bose","Delta Airlines","Google","Netflix") val autocompleteAdapter : ArrayAdapter<String> = ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,autocompleteAssetList) autocompleteTextView.setAdapter(autocompleteAdapter ) } private fun initListeners() { //TODO basically any listeners that are needed by main activity for buttons and stuff. } private fun observeUserProfileModel() { viewModel.autofillUSCompanyList.observe(this, Observer { //TODO -> when this gets updated or w/e we can let our app know we can autofill now. }) viewModel.getCurrentUserStockList.observe(this, Observer { //TODO re or re-render stocks list val rerenderingAssetRealTimeStockQuote = viewModel.getCurrentUserStockList.value?.let { it1 -> AssetRecyclerViewAdapter(it1) } recyclerView.adapter = rerenderingAssetRealTimeStockQuote recyclerView.layoutManager = LinearLayoutManager(this) }) } override fun onBackPressed() { doubleBackToExit() } } 

    UserProfileViewModel will hold all user data like the currentUser's stock companies, and the user itself.

    At initialization, it will retrieve the user information from firebase which contains the user's stocks. Then, it will send an api request to retrieve quotes on the user's stocks. There is also an API request to retrieve all US companies and this will be used for my AutoCompleteTextView Search Bar in MainActivity.

    UserProfileViewModel.kt

    class UserProfileViewModel(activity: Activity, stockAndIndexApiHelper: StockAndIndexApiHelper) : ViewModel() { private var _americanCompaniesList = MutableLiveData<HashMap<String,String>>() private var _currentUserStockList : MutableLiveData<LinkedHashMap<String,String>> private var _user : User init { _user = FirestoreClass(stockAndIndexApiHelper).getCurrentUser() Log.d("STOCK_VIEW_MODEL", _user.name + " " + _user.email) _americanCompaniesList = FirestoreClass(stockAndIndexApiHelper).retrieveAllUSCompanies() _currentUserStockList = FirestoreClass(stockAndIndexApiHelper).fetchUserStocks(_user) } val autofillUSCompanyList : MutableLiveData<HashMap<String,String>> get() = _americanCompaniesList val getCurrentUserStockList : MutableLiveData<LinkedHashMap<String,String>> get() = _currentUserStockList val user : User get() = _user fun refreshAutofillCompanyList(){ //TODO run firestoreClass task } override fun onCleared( ) { super.onCleared() //Get rid of all subscriptions to avoid memory leaks } } 

    The FirestoreClass below is the repository class in my app. This will handle all API calls from sign in, registration, and all API requests to retrieve stock information.

    This class will also parse and filter responses that we are getting from retrofit. The responses will then be returned up all the way to UserProfileViewModel as LiveData objects to observe them in MainActivity.

    FirestoreClass.kt

    class FirestoreClass(private val stockAndIndexFetcher: StockAndIndexApiHelper) { private val mFireStore = FirebaseFirestore.getInstance() val ioScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) private var mStockList: HashMap<String, String> = hashMapOf<String, String>() private var americanCompanyMap : HashMap<String, String> = hashMapOf<String, String>() private lateinit var mUserName: String fun getCurrentUser() : User{ //creates an empty, default user. Check email or name is empty to validate var loggedInUser: User loggedInUser = mFireStore.collection(Constants.USERS) .document(getCurrentUserID()) .get() .addOnSuccessListener { document -> Log.d("SUCCESS_GETTING_USER","Successfully retrieved user from firebase") }.addOnFailureListener{ e -> Log.e( "FAILED_TO_GET_USER", "Error while getting logged in details -> ${e.toString()}" ) }.result?.toObject(User::class.java)!! Log.d("LOGGED_IN_USER","right before logged in user is returned ${loggedInUser.name} -") return loggedInUser } /** * Retrieves user retrieve data from firebase database */ fun loadUserData(activity: Activity) { mFireStore.collection(Constants.USERS) .document(getCurrentUserID()) .get() .addOnSuccessListener { document -> Log.e(activity.javaClass.simpleName,document.toString()) val loggedInUser = document.toObject(User::class.java)!! when(activity){ is SignInActivity -> { activity.signInSuccess(loggedInUser) } //is MyProfileActivity -> { } } }.addOnFailureListener{ e -> when(activity){ is SignInActivity -> { activity.hideProgressDialog() } } Log.e( activity.javaClass.simpleName, "Error while getting logged in details" ) } } /** * This takes in a [user] and returns all the users stocks in a LinkedHashMap for rendering */ fun fetchUserStocks(user: User) : MutableLiveData<LinkedHashMap<String,String>>{ //val listOfLiveData: MutableList<MutableLiveData<RealTimeStockQuote>> = mutableListOf() //val stockLiveData: MutableLiveData<RealTimeStockQuote> = MutableLiveData() var listOfRealTimeQuotes: HashMap<String, HashMap<String, RealTimeStockQuote>> var mapOfUserStockSymbolAndPrice: LinkedHashMap<String, String> runBlocking { withContext(Dispatchers.IO) { listOfRealTimeQuotes = stockAndIndexFetcher.getMultipleStockQuotes( user.stock_list.joinToString(separator = ","), "quote", Constants.IEX_TOKEN) } mapOfUserStockSymbolAndPrice = parseUserStocks(listOfRealTimeQuotes) Log.d("SUCCESS_FETCH_USR_STCKS",mapOfUserStockSymbolAndPrice.keys.toString()) } val mutableLiveDataWrapper = MutableLiveData<LinkedHashMap<String,String>>() mutableLiveDataWrapper.value = mapOfUserStockSymbolAndPrice return mutableLiveDataWrapper } /** * This is used for our autocomplete functionality */ fun retrieveAllUSCompanies() : MutableLiveData<HashMap<String,String>>{ var americanCompaniesMap : HashMap<String,String> = hashMapOf() val americanCompanies = MutableLiveData<HashMap<String,String>>() runBlocking { withContext(Dispatchers.IO) { try { americanCompaniesMap = parseAutofillJSON( stockAndIndexFetcher.getAllUSCompanies(Constants.IEX_TOKEN)) Log.d("SUCCESS_STOCK_US_COMP",americanCompaniesMap.keys.toString()) } catch (e : Exception){ Log.e("STOCK_EXCEPTION_US_COMP",e.toString()) } } } americanCompanies.value = americanCompaniesMap return americanCompanies } private suspend fun parseAutofillJSON(listOfCompanies : List<AutofillCompany>) : HashMap<String,String> { var companySymbolAndNameMap : HashMap<String,String> = hashMapOf() withContext(Dispatchers.Default) { listOfCompanies.map { companySymbolAndNameMap.put(it.symbol.toString(),it.name.toString()) } } return companySymbolAndNameMap } /** * This parses through all the RealTimeStockQuotes and returns only two argumens for now * @returns Stock symbol and current stock price * todo figure out a way to make the database sort your assets alphabetically */ private suspend fun parseUserStocks(listOfRealTimeQuotes : HashMap<String,HashMap<String,RealTimeStockQuote>> ) : LinkedHashMap<String, String> { var linkedHashMap = LinkedHashMap<String, String>() withContext( Dispatchers.Default) { listOfRealTimeQuotes.values.map { it.get("quote")?.let { it1 -> linkedHashMap.put(it1.symbol.toString(), it1.latestPrice.toString()) } } } return linkedHashMap } /** * A function for getting the user id of current logged user. */ private fun getCurrentUserID(): String { // An Instance of currentUser using FirebaseAuth val currentUser = FirebaseAuth.getInstance().currentUser // A variable to assign the currentUserId if it is not null or else it will be blank. var currentUserID = "" if (currentUser != null) { currentUserID = currentUser.uid } return currentUserID } } sealed class FirebaseAuthUserState data class userSignedIn(val user: FirebaseUser) : FirebaseAuthUserState() object UserSignedOut : FirebaseAuthUserState() object UserSignedIn : FirebaseAuthUserState() 

    This is where the problem is. I'm using kotlin coroutines to handle thread intensive tasks like parsing information and for my api requests. I'm pretty sure I'm doing this wrong as I am using RunBlocking and WithContext(IO) for API requests and WithContext( Default) for parsing the data. I thought this would wait before rendering Main Activity, but that does not seem to happen. The whole point of using coroutines is so that the main/UI thread in MainActivity is not impacted. But, I've done a bunch of googling and read all kinds of articles but I haven't been able to find a solution. Or I guess I don't understand android as well as I thought.

    I've used async, await but the issue remains since ViewModel is waiting for a response while MainActivity starts to render. My current idea is to use the navigation pattern and turn the main activity into a fragment and have a loading screen fragment. While the ViewModel is fetching all the data, the loading screen fragment will be displayed to the user. When the data has been fetched, the frame manager will then load the main activity fragment and render the recyclerView.

    I know my code is probably terrible and novice, so any constructive critiques/suggestions are welcome. I'm trying to learn good programming skills and get a SE job in the near future

    submitted by /u/gamerCtC6669
    [link] [comments]

    Beginner Courses - Changing Routes

    Posted: 11 Jan 2021 04:36 PM PST

    Just thought I would share my experience for those deciding what course they should complete. I started with Colt's Web Developer course on Udemy since it was redone, but have decided to switch to a different course.

    At first it was great, I was hyped up about finally learning something I have wanted to do on the side of my original career (I'm a firefighter). Then it eventually started to dwindle down... I was less excited to just listen to someone speak and code. I needed hands on things, direction on projects to build and where to start. There is no practical hands on projects I think that help build the foundation I need. Of course there is 'code-alongs" but I personally think that doesn't benefit me at all, as I am just copying down whatever he does.

    Again, I like Colt, and his course is packed with information, I would still give it 4/5 stars, but it is not for me. I am a hands on person, it's why I became a firefighter, and it is why I want to become a developer as well.

    So I have decided to try the Odin Project, as I have read there are more hands on projects that I can dive into, and probably fail, but hey you gotta fail to learn!

    Hope this helps anyone who is like me and desires more hands on learning. But don't take my word for it! It is a good course and if you decide to try it you may like it.

    Now I shall go stumble my way through TOP.

    Cheers!

    submitted by /u/Clark-Coding
    [link] [comments]

    What should be my next step?

    Posted: 11 Jan 2021 06:39 PM PST

    Hi, English is not my mother-language, sorry if I make some mistakes.

    First of all, I am at the career of software engineering , I wanted to learn programming for a long time because I want to have some advantage over my classmates and I like coding or thats what I think, but I believe that I am stuck at the tutorial hell because I don't know what programming language should I learn or what should I do.

    I know the basic concepts like conditionals, variables, loops and so far, but always I get stuck at this and I only make basic proyects like TicTacToe.

    I read many guides but they all say the same thing, that I practice and learn more.

    Also, I don't know which paths a software engineer could choose.

    submitted by /u/El_Curios0
    [link] [comments]

    Is python really the easiest language? It is the 3rd time in last 3 years that I attempted to learn through another book and still find it confusing.

    Posted: 11 Jan 2021 04:48 AM PST

    I have tried through online courses like MIT which was a disaster. I don't understand the hype about this course. Terrible video quality and poor explanation. Then I tried the Automate the boring stuff which had many mistakes and poor explanation also. For the last year I am learning with the Crash course in Python which is the most helpful of all tbh. I have almost finished it and still don't get most of it. Every part until a certain point is OK. Then it gets overwhelming. If this is a beginner's book then I am really worried about the advanced part.

    But still find the syntax confusing. I dont understand why some things are done a certain way and why is this the way it should be done. I dont have experience with other languages except some of C++ which I forgot almost entirely, but I think that something is not quite right with this one. It is like trying to justify a foreign language as easy by people who have grown with it, when in fact it is fucking absurd (english is one of them the way it pronounced although I understand it well - not a native speaker).

    If this is truly the easiest language I give up. I will try something else. Maybe programming is not for me.

    submitted by /u/Jesus_was_on_DMT
    [link] [comments]

    Junior (or not junior) experience doubt

    Posted: 11 Jan 2021 09:54 PM PST

    Hi!

    I sometimes have an issue where I am not sure how to tackle it, so I would like to ask you what you do in these situations.

    I have to compile/create a program and send it to a client. The process is usually the same one. After compiling the application, I test it and it works, but when I send it to the client, he/she says that it is not working. My boss downloads the app and also verifies that it is not working.
    I say: ok.... let's do it again.

    I do the test and it is actually failing. So I recompile, test it 3 times. Once from the debugger, once from uninstalling and installing the app, and once from the download link (I download the app from the link and then install it). Everything is great, everything is working. So I send it again. And then it fails again.

    How can I approach to this situation? I have had many times this type of experience with this project and I am tired of staying like a fool in front of my boss, because it is as if I did not test it at all. I don't want to give him/her excuses, but I DID actually test it many times.

    submitted by /u/Mxlt
    [link] [comments]

    No comments:

    Post a Comment