i = 1
for veg in range(3):
print("Vegetable Name {} - {}".format(i, veg_name_list[i]))
i += 1
for veg in range(0,len(veg_name_list)):
print("Vegetable Name {} - {}".format(veg, veg_name_list[veg]))
Why are you using a loop variable 'veg' and then using i to access the array?
Code:i = 1 for veg in range(3): print("Vegetable Name {} - {}".format(i, veg_name_list[i])) i += 1
Why not do this:
Code:for veg in range(0,len(veg_name_list)): print("Vegetable Name {} - {}".format(veg, veg_name_list[veg]))
Also, are you supposed to keep track of all of the lists for the entirety of the program? I ask because you're emptying out the list every time the user enters another store.
veg_name_list = []
veg_plu_list = []
veg_order_quantity_list = []
Here's a hint. Arrays are 0 based, so you need to access item 0 with index 0, but when you print to the screen you can have the label be 0+1.
Vegetable Name 1 - bananana
Vegetable Name 2 - tomatoe
Vegetable PLU 1 - 1
Vegetable PLU 2 - 2
Amount to Order 1 - 1
Amount to Order 2 - 2
Vegetable Name 1 - bananana
Vegetable PLU 1 - 1
Amount to Order 1 - 1
Amount to Order 2 - 2
Vegetable PLU 2 - 2
Amount to Order 1 - 1
Amount to Order 2 - 2
Vegetable Name 2 - tomatoe
Vegetable PLU 1 - 1
Amount to Order 1 - 1
Amount to Order 2 - 2
Vegetable PLU 2 - 2
Amount to Order 1 - 1
Amount to Order 2 - 2
Why no do this:Why not do this:
Code:for veg in range(0,len(veg_name_list)): print("Vegetable Name {} - {}".format(veg, veg_name_list[veg]))
for num, veg in enumerate(veg_name_list):
print("Vegetable Name {} - {}".format(num, veg))
Why no do this:
Code:for num, veg in enumerate(veg_name_list): print("Vegetable Name {} - {}".format(num, veg))
I'd say that there's virtually never reasons to use integers in "for" loops in Python...
First, get used to comprehensions, enumerate and zip, then look at itertools. That REALLY worth your time, and often, it's far easier to write code with those tools.
Just use whatever you want and whatever database you want. No reason not to use MariaDB for the database.So here's a generalist design I guess question.
If someone was interested in building something like thetvdb.com, but for audiobooks just what would be a good choice of language and dbms? I'm mostly familiar with C# and MSSQL, but clearly that's not a good idea if I plan to make it a free public resource (assuming it becomes more than an idea).
Just MYSQL? or should I be looking at some kind of nosql thing? And if so where would be a good place to start?
Use SQL Server since it'll probably be the easiest to hook into your C# project.
It's being ported to Linux soon so you could use it depending on your timeline.That's why I haven't started. I'm thinking I should be using something other than c#/mssql. Something that could run on linux servers alone has me questioning what I should do, let alone whether I should be using a sql database or not. Hence my question.
I'm really not understanding Javascript at all.
Code:function generateFunctionList(){ var fnArr = []; for( var i = 0; i < 3; i++){ fnArr[i] = function(x){ return function(){ console.log(x); }; }(i); } return fnArr; } var functionArray = generateFunctionList(); functionArray[0](); //Expect 0? functionArray[1](); //Expect 1? functionArray[2](); //Expect 2?
How does functionArray[0](); even work as a call?
functionArray is generateFunctionList().
So functionArray[0]() = generateFunctionList()[0]()?
Or does that syntax somehow access element 0 of fnArr?
Like what the fuck is even going on in this code?
[first function, second function, third function]
var arr = ["hello", "world", "yo", "doge"];
console log(arr[2]); // "yo"
console.log(functionArray[0]); // function () {...}"
fnArr[i] = function(x){
return function(){
console.log(x);
};
}(i);
fnArr[i] = function(){
console.log(x);
}
for(int i = 0; i < exp; i++)
{
pow = pow * pow;
}
return pow;
package hello;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class GreetingController {
@RequestMapping(value="/greeting", method=RequestMethod.GET)
public String greetingForm(Model model) {
model.addAttribute("greeting", new Greeting());
return "greeting";
}
@RequestMapping(value="/greeting", method=RequestMethod.POST)
public String greetingSubmit(@ModelAttribute Greeting greeting, Model model) {
model.addAttribute("greeting", greeting);
return "result";
}
}
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Getting Started: Handling Form Submission</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Form</h1>
<form action="#" th:action="@{/greeting}" th:object="${greeting}" method="post">
<p>Id: <input type="text" th:field="*{id}" /></p>
<p>Message: <input type="text" th:field="*{content}" /></p>
<p><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></p>
</form>
</body>
</html>
Can anyone help clarify what exactly is happening here or what I'm missing? I've been looking online for a while but can't seem to find a clear explanation of it. Thanks in advance for any help.
The GET mapping creates a blank Greeting object and places it into the model.
Thymeleaf creates a form and binds the inputs to that object (looks like the object has an id and a content field). You can view the source HTML in a browser to see how the template wrote the true HTML.
When the POST happens Spring takes the id and content from the request params and creates a Greeting object with what was entered into the input fields. It then adds that object to the model and kicks back to a result.html (for display I would assume).
Although, if I'm remembering right @ModelAttribute would already add to the Model that gets returned. Otherwise it would act exactly like a @RequestParam.
Ah I see, thanks! That makes it a lot clearer.
Only thing I can think of for the @ModelAttribute is that maybe it adds to the model but the previous model as then a new model is defined in the parameters of the POST request? I would imagine that is why we still have to use model.addAttribute to add the populated Greeting object to the new model map for the results page?
At least I think that might be happening. As I said I'm pretty new to Spring MVC so trying to get the hang of it.
It was 11 lines, one function, and was a package on its own. It broke, and suddenly many, many big name projects started breaking, too. That sounds awfully brittle and chaotic to me.
console.log(ancestry.filter(function(person) {
return person.father == "Carel Haverbeke";
}));
console.log(ancestry.filter(person.father == "Carel Haverbeke"))
Why write:
Code:console.log(ancestry.filter(function(person) { return person.father == "Carel Haverbeke"; }));
Instead of just
Code:console.log(ancestry.filter(person.father == "Carel Haverbeke"))
console.log(ancestry.filter(false)); // Or true, depending on the value of person
person.father == "Carel Haverbeke"
function(person) {
return person.father == "Carel Haverbeke";
}
Why write:
Code:console.log(ancestry.filter(function(person) { return person.father == "Carel Haverbeke"; }));
Instead of just
Code:console.log(ancestry.filter(person.father == "Carel Haverbeke"))
Why write:
Code:console.log(ancestry.filter(function(person) { return person.father == "Carel Haverbeke"; }));
Instead of just
Code:console.log(ancestry.filter(person.father == "Carel Haverbeke"))
console.log(ancestry.filter(person => person.father == "Carel Haverbeke"))
Today was my first day on a Programmer Intern role and I did sod all. I spent most of the time trying to understand the codebase, tried to implement a solution to my first task in a cool way, failed, then spent the rest of the day implementing a longer solution which ended up having a serious bug, and finally padding that bug in the worst way possible. 10 hours of work and I only completed 1 task out of 6. The Lead Programmer wasn't mad or anything and initially said I can take as much time as I needed but I'm worried my work rate is far too slow for me to last here.
Any tips on how to understand a large codebase quickly? I'm mostly just bug-fixing now but I've never seen so many components in a solution before, and the company uses their own in-house engine so API documentation is pretty barebones so I have to rely on comments written by other programmers.
Read, ask, and try...Any tips on how to understand a large codebase quickly?
Does anyone have experience with image processing in python? I did a quick search and it appears that Pillow and OpenCV are the most recommended libs. I already used OpenCV before (though in Java), and had some problems with documentation. Anyone has some (other) suggestion, or these are the way to go?
What kind of image processing do you want to do? Still images in file form, or camera capture in real time?Does anyone have experience with image processing in python? I did a quick search and it appears that Pillow and OpenCV are the most recommended libs. I already used OpenCV before (though in Java), and had some problems with documentation. Anyone has some (other) suggestion, or these are the way to go?
Does anyone have experience with image processing in python? I did a quick search and it appears that Pillow and OpenCV are the most recommended libs. I already used OpenCV before (though in Java), and had some problems with documentation. Anyone has some (other) suggestion, or these are the way to go?
You'll probably want to look into numpy.
What kind of image processing do you want to do? Still images in file form, or camera capture in real time?
A lot of things can be done with just numpy & scipy...
Python 2 or 3, btw?
I've recently messed around a little with Pillow for Python.
It's a fork of PIL (Python Imaging Library). But since the author hasn't made an update since like 2011 it was forked by enthusiasts and thus we have Pillow.
I've only used it for basic things but it seems straight forward enough and there are tutorials online that will give you a basic grasp of how to use it. It worked fine for my basic needs.
I program in Python 3 and it worked fine for my needs. Not sure how complex you want go but there are lots of documentation if you want to go deeper and do advanced image processing.
A lot of things use Numpy (mostly because it's one of the most common way to have tables in Python), so yes, you won't be able to avoid it. At least, a lot of python distributions (Python(x,y) for Python, Pyzo for Python3k...) ship with numpy/scipy preinstalled.From what I read they both use numpy, and since I want something more "ready to use", I`m looking at these first before doing them myself.
As long as you don't need complex image algorithm ready to use, yes, you can probably do anything using Numpy and stay away from OpenCV.Still image. I'm trying to replicate an article, and will be doing some color analysis, checking for borders, symmetry, this kind of stuff. Some stuff they actually show the formulas they used, so at least that I can do in numpy if it comes to it.
0 - never used it
1 - used it a few times
2 - helped others when they had trouble
3 - set it up for a team
4 - set it up for various teams in various contexts
5 - developed extensions, contributed code
// create table of contents
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">Name</th>
</tr>
<xsl:for-each select="">
<xsl:apply-templates select="my_node"/>
</xsl:for-each>
// do other stuff
// detailed view (code omitted because I don't know how yet)
// template for node
<xsl:template match="my_node">
<tr>
<td><xsl:value-of select="../@name"/></td>
</tr>
</xsl:template>
A lot of things use Numpy (mostly because it's one of the most common way to have tables in Python), so yes, you won't be able to avoid it. At least, a lot of python distributions (Python(x,y) for Python, Pyzo for Python3k...) ship with numpy/scipy preinstalled.
Unfortunately, Numpy is both great and awful (my rant list is longer and longer each month... functions that don't do what the documentation says, strange design choices, from implicit conversions to non-pythonic non-intuitive contructs, etc.)
As long as you don't need complex image algorithm ready to use, yes, you can probably do anything using Numpy and stay away from OpenCV.
Look also for scipy, things like 2D convolution, especially useful for image manipulation, can be found there.
You'll just need something to load the images besides that. In 3k, Pillow is a solution, but ImageIO works also well (and can be easier to install).
So I'm trying to setup a new resume but I really have no idea how to go about it. My career has been mostly contract jobs lasting a few months, as such I have like a zillion projects where I've done different things, different technologies and different audiences I can list which all seem valuable but no good idea how to represent them compactly even if I limit it to a handful. Anyone else have a more project-oriented resume opposed to a position-oriented one?
"Hey,
I saw that you were looking for Visual Basic backend dev ops guys which got me interested. For the past year I have done like a zillion projects where I've done different things, different technologies and different audience, for example building VB stuff with React on the front blah blah blah deployed usually to AWS. Let's get in touch if you want to learn more. Oh and I saw that you do tons of open source stuff, checkout my GitHub profile at https://zombo.com".
- Somnid"
Well, after my application last month went nowhere, I'm now sending out emails again. One of the companies I applied at looks seriously incredible, so I'd love to get that job. They just sent me a list of technologies they use and would like me to grade my level of experience of them. They also included a scale I'm supposed to use, but it's.. weird. I'm not sure what to make of it.
The list of technologies includes languages, frameworks, but also things like "Design Patterns" or "Continuous Integration".
So, if I'm very comfortable with a technology I regularly use, I would definitely grade it higher than 1. But what if I never helped others? This is a quote, by the way. This "helped others" etc. is all the scale says. If I never helped others with a technology, what grade should I pick? 1 would be wrong, but so would be 2. Well, maybe I should consider 2 to be more like "comfortable enough to be able to help others"..?
And some of the grades don't even make sense for some of the items. How can you set up "Design Patterns" for a team? How can you set up a programming language for a team? Do they mean the project setup (i.e. dependency/build management etc.)?
If I added JUnit to Maven's pom.xml, does this count as "set it up for a team"? What about Git? Can I grade it with 4 if I created multiple repositories on Github?
This scale is just strange.
What kinds of jobs are you going to be applying for? Cool hipster startups? Corporate 9-5 places? Government?
I can only speak from behalf of the first category, but I am already more interested about the zillion projects you have worked on than the positions you were at. Different technologies? Cool, that probably means that you adapt fast. Different audiences? Neat.
As a developer who occasionally voices an opinion on potential recruits, I am not really looking at a list of stuff you say you have done. I care about the stuff you can do in the future. If you got a GitHub profile full of neat contributions or if you can show a project or two that really shine, even better. But just write that all open in couple of lines in the cover letter and throw an actionable item and if it's not totally terrible, you most likely will end up in an interview.
Obviously that might not cut it for corporate, just replace GitHub with LinkedIn and put a 10 page PDF in the attachments.