185
Points
Questions
35
Answers
39
-
Asked on July 16, 2020 in XML.
For Intellij Idea users:
Have a look at Tools -> XML Actions
Seems to work very well (as far as I have tested).
Edit:
As mentioned by @naXa, you can now also right-click on the XSD file and click “Generate XML Document from XSD Schema…”
- 837 views
- 19 answers
- 0 votes
-
Asked on July 16, 2020 in .NET.
First save the filename of the selected file from the file dialog by for example using an attribute in the class.
private string selectedFileName; //attribute in the class private void button1_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Files | *"; if (ofd.ShowDialog() == DialogResult.OK) { md5box.Text = GetMD5FromFile(ofd.FileName); selectedFileName = ofd.FileName; //set to the path of the opened file } }
You can then add the saved file path to the
ListBox
simply by doinglistbox1.Items.Add(selectedFileName)
inbutton2_Click
.- 351 views
- 1 answers
- 0 votes
-
Asked on July 16, 2020 in .NET.
You just need to:
first, set your response mime type:
Response.Headers.Add("Content-Type", "application/pdf"); //for example
second, set following header as a dictate to browsers to download file:
Response.Headers.Add("Content-Disposition", "attachment; filename=foo.pdf"); //for example
- 362 views
- 1 answers
- 0 votes
-
Asked on July 16, 2020 in .NET.
You could override the validation error message by using the ErrorMessage property. Code as below:
[Required(ErrorMessage = "Please enter a valid Month")] [Range(1,12,ErrorMessage ="Entered Month is inValid")] public int? VisitMonth { get; set; } [Required(ErrorMessage ="Please enter a valid Year")] [Range(1, 12, ErrorMessage = "Entered Year is inValid")] public int? VisitYear { get; set; }
The output:
- 373 views
- 2 answers
- 0 votes
-
Asked on July 16, 2020 in Mysql.
The solution is to use:
-
Once:
con.autocommit(True)
-
Or, after each select query:
con.commit()
With this option, there will be a commit after each select query. Otherwise, subsequent selects will render the same result.
This error seems to be Bug #42197 related to Query cache and auto-commit in MySQL. The status is won’t fix!
In a few months, this should be irrelevant because MySQL 8.0 is dropping Query Cache.
- 403 views
- 5 answers
- 0 votes
-
-
Asked on July 16, 2020 in Mysql.
I think you intend to set values in each row:
DELIMITER $$ CREATE TRIGGER id_bayar BEFORE INSERT ON pembayaran FOR EACH ROW BEGIN SET new.id_pembayaran = (SELECT (CASE WHEN new.id_jenis_pembayaran = 'DP' THEN CONCAT('DP','-', DATE_FORMAT(curdate(), '%Y%m%d'), '-', COUNT(*) + 1) ELSE CONCAT('LNS','-', DATE_FORMAT(curdate(), '%Y%m%d'), '-', COUNT(*) + 1) END) FROM pembayaran ); END$$ DELIMITER ;
- 371 views
- 1 answers
- 0 votes
-
Asked on July 16, 2020 in Python.
You are comparing a string to a list
["yes","Yes"]
which will always evaluate to false, and since you didn’t specify theelse
condition, you will get nothing as an output.You can fix this issue by using the word
in
which can be used to evaluate individual elements in a list:if answear in ["yes", "Yes"]: print("answear 1") elif answear in ["no", "No"]: print("answear 2")
- 339 views
- 3 answers
- 0 votes
-
Asked on July 16, 2020 in Python.
The second attempt is the most pythonic. The first one can still be achieved with the following:
filename = 'sample.txt' with open(filename) as input_file: word_list = input_file.read().strip().split(' ') word_list = [word.lower() for word in word_list] for word in word_list: if len(word) == 1: word_list.remove(word) print(word_list)
- 382 views
- 4 answers
- 0 votes
-
Asked on July 16, 2020 in Python.
You can also do NumPy indexing for even greater speed ups. It’s not really iterating but works much better than iteration for certain applications.
subset = row['c1'][0:5] all = row['c1'][:]
You may also want to cast it to an array. These indexes/selections are supposed to act like NumPy arrays already, but I ran into issues and needed to cast
np.asarray(all) imgs[:] = cv2.resize(imgs[:], (224,224) ) # Resize every image in an hdf5 file
- 1096 views
- 22 answers
- 0 votes
-
Asked on July 16, 2020 in Python.
Is this what you wat?
import random words_list = ['GOOD', 'BAD', 'EVIL'] chosenWord = random.choice(words_list).upper() lives = 4 print ("The word has", len(chosenWord), "letters") rightGuessed = ["*"] * len(chosenWord) wrongGuessed = [] def modificari(): for i in rightGuessed: print(i, end = " ") print() modificari() while True: print("=========================") letterGuessed = input("Guess a letter: ").upper() if letterGuessed in chosenWord: index = 0 for i in chosenWord: if i == letterGuessed: rightGuessed[index] = letterGuessed index += 1 modificari() elif letterGuessed == chosenWord: print ('You win !!!') break else: lives = lives - 1 print ("You have", lives, "lives left") if letterGuessed not in wrongGuessed: wrongGuessed.append(letterGuessed) else: print ('You already guessed that letter') print("Wrong: " ,wrongGuessed) if lives == 0: print("Game Over") break if '*' not in rightGuessed: print ('You win !!!') break
Or maybe this:
words_list = ['GOOD', 'BAD', 'EVIL'] chosenWord = random.choice(words_list).upper() lives = 4 print ("The word has", len(chosenWord), "letters") wrongGuessed = [] while True: print("=========================") print("* "*len(chosenWord)) print("WrongGuesses:"+" ".join(wrongGuessed)) Gussedword = input("Guess a letter: ").upper() if Gussedword == chosenWord: print('You win !!!') break elif Gussedword in wrongGuessed: print('You already guessed that word') else: lives = lives - 1 wrongGuessed.append(Gussedword) print ("You have", lives, "lives left") if lives == 0: print("Game Over") break
- 292 views
- 1 answers
- 0 votes