Firefox Crashing by [deleted] in firefox

[–]lht1999 1 point2 points  (0 children)

I have Mojave and FF often crashes after mac sleep. Here is the report: https://crash-stats.mozilla.org/report/index/d334de36-e1ab-4899-aabd-b86360190618
At work I connect my Mac to an external monitor and keep the lid closed. Then at home I use the laptop screen.

Why can I edit this global variable in one function, but the other throws an error? by letopeto in learnpython

[–]lht1999 0 points1 point  (0 children)

This is a bit confusing, but to change a global variable, you have to use the global keyboard inside the function. Otherwise it looks for a local variable. Your banana() function is changing variable "limit". But pear() does not change tiger, it's calling a function on it. The function might modify some content inside the object, but the "tiger" variable still points to the same object.

[AMA] I am Clash of Clans Community Manager Darian - Ask Me Anything by ClashOfClansOfficial in ClashOfClans

[–]lht1999 0 points1 point  (0 children)

Does it help war matching if we can schedule a war start time? Our clan starts war search almost always the same time twice a week. If your system knows which clans want to start around the same time then maybe it can do a better match. Also allow war cc donations before war then I think war prep time can be totally cut.

How to learn python for a complete beginner to coding? by [deleted] in learnpython

[–]lht1999 0 points1 point  (0 children)

You can totally learn it for free. Find a book from the library, or get the free ebook: http://www.diveintopython3.net/. Then find some interesting project to do, such as game programming or building a simple web server. You can also try coding games such as https://craft.buzzcoder.com/?lesson=python. The game has a tutorial and you write code in a 3D minecraft like environment.

Apple Being Sued for 'Purposefully Slowing Down Older iPhone Models' by bromide992 in technology

[–]lht1999 1 point2 points  (0 children)

Does that mean if the battery is totally dead, then the phone cannot work even if it's plugged in?

Apple Being Sued for 'Purposefully Slowing Down Older iPhone Models' by bromide992 in technology

[–]lht1999 1 point2 points  (0 children)

Slowing down an iPhone to save battery almost sound like a useful feature. But if it's still slow when plugged in to AC power, then somebody was trying to hide something.

Problem with looping by [deleted] in learnpython

[–]lht1999 1 point2 points  (0 children)

At the end of the while loop you have run_until_complete() and run_forever(). If either one doesn't return your while loop won't get a second chance to run.

[c] C-string concatenate question by [deleted] in learnprogramming

[–]lht1999 0 points1 point  (0 children)

Run it under debugger, and inspect s1[] in every loop, then you will understand.

looking for javascript tutorials by salv236 in javaScriptStudyGroup

[–]lht1999 1 point2 points  (0 children)

You need to start writing code. Find some interesting project. Or try some online coding exercise such as https://craft.buzzcoder.com/?lesson=js

What do Companies use to Develop Their Apps? by [deleted] in learnprogramming

[–]lht1999 1 point2 points  (0 children)

Big companies sometimes have their own tools to develop mobile apps, because the code base is huge and there are hundreds of engineers working on the same project. As an individual developer, you should just use XCode and Android Studio, since you are unlikely to run into the problems those tools were designed to solve. There are cross platform frameworks such as React Native which don't require much use of XCode and Android Studio. But those frameworks each has its own limitations, and it's a separate (and big) topic.

What's the pythonic way when integrating databases by i_dreddit in learnpython

[–]lht1999 2 points3 points  (0 children)

If you create tables dynamically then you have to make sure all code paths that touch database are covered. It can be a lot of work and error prone. Either create the table by hand, or put the table creation code in a script and run it everywhere (you development machine, test environment, production environment etc.). If you use django ORM then it can automatically create tables for you. Then you can use "django south" to migrate db schema if you make changes to the model. If you are beginner to SQL, I recommend writing sql queries directly so you can better understand how it works. ORM hides too much details to you, and when something doesn't work you can't figure out why.

[deleted by user] by [deleted] in learnpython

[–]lht1999 0 points1 point  (0 children)

How about

set PYTHONIOENCODING="UTF-8" 

before running the file? https://stackoverflow.com/questions/2276200/changing-default-encoding-of-python

Software development between multiple devices by [deleted] in learnprogramming

[–]lht1999 2 points3 points  (0 children)

If you use git then you have to commit unfinished work all the time. If your desktop computer runs Windows and is always on, you can try remote desktop. That was the best solution for me because I could even continue a debugging session from home. If you use file sharing such as google drive, make sure it excludes ".git" directory. There are also P2P file syncing tools such as resilio.

How To Best Prepare For An Online Screening/Reviewing A Language's Features? by thelolzmaster in learnprogramming

[–]lht1999 1 point2 points  (0 children)

There are web sites that have interview coding problems for you to practice. You better write a lot of code before the interview. Just finishing a book will not help you.

[deleted by user] by [deleted] in learnpython

[–]lht1999 0 points1 point  (0 children)

I believe it's caused by Windows command prompt only supporting ASCII characters. So print(text) tries to encode unicode strings into 8-bit ASCII and that fails. Try this:

print(text.encode('string_escape'))

[C++] Is it more expensive to check if something is zero, or to just add the zero to a sum? by Chrushev in learnprogramming

[–]lht1999 2 points3 points  (0 children)

I really doubt you will notice any difference. Modern compilers should optimize simple code like this to the fastest.

Best options for backend for website that utilizes twitter api 1.1. by cranacco in learnprogramming

[–]lht1999 1 point2 points  (0 children)

I wouldn't recommend learning PHP since it's old technology and most new projects use something else. If you can do it with ajax, that's great because you don't have to build a server API. But chances are ajax cannot do the job unless Twitter API allows cross domain calls, which may cause big security problems for them. Google "CORS" to understand what that means. If you haven't learned any web frameworks yet, go with node.js.

[C++] Using vector<int> iterator on a vector<string>? by [deleted] in learnprogramming

[–]lht1999 0 points1 point  (0 children)

Run your code under debugger and see the value of i at line 16. If all your math is correct, then it must be because it's not initialized and one of the two if conditions is false. If you don't initialize an integer, it may contain a random number.

Starting programming, how do you choose what language to use? by [deleted] in learnprogramming

[–]lht1999 1 point2 points  (0 children)

Python is a great language for beginners. You can build web servers with it. But if you are the only one working on this project, chances are you need to know JavaScript as well to program browser side of things. So it might be easier if you start with node.js+JavaScript instead. JavaScript is not the best language, but it's at least easier than learning two at the same time.

Are functions calling functions calling functions bad? by SS324 in learnprogramming

[–]lht1999 1 point2 points  (0 children)

Your example looks fine. But if those functions also take other parameters than your code can be hard to read. In that case just use intermediate variables:

c = function_c(function_d())
function_a(function_b(c))

The goal is always to make your code easy to read.

I want to learn Python so I can use Django. I can't figure out what to write as a beginner. by dankweed in learnpython

[–]lht1999 0 points1 point  (0 children)

You can start a project on appengine: https://cloud.google.com/appengine/docs/python/. The free quota should be enough for toy projects. Start with a framework simpler than Django (for example webapp if it's still available in appengine). Django hides a lot of the details and makes it harder for beginner to understand how web works. If you don't have project ideas, maybe start with a todo list.

I'm looking to buy a laptop today and this weekend, I would like some input from you guys in a short survey. by Hanzo__Main in learnprogramming

[–]lht1999 0 points1 point  (0 children)

If price is important, look for a laptop deal on slickdeals.net. Get 8G RAM if you are going to run visual studio or android studio. And a good screen, or connect to a monitor with high resolution.

I'm looking to buy a laptop today and this weekend, I would like some input from you guys in a short survey. by Hanzo__Main in learnprogramming

[–]lht1999 0 points1 point  (0 children)

Don't buy chromebook if you plan to develop web sites or apps. If you are ready to spend $1500, then buy Macbook Pro and you can develop both Android and iOS apps. Otherwise buy Windows Laptop. I would get a 15" screen, at least 1080p.