qid
int64
1
74.7M
question
stringlengths
15
55.4k
date
stringlengths
10
10
metadata
sequencelengths
3
3
response_j
stringlengths
2
32.4k
response_k
stringlengths
9
40.5k
53,179,085
I'm writing a code using Java Swing to press the right button when I type a number key. But I can't find what I want through search. This is my code and I can't understand why this isn't working. Please help me.. ``` import javax.swing.*; import java.awt.Dimension; import java.awt.event.*; class class01 { public static void main(String[] args) { JFrame f = new JFrame("Key event test"); f.setSize(230, 500); f.setLayout(null); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel(); JButton button1 = new JButton("Coffe"); button1.setSize(100, 100); button1.setLocation(0, 0); JButton button2 = new JButton("Latte"); button2.setSize(100, 100); button2.setLocation(0, 100); JButton button3 = new JButton("Espresso"); button3.setSize(100, 100); button3.setLocation(100, 100); JButton button4 = new JButton("Vanilla Latte"); button4.setSize(100, 100); button4.setLocation(100, 0); f.add(button1); f.add(button2); f.add(button3); f.add(button4); // Show message when the corresponding button is pressed. button1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { button1.keyPressed(KeyEvent.VK_1); JOptionPane.showMessageDialog(f.getComponent(0), "Coffee selected"); } }); button2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { button2.keyPressed(KeyEvent.VK_2); JOptionPane.showMessageDialog(f.getComponent(0), "Latte selected"); } }); button3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { button3.keyPressed(KeyEvent.VK_3); JOptionPane.showMessageDialog(f.getComponent(0), "Espresso selected"); } }); button4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { button4.keyPressed(KeyEvent.VK_4); JOptionPane.showMessageDialog(f.getComponent(0), "Vanilla Latte selected"); } }); } } ```
2018/11/06
[ "https://Stackoverflow.com/questions/53179085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8933767/" ]
The code you are showing does exactly one thing: attach action listeners to your buttons.. Meaning: when you click the button, then the listener will be called. You need a generic keyboard listener that translates key events into calls to the appropriate button, respectively action listener instead.
When you do this: ``` button1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { button1.keyPressed(KeyEvent.VK_1); JOptionPane.showMessageDialog(f.getComponent(0), "Coffee selected"); } }); ``` You are telling `button1` what to do when somebody clicks on the button. The line with `keyPressed` should not be there (it does not compile even). What you need to do is listen for key presses by adding a `KeyListener` to the frame like this: ``` f.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { if( e.getKeyChar() == KeyEvent.VK_1) { JOptionPane.showMessageDialog(f.getComponent(0), "Coffee selected"); } } }); ``` I repeated the `showMessageDialog`, but you should extract the actual logic into a method and call that method from within the `KeyListener` on the frame and the `ActionListener` on the button.
53,179,085
I'm writing a code using Java Swing to press the right button when I type a number key. But I can't find what I want through search. This is my code and I can't understand why this isn't working. Please help me.. ``` import javax.swing.*; import java.awt.Dimension; import java.awt.event.*; class class01 { public static void main(String[] args) { JFrame f = new JFrame("Key event test"); f.setSize(230, 500); f.setLayout(null); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel(); JButton button1 = new JButton("Coffe"); button1.setSize(100, 100); button1.setLocation(0, 0); JButton button2 = new JButton("Latte"); button2.setSize(100, 100); button2.setLocation(0, 100); JButton button3 = new JButton("Espresso"); button3.setSize(100, 100); button3.setLocation(100, 100); JButton button4 = new JButton("Vanilla Latte"); button4.setSize(100, 100); button4.setLocation(100, 0); f.add(button1); f.add(button2); f.add(button3); f.add(button4); // Show message when the corresponding button is pressed. button1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { button1.keyPressed(KeyEvent.VK_1); JOptionPane.showMessageDialog(f.getComponent(0), "Coffee selected"); } }); button2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { button2.keyPressed(KeyEvent.VK_2); JOptionPane.showMessageDialog(f.getComponent(0), "Latte selected"); } }); button3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { button3.keyPressed(KeyEvent.VK_3); JOptionPane.showMessageDialog(f.getComponent(0), "Espresso selected"); } }); button4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { button4.keyPressed(KeyEvent.VK_4); JOptionPane.showMessageDialog(f.getComponent(0), "Vanilla Latte selected"); } }); } } ```
2018/11/06
[ "https://Stackoverflow.com/questions/53179085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8933767/" ]
From what I understand, essentially you want to have the same operation of a button assigned to a specific key stroke. Things you want to avoid are `KeyListener`, especially because you have other focusable components in the view, namely buttons, which will steal keyboard focus and render the `KeyListener` useless. This is why, in almost all cases, you want to avoid `KeyListener`. A better and more reliable solution would be to use the [Key Bindings API](https://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html), which overcomes this focus related issue, but it also encourages the use of reusable components of work through the [`Action`s API](https://docs.oracle.com/javase/tutorial/uiswing/misc/action.html) Something like... ``` import java.awt.EventQueue; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.util.StringJoiner; import javax.swing.AbstractAction; import javax.swing.ActionMap; import javax.swing.InputMap; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.KeyStroke; public class Test { public static void main(String[] args) { new Test(); } public Test() { EventQueue.invokeLater(new Runnable() { @Override public void run() { JFrame frame = new JFrame(); frame.add(new TestPane()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } public class TestPane extends JPanel { public TestPane() { JTextField field = new JTextField(10); field.setEditable(false); field.setFocusable(false); InputMap im = getInputMap(WHEN_IN_FOCUSED_WINDOW); ActionMap am = getActionMap(); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_1, 0), "Pressed.One"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_2, 0), "Pressed.Two"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_3, 0), "Pressed.Three"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_4, 0), "Pressed.Four"); am.put("Pressed.One", new OrderAction(1, field)); am.put("Pressed.Two", new OrderAction(2, field)); am.put("Pressed.Three", new OrderAction(3, field)); am.put("Pressed.Four", new OrderAction(4, field)); JButton btnOne = new JButton(new OrderAction(1, field)); JButton btnTwo = new JButton(new OrderAction(2, field)); JButton btnThree = new JButton(new OrderAction(3, field)); JButton btnFour = new JButton(new OrderAction(4, field)); setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.weightx = 1; gbc.weighty = 1; gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 0; gbc.gridy = 1; add(btnOne, gbc); gbc.gridx++; add(btnTwo, gbc); gbc.gridx = 0; gbc.gridy++; add(btnThree, gbc); gbc.gridx++; add(btnFour, gbc); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 2; add(field, gbc); } protected class OrderAction extends AbstractAction { private int value; private JTextField field; public OrderAction(int value, JTextField field) { this.value = value; this.field = field; switch (value) { case 1: putValue(NAME, "Coffe"); break; case 2: putValue(NAME, "Latte"); break; case 3: putValue(NAME, "Espresso"); break; case 4: putValue(NAME, "Vanilla Latte"); break; } } @Override public void actionPerformed(ActionEvent e) { StringJoiner sj = new StringJoiner("; "); if (field.getText() != null && field.getText().length() > 0) { sj.add(field.getText()); } sj.add(Integer.toString(value)); field.setText(sj.toString()); } } } } ``` Note, you could apply the key bindings directly to each button instead Now, if you want to "visually" press the button on a key stroke, I would recommend either creating a custom `JButton` or factory method, which could allow for a more simplified implementation, but the basic idea would be to define a key binding and `Action` which simply called the buttons `doClick` method, for example ``` import java.awt.EventQueue; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.util.StringJoiner; import javax.swing.AbstractAction; import javax.swing.ActionMap; import javax.swing.InputMap; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.KeyStroke; public class Test { public static void main(String[] args) { new Test(); } public Test() { EventQueue.invokeLater(new Runnable() { @Override public void run() { JFrame frame = new JFrame(); frame.add(new TestPane()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } public class TestPane extends JPanel { public TestPane() { JTextField field = new JTextField(10); field.setEditable(false); field.setFocusable(false); JButton btnOne = new JButton(new OrderAction(1, field)); JButton btnTwo = new JButton(new OrderAction(2, field)); JButton btnThree = new JButton(new OrderAction(3, field)); JButton btnFour = new JButton(new OrderAction(4, field)); InputMap im = getInputMap(WHEN_IN_FOCUSED_WINDOW); ActionMap am = getActionMap(); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_1, 0), "Pressed.One"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_2, 0), "Pressed.Two"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_3, 0), "Pressed.Three"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_4, 0), "Pressed.Four"); am.put("Pressed.One", new ProxyAction(btnOne)); am.put("Pressed.Two", new ProxyAction(btnTwo)); am.put("Pressed.Three", new ProxyAction(btnThree)); am.put("Pressed.Four", new ProxyAction(btnFour)); setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.weightx = 1; gbc.weighty = 1; gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 0; gbc.gridy = 1; add(btnOne, gbc); gbc.gridx++; add(btnTwo, gbc); gbc.gridx = 0; gbc.gridy++; add(btnThree, gbc); gbc.gridx++; add(btnFour, gbc); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 2; add(field, gbc); } protected class ProxyAction extends AbstractAction { private JButton btn; public ProxyAction(JButton btn) { this.btn = btn; } @Override public void actionPerformed(ActionEvent e) { btn.doClick(); } } protected class OrderAction extends AbstractAction { private int value; private JTextField field; public OrderAction(int value, JTextField field) { this.value = value; this.field = field; switch (value) { case 1: putValue(NAME, "Coffe"); break; case 2: putValue(NAME, "Latte"); break; case 3: putValue(NAME, "Espresso"); break; case 4: putValue(NAME, "Vanilla Latte"); break; } } @Override public void actionPerformed(ActionEvent e) { StringJoiner sj = new StringJoiner("; "); if (field.getText() != null && field.getText().length() > 0) { sj.add(field.getText()); } sj.add(Integer.toString(value)); field.setText(sj.toString()); } } } } ```
When you do this: ``` button1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { button1.keyPressed(KeyEvent.VK_1); JOptionPane.showMessageDialog(f.getComponent(0), "Coffee selected"); } }); ``` You are telling `button1` what to do when somebody clicks on the button. The line with `keyPressed` should not be there (it does not compile even). What you need to do is listen for key presses by adding a `KeyListener` to the frame like this: ``` f.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { if( e.getKeyChar() == KeyEvent.VK_1) { JOptionPane.showMessageDialog(f.getComponent(0), "Coffee selected"); } } }); ``` I repeated the `showMessageDialog`, but you should extract the actual logic into a method and call that method from within the `KeyListener` on the frame and the `ActionListener` on the button.
213,173
I am a senior Siebel CRM developer having more than 8 years of working experience. Now, I am very keen and excited to learn Salesforce and get certified as soon as possible. Please guide me where to start from scratch ?
2018/03/29
[ "https://salesforce.stackexchange.com/questions/213173", "https://salesforce.stackexchange.com", "https://salesforce.stackexchange.com/users/55249/" ]
After some research and not reaching to any solution, I refreshed the selected Business Units by removing them, saving and the adding and saving again. This solved my issue.
You may need to raise the case with SFMC support. I have seen these issues, and support needs to toggle some backend settings to reset the SC and SFMC connection.
6,763,429
i want to write a shape with " \* " and " | " the shape is below. The program must take height and width from user.Width is column number without ' | '.I tried to write but confused.My code sometimes works great and sometimes being stupid.For example when i enter height : 13, width : 4 it writes one more,if witdh is 1 it enters infinite loop.While trying to solve it became too conflicted.Must i fix it or rewrite ? Here is the code : height =10, width = 5 ``` |*____| |_*___| |__*__| |___*_| |____*| |___*_| |__*__| |_*___| |*____| |_*___| ``` ``` private static void Function() { int height, width; if (width == 2) while (height > 0) { FirstPart(width, height); height -= width; } else while (height > 0) { if (height > 1) { FirstPart(width, height); height -= width; } if (height > 0) { SecondPart(width, height); height -= width - 2; } } } private static void FirstPart(int width,int height) { if(height > width) for (int i = 0; i < width; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } private static void SecondPart(int width,int height) { if(height > width) for (int i = 0; i < width-2; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width-1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width - 1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } ```
2011/07/20
[ "https://Stackoverflow.com/questions/6763429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/852118/" ]
I see a ``` while (Height > 0) ``` so your infinite loop is coming from Height never getting less or equal to 0.
It's better to rewrite. When you do, decouple the code into several functions so that one function draws a single line, and another one calls the former to draw all the lines.
6,763,429
i want to write a shape with " \* " and " | " the shape is below. The program must take height and width from user.Width is column number without ' | '.I tried to write but confused.My code sometimes works great and sometimes being stupid.For example when i enter height : 13, width : 4 it writes one more,if witdh is 1 it enters infinite loop.While trying to solve it became too conflicted.Must i fix it or rewrite ? Here is the code : height =10, width = 5 ``` |*____| |_*___| |__*__| |___*_| |____*| |___*_| |__*__| |_*___| |*____| |_*___| ``` ``` private static void Function() { int height, width; if (width == 2) while (height > 0) { FirstPart(width, height); height -= width; } else while (height > 0) { if (height > 1) { FirstPart(width, height); height -= width; } if (height > 0) { SecondPart(width, height); height -= width - 2; } } } private static void FirstPart(int width,int height) { if(height > width) for (int i = 0; i < width; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } private static void SecondPart(int width,int height) { if(height > width) for (int i = 0; i < width-2; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width-1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width - 1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } ```
2011/07/20
[ "https://Stackoverflow.com/questions/6763429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/852118/" ]
I see a ``` while (Height > 0) ``` so your infinite loop is coming from Height never getting less or equal to 0.
``` void WriteStars(int Width,int Height) { int _sp=1; //Star Pos bool _left = false; for(int i =0;i<Height;i++) { Console.Write("|"); int j; for(j=1;j<Width-1;j++) { if(j==_sp) { Console.Write("*"); if(_left) { _sp--; } else { _sp++; } j++; break; } else { Console.Write("_"); } } for(;j<Width-1;j++) { Console.Write("_"); } Console.WriteLine("|"); if(_sp==0) { _left = false; } else if(_sp==Width) { _left = true; } } } ``` Try if it works, wrote it right here.
6,763,429
i want to write a shape with " \* " and " | " the shape is below. The program must take height and width from user.Width is column number without ' | '.I tried to write but confused.My code sometimes works great and sometimes being stupid.For example when i enter height : 13, width : 4 it writes one more,if witdh is 1 it enters infinite loop.While trying to solve it became too conflicted.Must i fix it or rewrite ? Here is the code : height =10, width = 5 ``` |*____| |_*___| |__*__| |___*_| |____*| |___*_| |__*__| |_*___| |*____| |_*___| ``` ``` private static void Function() { int height, width; if (width == 2) while (height > 0) { FirstPart(width, height); height -= width; } else while (height > 0) { if (height > 1) { FirstPart(width, height); height -= width; } if (height > 0) { SecondPart(width, height); height -= width - 2; } } } private static void FirstPart(int width,int height) { if(height > width) for (int i = 0; i < width; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } private static void SecondPart(int width,int height) { if(height > width) for (int i = 0; i < width-2; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width-1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width - 1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } ```
2011/07/20
[ "https://Stackoverflow.com/questions/6763429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/852118/" ]
``` private static void WriteStars(int width, int height) { int j = 0; for (int i = 0; i < height; i++) { Console.Write("|"); for (int f = 0; f < width; f++) { if (f == Math.Abs(j)) { Console.Write("*"); } else { Console.Write(" "); } } j++; if (Math.Abs(j) == width - 1) { j *= -1; } Console.WriteLine("|"); } } ``` Probably going to get downvoted for giving you a complete answer, but maybe it'll show you one correct approach and you can learn something from it...
I see a ``` while (Height > 0) ``` so your infinite loop is coming from Height never getting less or equal to 0.
6,763,429
i want to write a shape with " \* " and " | " the shape is below. The program must take height and width from user.Width is column number without ' | '.I tried to write but confused.My code sometimes works great and sometimes being stupid.For example when i enter height : 13, width : 4 it writes one more,if witdh is 1 it enters infinite loop.While trying to solve it became too conflicted.Must i fix it or rewrite ? Here is the code : height =10, width = 5 ``` |*____| |_*___| |__*__| |___*_| |____*| |___*_| |__*__| |_*___| |*____| |_*___| ``` ``` private static void Function() { int height, width; if (width == 2) while (height > 0) { FirstPart(width, height); height -= width; } else while (height > 0) { if (height > 1) { FirstPart(width, height); height -= width; } if (height > 0) { SecondPart(width, height); height -= width - 2; } } } private static void FirstPart(int width,int height) { if(height > width) for (int i = 0; i < width; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } private static void SecondPart(int width,int height) { if(height > width) for (int i = 0; i < width-2; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width-1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width - 1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } ```
2011/07/20
[ "https://Stackoverflow.com/questions/6763429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/852118/" ]
I see a ``` while (Height > 0) ``` so your infinite loop is coming from Height never getting less or equal to 0.
even shorter: ``` static void Variante_2(int height, int width) { byte[][] arr = new byte[height][]; int pos = 0; int mov = 1; for (int line = 0; line < height; line++) { arr[line] = new byte[width]; for (int col = 0; col < width; col++) { arr[line][col] = 45; } arr[line][pos] = 42; pos += mov; if (pos == 0 || pos == (width - 1)) { mov *= -1; } Console.WriteLine("|" + ASCIIEncoding.ASCII.GetString(arr[line]) + "|"); } string temp = Console.ReadLine(); } ```
6,763,429
i want to write a shape with " \* " and " | " the shape is below. The program must take height and width from user.Width is column number without ' | '.I tried to write but confused.My code sometimes works great and sometimes being stupid.For example when i enter height : 13, width : 4 it writes one more,if witdh is 1 it enters infinite loop.While trying to solve it became too conflicted.Must i fix it or rewrite ? Here is the code : height =10, width = 5 ``` |*____| |_*___| |__*__| |___*_| |____*| |___*_| |__*__| |_*___| |*____| |_*___| ``` ``` private static void Function() { int height, width; if (width == 2) while (height > 0) { FirstPart(width, height); height -= width; } else while (height > 0) { if (height > 1) { FirstPart(width, height); height -= width; } if (height > 0) { SecondPart(width, height); height -= width - 2; } } } private static void FirstPart(int width,int height) { if(height > width) for (int i = 0; i < width; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } private static void SecondPart(int width,int height) { if(height > width) for (int i = 0; i < width-2; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width-1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width - 1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } ```
2011/07/20
[ "https://Stackoverflow.com/questions/6763429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/852118/" ]
I see a ``` while (Height > 0) ``` so your infinite loop is coming from Height never getting less or equal to 0.
and it is possible to do it with less code: ``` static void Variante_3(int height, int width) { int pos = 1; int mov = 1; for (int line = 0; line < height; line++) { Console.WriteLine("|" + "*".PadLeft(pos, '_') + "|".PadLeft(width - pos, '_')); pos += mov; if (pos == 1 || pos == (width - 1)) { mov *= -1; } } string temp = Console.ReadLine(); } ``` Sorry to all not doing others homework, but I couldn´t sleep without showing this *g*
6,763,429
i want to write a shape with " \* " and " | " the shape is below. The program must take height and width from user.Width is column number without ' | '.I tried to write but confused.My code sometimes works great and sometimes being stupid.For example when i enter height : 13, width : 4 it writes one more,if witdh is 1 it enters infinite loop.While trying to solve it became too conflicted.Must i fix it or rewrite ? Here is the code : height =10, width = 5 ``` |*____| |_*___| |__*__| |___*_| |____*| |___*_| |__*__| |_*___| |*____| |_*___| ``` ``` private static void Function() { int height, width; if (width == 2) while (height > 0) { FirstPart(width, height); height -= width; } else while (height > 0) { if (height > 1) { FirstPart(width, height); height -= width; } if (height > 0) { SecondPart(width, height); height -= width - 2; } } } private static void FirstPart(int width,int height) { if(height > width) for (int i = 0; i < width; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } private static void SecondPart(int width,int height) { if(height > width) for (int i = 0; i < width-2; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width-1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width - 1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } ```
2011/07/20
[ "https://Stackoverflow.com/questions/6763429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/852118/" ]
``` private static void WriteStars(int width, int height) { int j = 0; for (int i = 0; i < height; i++) { Console.Write("|"); for (int f = 0; f < width; f++) { if (f == Math.Abs(j)) { Console.Write("*"); } else { Console.Write(" "); } } j++; if (Math.Abs(j) == width - 1) { j *= -1; } Console.WriteLine("|"); } } ``` Probably going to get downvoted for giving you a complete answer, but maybe it'll show you one correct approach and you can learn something from it...
It's better to rewrite. When you do, decouple the code into several functions so that one function draws a single line, and another one calls the former to draw all the lines.
6,763,429
i want to write a shape with " \* " and " | " the shape is below. The program must take height and width from user.Width is column number without ' | '.I tried to write but confused.My code sometimes works great and sometimes being stupid.For example when i enter height : 13, width : 4 it writes one more,if witdh is 1 it enters infinite loop.While trying to solve it became too conflicted.Must i fix it or rewrite ? Here is the code : height =10, width = 5 ``` |*____| |_*___| |__*__| |___*_| |____*| |___*_| |__*__| |_*___| |*____| |_*___| ``` ``` private static void Function() { int height, width; if (width == 2) while (height > 0) { FirstPart(width, height); height -= width; } else while (height > 0) { if (height > 1) { FirstPart(width, height); height -= width; } if (height > 0) { SecondPart(width, height); height -= width - 2; } } } private static void FirstPart(int width,int height) { if(height > width) for (int i = 0; i < width; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } private static void SecondPart(int width,int height) { if(height > width) for (int i = 0; i < width-2; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width-1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width - 1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } ```
2011/07/20
[ "https://Stackoverflow.com/questions/6763429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/852118/" ]
``` private static void WriteStars(int width, int height) { int j = 0; for (int i = 0; i < height; i++) { Console.Write("|"); for (int f = 0; f < width; f++) { if (f == Math.Abs(j)) { Console.Write("*"); } else { Console.Write(" "); } } j++; if (Math.Abs(j) == width - 1) { j *= -1; } Console.WriteLine("|"); } } ``` Probably going to get downvoted for giving you a complete answer, but maybe it'll show you one correct approach and you can learn something from it...
``` void WriteStars(int Width,int Height) { int _sp=1; //Star Pos bool _left = false; for(int i =0;i<Height;i++) { Console.Write("|"); int j; for(j=1;j<Width-1;j++) { if(j==_sp) { Console.Write("*"); if(_left) { _sp--; } else { _sp++; } j++; break; } else { Console.Write("_"); } } for(;j<Width-1;j++) { Console.Write("_"); } Console.WriteLine("|"); if(_sp==0) { _left = false; } else if(_sp==Width) { _left = true; } } } ``` Try if it works, wrote it right here.
6,763,429
i want to write a shape with " \* " and " | " the shape is below. The program must take height and width from user.Width is column number without ' | '.I tried to write but confused.My code sometimes works great and sometimes being stupid.For example when i enter height : 13, width : 4 it writes one more,if witdh is 1 it enters infinite loop.While trying to solve it became too conflicted.Must i fix it or rewrite ? Here is the code : height =10, width = 5 ``` |*____| |_*___| |__*__| |___*_| |____*| |___*_| |__*__| |_*___| |*____| |_*___| ``` ``` private static void Function() { int height, width; if (width == 2) while (height > 0) { FirstPart(width, height); height -= width; } else while (height > 0) { if (height > 1) { FirstPart(width, height); height -= width; } if (height > 0) { SecondPart(width, height); height -= width - 2; } } } private static void FirstPart(int width,int height) { if(height > width) for (int i = 0; i < width; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } private static void SecondPart(int width,int height) { if(height > width) for (int i = 0; i < width-2; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width-1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width - 1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } ```
2011/07/20
[ "https://Stackoverflow.com/questions/6763429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/852118/" ]
``` private static void WriteStars(int width, int height) { int j = 0; for (int i = 0; i < height; i++) { Console.Write("|"); for (int f = 0; f < width; f++) { if (f == Math.Abs(j)) { Console.Write("*"); } else { Console.Write(" "); } } j++; if (Math.Abs(j) == width - 1) { j *= -1; } Console.WriteLine("|"); } } ``` Probably going to get downvoted for giving you a complete answer, but maybe it'll show you one correct approach and you can learn something from it...
even shorter: ``` static void Variante_2(int height, int width) { byte[][] arr = new byte[height][]; int pos = 0; int mov = 1; for (int line = 0; line < height; line++) { arr[line] = new byte[width]; for (int col = 0; col < width; col++) { arr[line][col] = 45; } arr[line][pos] = 42; pos += mov; if (pos == 0 || pos == (width - 1)) { mov *= -1; } Console.WriteLine("|" + ASCIIEncoding.ASCII.GetString(arr[line]) + "|"); } string temp = Console.ReadLine(); } ```
6,763,429
i want to write a shape with " \* " and " | " the shape is below. The program must take height and width from user.Width is column number without ' | '.I tried to write but confused.My code sometimes works great and sometimes being stupid.For example when i enter height : 13, width : 4 it writes one more,if witdh is 1 it enters infinite loop.While trying to solve it became too conflicted.Must i fix it or rewrite ? Here is the code : height =10, width = 5 ``` |*____| |_*___| |__*__| |___*_| |____*| |___*_| |__*__| |_*___| |*____| |_*___| ``` ``` private static void Function() { int height, width; if (width == 2) while (height > 0) { FirstPart(width, height); height -= width; } else while (height > 0) { if (height > 1) { FirstPart(width, height); height -= width; } if (height > 0) { SecondPart(width, height); height -= width - 2; } } } private static void FirstPart(int width,int height) { if(height > width) for (int i = 0; i < width; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + 1 == j) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } private static void SecondPart(int width,int height) { if(height > width) for (int i = 0; i < width-2; i++) { for (int j = 0; j < width+2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width-1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } else for (int i = 0; i < height; i++) { for (int j = 0; j < width + 2; j++) { if (j == 0 || j == width + 1) Console.Write("|"); else if (i + j == width - 1) Console.Write("*"); else Console.Write(" "); } Console.WriteLine(); } } ```
2011/07/20
[ "https://Stackoverflow.com/questions/6763429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/852118/" ]
``` private static void WriteStars(int width, int height) { int j = 0; for (int i = 0; i < height; i++) { Console.Write("|"); for (int f = 0; f < width; f++) { if (f == Math.Abs(j)) { Console.Write("*"); } else { Console.Write(" "); } } j++; if (Math.Abs(j) == width - 1) { j *= -1; } Console.WriteLine("|"); } } ``` Probably going to get downvoted for giving you a complete answer, but maybe it'll show you one correct approach and you can learn something from it...
and it is possible to do it with less code: ``` static void Variante_3(int height, int width) { int pos = 1; int mov = 1; for (int line = 0; line < height; line++) { Console.WriteLine("|" + "*".PadLeft(pos, '_') + "|".PadLeft(width - pos, '_')); pos += mov; if (pos == 1 || pos == (width - 1)) { mov *= -1; } } string temp = Console.ReadLine(); } ``` Sorry to all not doing others homework, but I couldn´t sleep without showing this *g*
62,851,314
Let me explain what is happening: * Database: Oracle 19c * Apex: 19.1.0.00.15 * ORDS standalone is 19.1.0.r0921545 I did the tasks to configure an Apex Social Sign In to Microsoft AAD without almost any issue: * I created the authentication method in Apex. * I register my application and get the web credentials in Azure. * I created a wallet in my database with the root CA Microsoft certificates and configured the instance settings to usee that wallet. * My wallet in the database server contains the property auto\_login to avoid using passwords. * I created the ACEs entries to allow connection to the login.microsoftonline.com in the port 443 * Although it is not important for the purpose of the question itself and the error that is producing, just comment that I configured the wallet settings in the internal workspace in order to provide access to the wallet to the apex applications. For some weeks the process was working fine, I was having a perfect Single Sing on mechanism for all my apex applications in the different workspaces. However, since some days ago, I am getting always the same error: **ORA-29024: Certificate validation failure** After some digging I realise that someone has configured a PROXY for outgoing traffic. Before even trying in Apex, I tried in SQL using APEX\_WEB\_SERVICE Request with proxy settings to login.microsoftonline.com ``` select apex_web_service.make_rest_request( p_url => 'https://login.microsoftonline.com', p_http_method => 'GET', p_wallet_path => 'file:/home/oracle/wallet', p_wallet_pwd => 'MyPassword' , p_proxy_override => 'http://myproxy:myport' 7 ) from dual; ERROR: ORA-29273: HTTP request failed ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1035 ORA-29024: Certificate validation failure ORA-06512: at "SYS.UTL_HTTP", line 380 ORA-06512: at "SYS.UTL_HTTP", line 1148 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 934 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1580 ORA-06512: at "APEX_190100.WWV_FLOW_WEBSERVICES_API", line 408 ORA-06512: at line 1 ``` Request without proxy settings, just to see if I can get there ``` SQL> select apex_web_service.make_rest_request( 2 p_url => 'https://login.microsoftonline.com', 3 p_http_method => 'GET', 4 p_wallet_path => 'file:/home/oracle/wallet' 5* ) from dual SQL> / ERROR: ORA-29273: HTTP request failed ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1035 ORA-29024: Certificate validation failure ORA-06512: at "SYS.UTL_HTTP", line 380 ORA-06512: at "SYS.UTL_HTTP", line 1148 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 934 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1580 ORA-06512: at "APEX_190100.WWV_FLOW_WEBSERVICES_API", line 408 ORA-06512: at line 1 ``` Request to google using Proxy settings ``` select apex_web_service.make_rest_request( p_url => 'https://google.com', p_http_method => 'GET', p_wallet_path => 'file:/home/oracle/wallet', p_wallet_pwd => 'MyPassword' , 6 p_proxy_override => 'http://myproxy:myport' 7 ) from dual ; ERROR: ORA-29273: HTTP request failed ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1035 ORA-29024: Certificate validation failure ORA-06512: at "SYS.UTL_HTTP", line 380 ORA-06512: at "SYS.UTL_HTTP", line 1148 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 934 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1580 ORA-06512: at "APEX_190100.WWV_FLOW_WEBSERVICES_API", line 408 ORA-06512: at line 1 ``` Request to google without proxy settings ``` SQL> select apex_web_service.make_rest_request( 2 p_url => 'https://google.com', 3 p_http_method => 'GET', 4 p_wallet_path => 'file:/home/oracle/wallet' 5* ) from dual SQL> / ERROR: ORA-29273: HTTP request failed ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1035 ORA-12535: TNS:operation timed out ORA-06512: at "SYS.UTL_HTTP", line 380 ORA-06512: at "SYS.UTL_HTTP", line 1148 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 934 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1580 ORA-06512: at "APEX_190100.WWV_FLOW_WEBSERVICES_API", line 408 ORA-06512: at line 1 ``` My questions are the following: * It is a network problem or a proxy issue regarding inbound/outbound traffic ? I can reach Microsoft but not Google in the port 443 when I don't specify proxy. * Why am I getting invalid certificate when it has nothing to do with the certificates ? * How can I setup my APEX to use authentication on Azure or any other provider for that matter when I have a proxy in the middle ? * As I use ORDS standalone, am I allow to keep using it or I need a reverse proxy with Tomcat ? I tried to configure the ACE to use HTTP\_PROXY in the ports by running ``` begin sys.dbms_network_acl_admin.append_host_ace( host => 'myproxyserver' ,lower_port => 8080 ,upper_port => 8080 ,ace => xs$ace_type( privilege_list => xs$name_list('http_proxy') ,granted => true ,principal_name => 'MY_PRINCIPAL' ,principal_type => XS_ACL.PTYPE_DB ) ); end; / ``` Even I grant to the ACE privileges over the wallet ``` SET SERVEROUTPUT ON BEGIN DBMS_NETWORK_ACL_ADMIN.APPEND_WALLET_ACE ( WALLET_PATH => 'file:/home/oracle/wallet', ACE => XS$ACE_TYPE( PRIVILEGE_LIST => XS$NAME_LIST('use_passwords','use_client_certificates'), PRINCIPAL_NAME => 'MY_PRINCIPAL', PRINCIPAL_TYPE => XS_ACL.PTYPE_DB ) ); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('Error while configuring ACL for wallet: '|| SQLERRM); END; / ``` but I am still getting the same error all over. Any help would be appreciated! Thank you
2020/07/11
[ "https://Stackoverflow.com/questions/62851314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13755538/" ]
I had issue like this, it seems Oracle SSL library has some bugs. Finally I implemented some Java Source for OJVM, please read my answer here: <https://stackoverflow.com/a/60152830/11272044>
In my understanding,you will need to do following(in addition to what you did) : 1. login to Apex as administrator 2. From settings, go to 'Wallet' 3. Add Wallet path(absolute path with prefix 'file://' and password you used for creating wallet Now, your problem should be solved.
62,851,314
Let me explain what is happening: * Database: Oracle 19c * Apex: 19.1.0.00.15 * ORDS standalone is 19.1.0.r0921545 I did the tasks to configure an Apex Social Sign In to Microsoft AAD without almost any issue: * I created the authentication method in Apex. * I register my application and get the web credentials in Azure. * I created a wallet in my database with the root CA Microsoft certificates and configured the instance settings to usee that wallet. * My wallet in the database server contains the property auto\_login to avoid using passwords. * I created the ACEs entries to allow connection to the login.microsoftonline.com in the port 443 * Although it is not important for the purpose of the question itself and the error that is producing, just comment that I configured the wallet settings in the internal workspace in order to provide access to the wallet to the apex applications. For some weeks the process was working fine, I was having a perfect Single Sing on mechanism for all my apex applications in the different workspaces. However, since some days ago, I am getting always the same error: **ORA-29024: Certificate validation failure** After some digging I realise that someone has configured a PROXY for outgoing traffic. Before even trying in Apex, I tried in SQL using APEX\_WEB\_SERVICE Request with proxy settings to login.microsoftonline.com ``` select apex_web_service.make_rest_request( p_url => 'https://login.microsoftonline.com', p_http_method => 'GET', p_wallet_path => 'file:/home/oracle/wallet', p_wallet_pwd => 'MyPassword' , p_proxy_override => 'http://myproxy:myport' 7 ) from dual; ERROR: ORA-29273: HTTP request failed ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1035 ORA-29024: Certificate validation failure ORA-06512: at "SYS.UTL_HTTP", line 380 ORA-06512: at "SYS.UTL_HTTP", line 1148 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 934 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1580 ORA-06512: at "APEX_190100.WWV_FLOW_WEBSERVICES_API", line 408 ORA-06512: at line 1 ``` Request without proxy settings, just to see if I can get there ``` SQL> select apex_web_service.make_rest_request( 2 p_url => 'https://login.microsoftonline.com', 3 p_http_method => 'GET', 4 p_wallet_path => 'file:/home/oracle/wallet' 5* ) from dual SQL> / ERROR: ORA-29273: HTTP request failed ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1035 ORA-29024: Certificate validation failure ORA-06512: at "SYS.UTL_HTTP", line 380 ORA-06512: at "SYS.UTL_HTTP", line 1148 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 934 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1580 ORA-06512: at "APEX_190100.WWV_FLOW_WEBSERVICES_API", line 408 ORA-06512: at line 1 ``` Request to google using Proxy settings ``` select apex_web_service.make_rest_request( p_url => 'https://google.com', p_http_method => 'GET', p_wallet_path => 'file:/home/oracle/wallet', p_wallet_pwd => 'MyPassword' , 6 p_proxy_override => 'http://myproxy:myport' 7 ) from dual ; ERROR: ORA-29273: HTTP request failed ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1035 ORA-29024: Certificate validation failure ORA-06512: at "SYS.UTL_HTTP", line 380 ORA-06512: at "SYS.UTL_HTTP", line 1148 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 934 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1580 ORA-06512: at "APEX_190100.WWV_FLOW_WEBSERVICES_API", line 408 ORA-06512: at line 1 ``` Request to google without proxy settings ``` SQL> select apex_web_service.make_rest_request( 2 p_url => 'https://google.com', 3 p_http_method => 'GET', 4 p_wallet_path => 'file:/home/oracle/wallet' 5* ) from dual SQL> / ERROR: ORA-29273: HTTP request failed ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1035 ORA-12535: TNS:operation timed out ORA-06512: at "SYS.UTL_HTTP", line 380 ORA-06512: at "SYS.UTL_HTTP", line 1148 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 934 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1580 ORA-06512: at "APEX_190100.WWV_FLOW_WEBSERVICES_API", line 408 ORA-06512: at line 1 ``` My questions are the following: * It is a network problem or a proxy issue regarding inbound/outbound traffic ? I can reach Microsoft but not Google in the port 443 when I don't specify proxy. * Why am I getting invalid certificate when it has nothing to do with the certificates ? * How can I setup my APEX to use authentication on Azure or any other provider for that matter when I have a proxy in the middle ? * As I use ORDS standalone, am I allow to keep using it or I need a reverse proxy with Tomcat ? I tried to configure the ACE to use HTTP\_PROXY in the ports by running ``` begin sys.dbms_network_acl_admin.append_host_ace( host => 'myproxyserver' ,lower_port => 8080 ,upper_port => 8080 ,ace => xs$ace_type( privilege_list => xs$name_list('http_proxy') ,granted => true ,principal_name => 'MY_PRINCIPAL' ,principal_type => XS_ACL.PTYPE_DB ) ); end; / ``` Even I grant to the ACE privileges over the wallet ``` SET SERVEROUTPUT ON BEGIN DBMS_NETWORK_ACL_ADMIN.APPEND_WALLET_ACE ( WALLET_PATH => 'file:/home/oracle/wallet', ACE => XS$ACE_TYPE( PRIVILEGE_LIST => XS$NAME_LIST('use_passwords','use_client_certificates'), PRINCIPAL_NAME => 'MY_PRINCIPAL', PRINCIPAL_TYPE => XS_ACL.PTYPE_DB ) ); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('Error while configuring ACL for wallet: '|| SQLERRM); END; / ``` but I am still getting the same error all over. Any help would be appreciated! Thank you
2020/07/11
[ "https://Stackoverflow.com/questions/62851314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13755538/" ]
Thank you to all who post answers, but finally, after struggling for a while, I found the root cause. Actually Oracle was right after all, as Microsoft has changed the way the authentication is handled, either you are using Oauth2 or OpenID, when you use Office365 and Azure Active Directory. In this case, my organisation is using Office 365 and at the beginning was enough with importing the PKI certificates from : <https://www.microsoft.com/pki/mscorp/cps/default.htm> After a change done in Azure Active Directory (AAD), you now need also the Global Sign certificates from [office.com](http://office.com) I hope it clarifies to other users who got in the same problem trying to authenticate with Azure Active Directory using Apex Social sign in. You can download the certificates directly from office365.com [![enter image description here](https://i.stack.imgur.com/zkbq2.png)](https://i.stack.imgur.com/zkbq2.png) After adding the new two certificates to the wallet, you can now enter without issues: ``` select apex_web_service.make_rest_request( p_url => 'https://login.microsoftonline.com', p_http_method => 'GET', 4 p_wallet_path => 'file:/home/oracle/wallet' ) from dual ; APEX_WEB_SERVICE.MAKE_REST_REQUEST(P_URL=>'HTTPS://LOGIN.MICROSOFTONLINE.COM',P_ -------------------------------------------------------------------------------- <!-- Copyright (C) Microsoft Corporation. All rights reserved. --> <!DOCTYP SQL> ```
In my understanding,you will need to do following(in addition to what you did) : 1. login to Apex as administrator 2. From settings, go to 'Wallet' 3. Add Wallet path(absolute path with prefix 'file://' and password you used for creating wallet Now, your problem should be solved.
62,851,314
Let me explain what is happening: * Database: Oracle 19c * Apex: 19.1.0.00.15 * ORDS standalone is 19.1.0.r0921545 I did the tasks to configure an Apex Social Sign In to Microsoft AAD without almost any issue: * I created the authentication method in Apex. * I register my application and get the web credentials in Azure. * I created a wallet in my database with the root CA Microsoft certificates and configured the instance settings to usee that wallet. * My wallet in the database server contains the property auto\_login to avoid using passwords. * I created the ACEs entries to allow connection to the login.microsoftonline.com in the port 443 * Although it is not important for the purpose of the question itself and the error that is producing, just comment that I configured the wallet settings in the internal workspace in order to provide access to the wallet to the apex applications. For some weeks the process was working fine, I was having a perfect Single Sing on mechanism for all my apex applications in the different workspaces. However, since some days ago, I am getting always the same error: **ORA-29024: Certificate validation failure** After some digging I realise that someone has configured a PROXY for outgoing traffic. Before even trying in Apex, I tried in SQL using APEX\_WEB\_SERVICE Request with proxy settings to login.microsoftonline.com ``` select apex_web_service.make_rest_request( p_url => 'https://login.microsoftonline.com', p_http_method => 'GET', p_wallet_path => 'file:/home/oracle/wallet', p_wallet_pwd => 'MyPassword' , p_proxy_override => 'http://myproxy:myport' 7 ) from dual; ERROR: ORA-29273: HTTP request failed ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1035 ORA-29024: Certificate validation failure ORA-06512: at "SYS.UTL_HTTP", line 380 ORA-06512: at "SYS.UTL_HTTP", line 1148 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 934 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1580 ORA-06512: at "APEX_190100.WWV_FLOW_WEBSERVICES_API", line 408 ORA-06512: at line 1 ``` Request without proxy settings, just to see if I can get there ``` SQL> select apex_web_service.make_rest_request( 2 p_url => 'https://login.microsoftonline.com', 3 p_http_method => 'GET', 4 p_wallet_path => 'file:/home/oracle/wallet' 5* ) from dual SQL> / ERROR: ORA-29273: HTTP request failed ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1035 ORA-29024: Certificate validation failure ORA-06512: at "SYS.UTL_HTTP", line 380 ORA-06512: at "SYS.UTL_HTTP", line 1148 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 934 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1580 ORA-06512: at "APEX_190100.WWV_FLOW_WEBSERVICES_API", line 408 ORA-06512: at line 1 ``` Request to google using Proxy settings ``` select apex_web_service.make_rest_request( p_url => 'https://google.com', p_http_method => 'GET', p_wallet_path => 'file:/home/oracle/wallet', p_wallet_pwd => 'MyPassword' , 6 p_proxy_override => 'http://myproxy:myport' 7 ) from dual ; ERROR: ORA-29273: HTTP request failed ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1035 ORA-29024: Certificate validation failure ORA-06512: at "SYS.UTL_HTTP", line 380 ORA-06512: at "SYS.UTL_HTTP", line 1148 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 934 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1580 ORA-06512: at "APEX_190100.WWV_FLOW_WEBSERVICES_API", line 408 ORA-06512: at line 1 ``` Request to google without proxy settings ``` SQL> select apex_web_service.make_rest_request( 2 p_url => 'https://google.com', 3 p_http_method => 'GET', 4 p_wallet_path => 'file:/home/oracle/wallet' 5* ) from dual SQL> / ERROR: ORA-29273: HTTP request failed ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1035 ORA-12535: TNS:operation timed out ORA-06512: at "SYS.UTL_HTTP", line 380 ORA-06512: at "SYS.UTL_HTTP", line 1148 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 934 ORA-06512: at "APEX_190100.WWV_FLOW_WEB_SERVICES", line 1580 ORA-06512: at "APEX_190100.WWV_FLOW_WEBSERVICES_API", line 408 ORA-06512: at line 1 ``` My questions are the following: * It is a network problem or a proxy issue regarding inbound/outbound traffic ? I can reach Microsoft but not Google in the port 443 when I don't specify proxy. * Why am I getting invalid certificate when it has nothing to do with the certificates ? * How can I setup my APEX to use authentication on Azure or any other provider for that matter when I have a proxy in the middle ? * As I use ORDS standalone, am I allow to keep using it or I need a reverse proxy with Tomcat ? I tried to configure the ACE to use HTTP\_PROXY in the ports by running ``` begin sys.dbms_network_acl_admin.append_host_ace( host => 'myproxyserver' ,lower_port => 8080 ,upper_port => 8080 ,ace => xs$ace_type( privilege_list => xs$name_list('http_proxy') ,granted => true ,principal_name => 'MY_PRINCIPAL' ,principal_type => XS_ACL.PTYPE_DB ) ); end; / ``` Even I grant to the ACE privileges over the wallet ``` SET SERVEROUTPUT ON BEGIN DBMS_NETWORK_ACL_ADMIN.APPEND_WALLET_ACE ( WALLET_PATH => 'file:/home/oracle/wallet', ACE => XS$ACE_TYPE( PRIVILEGE_LIST => XS$NAME_LIST('use_passwords','use_client_certificates'), PRINCIPAL_NAME => 'MY_PRINCIPAL', PRINCIPAL_TYPE => XS_ACL.PTYPE_DB ) ); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('Error while configuring ACL for wallet: '|| SQLERRM); END; / ``` but I am still getting the same error all over. Any help would be appreciated! Thank you
2020/07/11
[ "https://Stackoverflow.com/questions/62851314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13755538/" ]
Thank you to all who post answers, but finally, after struggling for a while, I found the root cause. Actually Oracle was right after all, as Microsoft has changed the way the authentication is handled, either you are using Oauth2 or OpenID, when you use Office365 and Azure Active Directory. In this case, my organisation is using Office 365 and at the beginning was enough with importing the PKI certificates from : <https://www.microsoft.com/pki/mscorp/cps/default.htm> After a change done in Azure Active Directory (AAD), you now need also the Global Sign certificates from [office.com](http://office.com) I hope it clarifies to other users who got in the same problem trying to authenticate with Azure Active Directory using Apex Social sign in. You can download the certificates directly from office365.com [![enter image description here](https://i.stack.imgur.com/zkbq2.png)](https://i.stack.imgur.com/zkbq2.png) After adding the new two certificates to the wallet, you can now enter without issues: ``` select apex_web_service.make_rest_request( p_url => 'https://login.microsoftonline.com', p_http_method => 'GET', 4 p_wallet_path => 'file:/home/oracle/wallet' ) from dual ; APEX_WEB_SERVICE.MAKE_REST_REQUEST(P_URL=>'HTTPS://LOGIN.MICROSOFTONLINE.COM',P_ -------------------------------------------------------------------------------- <!-- Copyright (C) Microsoft Corporation. All rights reserved. --> <!DOCTYP SQL> ```
I had issue like this, it seems Oracle SSL library has some bugs. Finally I implemented some Java Source for OJVM, please read my answer here: <https://stackoverflow.com/a/60152830/11272044>
20,576,864
I am using Omniauth in a Rails application for login, my omniauth.rb, is as show below: ``` OmniAuth.config.logger = Rails.logger Rails.application.config.middleware.use OmniAuth::Builder do provider :facebook, 'xxxxxxx', 'xxxxxxx' provider :google_oauth2, 'xxxxxxxxx','xxxxxxxx' end ``` When a user attempts to login (via Facebook or Goolge) and denies permissions, get the following error: ``` OmniAuth::Strategies::OAuth2::CallbackError ``` with this parameters: ``` {"error"=>"access_denied", "error_code"=>"200", "error_description"=>"Permissions error", "error_reason"=>"user_denied", "state"=>"60daee5f78d9cc28972050ae8ca8f950bb4ed5958302bcea"} ``` if the user accept, no problem and everything works fine. I've tried some of the possible solutions related with this error, and listed on this website, but none solved my problem. For example: [How to rescue OmniAuth::Strategies::OAuth2::CallbackError?](https://stackoverflow.com/questions/10737200/how-to-rescue-omniauthstrategiesoauth2callbackerror) [Omniauth+facebook error when trying to cancel the popup](https://stackoverflow.com/questions/10647642/omniauthfacebook-error-when-trying-to-cancel-the-popup) Please, I need help to solve this problem.
2013/12/13
[ "https://Stackoverflow.com/questions/20576864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3100897/" ]
Our old friend `strace` solves this mystery. In the `fflush("cat")` case, awk quickly writes all three values while cat is still loading. When cat finishes loading, it reads all three values in sequence and writes them out at the same time. In the case of `close("cat")`, awk waits for the process to exit, at which point cat is guaranteed to have read the value, written it, and exited. I increased the numbers in the `fflush` case from 3 to 1000, and now `awk` reaches 120 before cat catches up, and from there on it works basically as you expect. It prints "1,2,..,120,1,2,...,120,121,121,122,122,123,123,...". Note that you're not guaranteed to see numbers in perfect pairs. awk blocks until the number has been written to the pipe, but it doesn't wait for cat to do anything with it.
Not really something I have much experience of but the gawk manual tells us: > > fflush([filename]) > Flush any buffered output associated with filename, > which is either a file opened for writing or a shell command for > redirecting output **to a pipe** or coprocess. > > > Note that "cat" as used above is in none of the contexts the gawk manual says are affected by fflush(). The same manual for close() on the other hand says: > > close(filename [, how]) > Close the file filename for input or output. > Alternatively, the argument may be a shell command that was used for > creating a coprocess, or for redirecting **to or from a pipe**; then > the coprocess or pipe is closed. > > > Note that the context in which you're using cat is redirecting **from** a pipe and so is included in the list of items affected by close() but not by fflush().
946,937
I bought a Dell Studio XPS 8100 desktop back in 2010, which had Windows 7 installed and came with a partition for Dell Factory Restore. After having installed Windows 10, what happened to that partition? Did the installation get rid of it? If not and I were to use it to do a Dell Factory Restore, would it "reinstall" Windows 7? Sorry if this is a duplicate of a question somewhere, I didn't see one exactly like this asking about Windows 10 upgrade and Dell's Recovery partition.
2015/07/29
[ "https://superuser.com/questions/946937", "https://superuser.com", "https://superuser.com/users/474857/" ]
The recovery partition will not be touched nor upgraded during this process. If you did a factory restore, you would end up with Windows 7.
If you run into a problem where you cannot access your recovery partition, or the partition is deleted, you can run a tool called DSRFIX and it should restore the recovery partition.
946,937
I bought a Dell Studio XPS 8100 desktop back in 2010, which had Windows 7 installed and came with a partition for Dell Factory Restore. After having installed Windows 10, what happened to that partition? Did the installation get rid of it? If not and I were to use it to do a Dell Factory Restore, would it "reinstall" Windows 7? Sorry if this is a duplicate of a question somewhere, I didn't see one exactly like this asking about Windows 10 upgrade and Dell's Recovery partition.
2015/07/29
[ "https://superuser.com/questions/946937", "https://superuser.com", "https://superuser.com/users/474857/" ]
From what I am seeing, if there is not a system partition on the drive, only the Dell recovery partition & OS partition, then Windows 10 will alter the boot folder of that partition. This effects the PE recovery environment & will break the factory recovery. Even after reapplying the Factory.wim of windows 7 and it blue screens, Windows 10 PE recovery environment will start & not help with the start up issues. I'm presently trying to undo all of this on a Dell Inspiron laptop at present. I don't think this will happen if there is a 100MB system partition on the drive as this is where the Windows 10 recovery environment will install (in the boot folder). Thus leaving the Dell Recovery partition untouched leaving the F11 function in tact to be able to factory install the OS that shipped with the laptop. Isn't the digital life wonderful!!!
If you run into a problem where you cannot access your recovery partition, or the partition is deleted, you can run a tool called DSRFIX and it should restore the recovery partition.
418,342
I know I can pass parameters to java to limit the amount of memory used, but that doesn't change the application behavior. (assuming I will get an out of memory exception or similar) I would like to limit the amount of memory that solr uses. I am assuming it is as simple as setting a single configuration option, but googling so far has been fruitless. Any ideas? Thanks! Edit: I just want to note that I understand there will be a tradeoff between memory usage and execution speed. In this case, I am willing to sacrifice speed to reduce memory footprint. I also understand that it is possible that solr does not support the option of tuning this tradeoff.
2012/08/16
[ "https://serverfault.com/questions/418342", "https://serverfault.com", "https://serverfault.com/users/107102/" ]
Check out this article, it should address your needs <http://blogs.technet.com/b/grouppolicy/archive/2009/07/30/security-filtering-wmi-filtering-and-item-level-targeting-in-group-policy-preferences.aspx> and like Joe said, yes you can use groups for computers as well
Yes, you can use a security group populated with computer accounts to filter Group Policy.
29,743,729
I am using video.js (<http://www.videojs.com/>) to build a video approval system and need to log user actions in the player. I can do this easily enough with play, pause, end etc. but have hit a problem when trying to log seeks. I want to be able to log the start and end times of any seeks within the plaback, so we know if the user has not actually watched a section of the video. The player seems to offer events to support this, but I am struggling to get correct timings from it. When the user skips through a video the player emits the following events in order: pause, seeking, seeked, play. If I query the player object at any of these events using currentTime() the result is always the end time for the seek, even on the initial pause event. This means I can log where the seek ended but not where it started. Can anyone help me to find the position in the video where the seek begins? If this is not possible, I'd settle for a way to disable seeking during playback. EDIT: adding code as requested. It's pretty simple: ``` var trackedPlayer = videojs('pvp-player'); trackedPlayer.on("play", function (e) { console.log("Video playback started: " + trackedPlayer.currentTime()); }); trackedPlayer.on("pause", function (e) { console.log("Video playback paused: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeking", function (e) { console.log("Video seeking: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeked", function (e) { console.log("Video seek ended: " + trackedPlayer.currentTime()); }); trackedPlayer.on("ended", function (e) { console.log("Video playback ended."); }); ``` If I can get all the tracking I want I will replace console.log with ajax calls to store the data.
2015/04/20
[ "https://Stackoverflow.com/questions/29743729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2664914/" ]
You can listen to `timeupdate` und take the next to last value you got there before `seeking` is called as your source: ``` var previousTime = 0; var currentTime = 0; trackedPlayer.on('timeupdate', function() { previousTime = currentTime; currentTime = trackedPlayer.currentTime(); }); trackedPlayer.on('seeking', function() { console.log('seeking from', previousTime, 'to', currentTime, '; delta:', currentTime - previousTime); }); ``` This seems to work with the HTML5 tech. I have not tested with other techs. There is, however, one glitch: the first time seeking a *paused* player yields only a small delta (and the almost-same previous value for both variables). But this shouldn’t matter much since the delta is only a few hundred milliseconds (and I gather you’re only interested in the “from” value). **Update** `seeked` is triggered far more infrequently than `seeking`. Try the following. ``` var previousTime = 0; var currentTime = 0; var seekStart = null; trackedPlayer.on('timeupdate', function() { previousTime = currentTime; currentTime = trackedPlayer.currentTime(); }); trackedPlayer.on('seeking', function() { if(seekStart === null) { seekStart = previousTime; } }); trackedPlayer.on('seeked', function() { console.log('seeked from', seekStart, 'to', currentTime, '; delta:', currentTime - previousTime); seekStart = null; }); ``` There are also many libraries for debouncing function calls (in this case the call to your backend).
Try with this code to know the length of video. ``` var duration = document.getElementById("duration"); var vid_duration = Math.round(document.getElementById("video").duration); //alert(vid_duration); duration.innerHTML = vid_duration; //duration.firstChild.nodeValue = vid_duration; ```
29,743,729
I am using video.js (<http://www.videojs.com/>) to build a video approval system and need to log user actions in the player. I can do this easily enough with play, pause, end etc. but have hit a problem when trying to log seeks. I want to be able to log the start and end times of any seeks within the plaback, so we know if the user has not actually watched a section of the video. The player seems to offer events to support this, but I am struggling to get correct timings from it. When the user skips through a video the player emits the following events in order: pause, seeking, seeked, play. If I query the player object at any of these events using currentTime() the result is always the end time for the seek, even on the initial pause event. This means I can log where the seek ended but not where it started. Can anyone help me to find the position in the video where the seek begins? If this is not possible, I'd settle for a way to disable seeking during playback. EDIT: adding code as requested. It's pretty simple: ``` var trackedPlayer = videojs('pvp-player'); trackedPlayer.on("play", function (e) { console.log("Video playback started: " + trackedPlayer.currentTime()); }); trackedPlayer.on("pause", function (e) { console.log("Video playback paused: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeking", function (e) { console.log("Video seeking: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeked", function (e) { console.log("Video seek ended: " + trackedPlayer.currentTime()); }); trackedPlayer.on("ended", function (e) { console.log("Video playback ended."); }); ``` If I can get all the tracking I want I will replace console.log with ajax calls to store the data.
2015/04/20
[ "https://Stackoverflow.com/questions/29743729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2664914/" ]
I needed to find the same value for a project I was working on so I could determine whether or not a user was skipping forward or backward in a videojs player. Initially, I thought to save the currentTime() a user was seeking **from** on **timeupdate** then immediately removing my timeupdate listener once **seeking** was dispatched. While this worked in some browsers like Chrome, unfortunately, I found that other browsers continued to fire timeupdate more frequently and would continue to update the currentTime() I was saving after the player actually seeked. Here was the solution that ultimately worked across Safari/Chrome/Firefox. I have yet to test in IE. ``` var previousTime = 0, currentTime = 0, completeTime = 0, position = 0; trackedPlayer.on('timeupdate', function() { previousTime = currentTime; currentTime = Math.floor(player.currentTime()); // save 'position' so long as time is moving forward with each update if (previousTime < currentTime) { position = previousTime; previousTime = currentTime; } }); // when seeking starts trackedPlayer.on('seeking', function() { player.off('timeupdate', onTimeUpdate); player.one('seeked', onSeekComplete); }); // when seeking completes trackedPlayer.on('seeked', function() { completeTime = Math.floor(player.currentTime()); console.log("User came from: " + position); console.log("User ended at: " + completeTime); }); ```
Try with this code to know the length of video. ``` var duration = document.getElementById("duration"); var vid_duration = Math.round(document.getElementById("video").duration); //alert(vid_duration); duration.innerHTML = vid_duration; //duration.firstChild.nodeValue = vid_duration; ```
29,743,729
I am using video.js (<http://www.videojs.com/>) to build a video approval system and need to log user actions in the player. I can do this easily enough with play, pause, end etc. but have hit a problem when trying to log seeks. I want to be able to log the start and end times of any seeks within the plaback, so we know if the user has not actually watched a section of the video. The player seems to offer events to support this, but I am struggling to get correct timings from it. When the user skips through a video the player emits the following events in order: pause, seeking, seeked, play. If I query the player object at any of these events using currentTime() the result is always the end time for the seek, even on the initial pause event. This means I can log where the seek ended but not where it started. Can anyone help me to find the position in the video where the seek begins? If this is not possible, I'd settle for a way to disable seeking during playback. EDIT: adding code as requested. It's pretty simple: ``` var trackedPlayer = videojs('pvp-player'); trackedPlayer.on("play", function (e) { console.log("Video playback started: " + trackedPlayer.currentTime()); }); trackedPlayer.on("pause", function (e) { console.log("Video playback paused: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeking", function (e) { console.log("Video seeking: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeked", function (e) { console.log("Video seek ended: " + trackedPlayer.currentTime()); }); trackedPlayer.on("ended", function (e) { console.log("Video playback ended."); }); ``` If I can get all the tracking I want I will replace console.log with ajax calls to store the data.
2015/04/20
[ "https://Stackoverflow.com/questions/29743729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2664914/" ]
I know this is an old post but this is the only solution that worked for me. ``` var counter = 0; var beforeTimeChange = 0; function handleSeeking() { var timeoutTime = 300; var beforeCounter = counter + 1; if (trackedPlayer.cache_.currentTime === trackedPlayer.duration()) { return; // when video starts over, calls seek } beforeTimeChange = beforeTimeChange || trackedPlayer.cache_.currentTime; setTimeout(function() { if (beforeCounter === counter) { console.log('before seek', beforeTimeChange, '\nafter seek', trackedPlayer.currentTime() - (timeoutTime / 1000)); counter = 0; beforeTimeChange = 0; } }, timeoutTime); counter++; } trackedPlayer.on('seeking', handleSeeking); ```
Try with this code to know the length of video. ``` var duration = document.getElementById("duration"); var vid_duration = Math.round(document.getElementById("video").duration); //alert(vid_duration); duration.innerHTML = vid_duration; //duration.firstChild.nodeValue = vid_duration; ```
29,743,729
I am using video.js (<http://www.videojs.com/>) to build a video approval system and need to log user actions in the player. I can do this easily enough with play, pause, end etc. but have hit a problem when trying to log seeks. I want to be able to log the start and end times of any seeks within the plaback, so we know if the user has not actually watched a section of the video. The player seems to offer events to support this, but I am struggling to get correct timings from it. When the user skips through a video the player emits the following events in order: pause, seeking, seeked, play. If I query the player object at any of these events using currentTime() the result is always the end time for the seek, even on the initial pause event. This means I can log where the seek ended but not where it started. Can anyone help me to find the position in the video where the seek begins? If this is not possible, I'd settle for a way to disable seeking during playback. EDIT: adding code as requested. It's pretty simple: ``` var trackedPlayer = videojs('pvp-player'); trackedPlayer.on("play", function (e) { console.log("Video playback started: " + trackedPlayer.currentTime()); }); trackedPlayer.on("pause", function (e) { console.log("Video playback paused: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeking", function (e) { console.log("Video seeking: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeked", function (e) { console.log("Video seek ended: " + trackedPlayer.currentTime()); }); trackedPlayer.on("ended", function (e) { console.log("Video playback ended."); }); ``` If I can get all the tracking I want I will replace console.log with ajax calls to store the data.
2015/04/20
[ "https://Stackoverflow.com/questions/29743729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2664914/" ]
For a more accurate solution, you can listen to the events that trigger the seek such as mousedown on progress bar, left key, right key etc., and get the current time from these events. For example in version 7.10.2 you can do the following, ``` let seekStartTime; player.controlBar.progressControl.on('mousedown', () => seekStartTime = player.currentTime()); player.controlBar.progressControl.seekBar.on('mousedown', () => seekStartTime = player.currentTime()); player.on('keydown', (e) => { if (e.key === "ArrowLeft" || e.key === "ArrowRight") { seekStartTime = player.currentTime(); } }); console.log(seekStartTime); ``` **Note 1:** There are two seperate mousedown event listeners for progress control and seek bar. This is because the video can be seeked by clicking outside the seek bar on the progress control as well. **Note 2:** Seeking using hotkey numbers does not pause the video. However, if necessary you can add those keydown listeners too.
Try with this code to know the length of video. ``` var duration = document.getElementById("duration"); var vid_duration = Math.round(document.getElementById("video").duration); //alert(vid_duration); duration.innerHTML = vid_duration; //duration.firstChild.nodeValue = vid_duration; ```
29,743,729
I am using video.js (<http://www.videojs.com/>) to build a video approval system and need to log user actions in the player. I can do this easily enough with play, pause, end etc. but have hit a problem when trying to log seeks. I want to be able to log the start and end times of any seeks within the plaback, so we know if the user has not actually watched a section of the video. The player seems to offer events to support this, but I am struggling to get correct timings from it. When the user skips through a video the player emits the following events in order: pause, seeking, seeked, play. If I query the player object at any of these events using currentTime() the result is always the end time for the seek, even on the initial pause event. This means I can log where the seek ended but not where it started. Can anyone help me to find the position in the video where the seek begins? If this is not possible, I'd settle for a way to disable seeking during playback. EDIT: adding code as requested. It's pretty simple: ``` var trackedPlayer = videojs('pvp-player'); trackedPlayer.on("play", function (e) { console.log("Video playback started: " + trackedPlayer.currentTime()); }); trackedPlayer.on("pause", function (e) { console.log("Video playback paused: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeking", function (e) { console.log("Video seeking: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeked", function (e) { console.log("Video seek ended: " + trackedPlayer.currentTime()); }); trackedPlayer.on("ended", function (e) { console.log("Video playback ended."); }); ``` If I can get all the tracking I want I will replace console.log with ajax calls to store the data.
2015/04/20
[ "https://Stackoverflow.com/questions/29743729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2664914/" ]
I needed to find the start and end of a seeking action in my project and I used @Motorcykey answer and it worked, but there was a small bug. when I tried to seek to a time before the current time while the player was paused, the `position` didn't get updated. so I added just one line and it fixed it. I've tried other solutions too but so far this was the best solution that I've found. Here's the code snippet on player 'seeked' ``` player.on('seeked', function () { completeTime = Math.floor(player.currentTime()); console.log("User came from: " + position); console.log("User ended at: " + completeTime); position= Math.floor(player.currentTime()) }); ```
Try with this code to know the length of video. ``` var duration = document.getElementById("duration"); var vid_duration = Math.round(document.getElementById("video").duration); //alert(vid_duration); duration.innerHTML = vid_duration; //duration.firstChild.nodeValue = vid_duration; ```
29,743,729
I am using video.js (<http://www.videojs.com/>) to build a video approval system and need to log user actions in the player. I can do this easily enough with play, pause, end etc. but have hit a problem when trying to log seeks. I want to be able to log the start and end times of any seeks within the plaback, so we know if the user has not actually watched a section of the video. The player seems to offer events to support this, but I am struggling to get correct timings from it. When the user skips through a video the player emits the following events in order: pause, seeking, seeked, play. If I query the player object at any of these events using currentTime() the result is always the end time for the seek, even on the initial pause event. This means I can log where the seek ended but not where it started. Can anyone help me to find the position in the video where the seek begins? If this is not possible, I'd settle for a way to disable seeking during playback. EDIT: adding code as requested. It's pretty simple: ``` var trackedPlayer = videojs('pvp-player'); trackedPlayer.on("play", function (e) { console.log("Video playback started: " + trackedPlayer.currentTime()); }); trackedPlayer.on("pause", function (e) { console.log("Video playback paused: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeking", function (e) { console.log("Video seeking: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeked", function (e) { console.log("Video seek ended: " + trackedPlayer.currentTime()); }); trackedPlayer.on("ended", function (e) { console.log("Video playback ended."); }); ``` If I can get all the tracking I want I will replace console.log with ajax calls to store the data.
2015/04/20
[ "https://Stackoverflow.com/questions/29743729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2664914/" ]
You can listen to `timeupdate` und take the next to last value you got there before `seeking` is called as your source: ``` var previousTime = 0; var currentTime = 0; trackedPlayer.on('timeupdate', function() { previousTime = currentTime; currentTime = trackedPlayer.currentTime(); }); trackedPlayer.on('seeking', function() { console.log('seeking from', previousTime, 'to', currentTime, '; delta:', currentTime - previousTime); }); ``` This seems to work with the HTML5 tech. I have not tested with other techs. There is, however, one glitch: the first time seeking a *paused* player yields only a small delta (and the almost-same previous value for both variables). But this shouldn’t matter much since the delta is only a few hundred milliseconds (and I gather you’re only interested in the “from” value). **Update** `seeked` is triggered far more infrequently than `seeking`. Try the following. ``` var previousTime = 0; var currentTime = 0; var seekStart = null; trackedPlayer.on('timeupdate', function() { previousTime = currentTime; currentTime = trackedPlayer.currentTime(); }); trackedPlayer.on('seeking', function() { if(seekStart === null) { seekStart = previousTime; } }); trackedPlayer.on('seeked', function() { console.log('seeked from', seekStart, 'to', currentTime, '; delta:', currentTime - previousTime); seekStart = null; }); ``` There are also many libraries for debouncing function calls (in this case the call to your backend).
I needed to find the same value for a project I was working on so I could determine whether or not a user was skipping forward or backward in a videojs player. Initially, I thought to save the currentTime() a user was seeking **from** on **timeupdate** then immediately removing my timeupdate listener once **seeking** was dispatched. While this worked in some browsers like Chrome, unfortunately, I found that other browsers continued to fire timeupdate more frequently and would continue to update the currentTime() I was saving after the player actually seeked. Here was the solution that ultimately worked across Safari/Chrome/Firefox. I have yet to test in IE. ``` var previousTime = 0, currentTime = 0, completeTime = 0, position = 0; trackedPlayer.on('timeupdate', function() { previousTime = currentTime; currentTime = Math.floor(player.currentTime()); // save 'position' so long as time is moving forward with each update if (previousTime < currentTime) { position = previousTime; previousTime = currentTime; } }); // when seeking starts trackedPlayer.on('seeking', function() { player.off('timeupdate', onTimeUpdate); player.one('seeked', onSeekComplete); }); // when seeking completes trackedPlayer.on('seeked', function() { completeTime = Math.floor(player.currentTime()); console.log("User came from: " + position); console.log("User ended at: " + completeTime); }); ```
29,743,729
I am using video.js (<http://www.videojs.com/>) to build a video approval system and need to log user actions in the player. I can do this easily enough with play, pause, end etc. but have hit a problem when trying to log seeks. I want to be able to log the start and end times of any seeks within the plaback, so we know if the user has not actually watched a section of the video. The player seems to offer events to support this, but I am struggling to get correct timings from it. When the user skips through a video the player emits the following events in order: pause, seeking, seeked, play. If I query the player object at any of these events using currentTime() the result is always the end time for the seek, even on the initial pause event. This means I can log where the seek ended but not where it started. Can anyone help me to find the position in the video where the seek begins? If this is not possible, I'd settle for a way to disable seeking during playback. EDIT: adding code as requested. It's pretty simple: ``` var trackedPlayer = videojs('pvp-player'); trackedPlayer.on("play", function (e) { console.log("Video playback started: " + trackedPlayer.currentTime()); }); trackedPlayer.on("pause", function (e) { console.log("Video playback paused: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeking", function (e) { console.log("Video seeking: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeked", function (e) { console.log("Video seek ended: " + trackedPlayer.currentTime()); }); trackedPlayer.on("ended", function (e) { console.log("Video playback ended."); }); ``` If I can get all the tracking I want I will replace console.log with ajax calls to store the data.
2015/04/20
[ "https://Stackoverflow.com/questions/29743729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2664914/" ]
You can listen to `timeupdate` und take the next to last value you got there before `seeking` is called as your source: ``` var previousTime = 0; var currentTime = 0; trackedPlayer.on('timeupdate', function() { previousTime = currentTime; currentTime = trackedPlayer.currentTime(); }); trackedPlayer.on('seeking', function() { console.log('seeking from', previousTime, 'to', currentTime, '; delta:', currentTime - previousTime); }); ``` This seems to work with the HTML5 tech. I have not tested with other techs. There is, however, one glitch: the first time seeking a *paused* player yields only a small delta (and the almost-same previous value for both variables). But this shouldn’t matter much since the delta is only a few hundred milliseconds (and I gather you’re only interested in the “from” value). **Update** `seeked` is triggered far more infrequently than `seeking`. Try the following. ``` var previousTime = 0; var currentTime = 0; var seekStart = null; trackedPlayer.on('timeupdate', function() { previousTime = currentTime; currentTime = trackedPlayer.currentTime(); }); trackedPlayer.on('seeking', function() { if(seekStart === null) { seekStart = previousTime; } }); trackedPlayer.on('seeked', function() { console.log('seeked from', seekStart, 'to', currentTime, '; delta:', currentTime - previousTime); seekStart = null; }); ``` There are also many libraries for debouncing function calls (in this case the call to your backend).
I know this is an old post but this is the only solution that worked for me. ``` var counter = 0; var beforeTimeChange = 0; function handleSeeking() { var timeoutTime = 300; var beforeCounter = counter + 1; if (trackedPlayer.cache_.currentTime === trackedPlayer.duration()) { return; // when video starts over, calls seek } beforeTimeChange = beforeTimeChange || trackedPlayer.cache_.currentTime; setTimeout(function() { if (beforeCounter === counter) { console.log('before seek', beforeTimeChange, '\nafter seek', trackedPlayer.currentTime() - (timeoutTime / 1000)); counter = 0; beforeTimeChange = 0; } }, timeoutTime); counter++; } trackedPlayer.on('seeking', handleSeeking); ```
29,743,729
I am using video.js (<http://www.videojs.com/>) to build a video approval system and need to log user actions in the player. I can do this easily enough with play, pause, end etc. but have hit a problem when trying to log seeks. I want to be able to log the start and end times of any seeks within the plaback, so we know if the user has not actually watched a section of the video. The player seems to offer events to support this, but I am struggling to get correct timings from it. When the user skips through a video the player emits the following events in order: pause, seeking, seeked, play. If I query the player object at any of these events using currentTime() the result is always the end time for the seek, even on the initial pause event. This means I can log where the seek ended but not where it started. Can anyone help me to find the position in the video where the seek begins? If this is not possible, I'd settle for a way to disable seeking during playback. EDIT: adding code as requested. It's pretty simple: ``` var trackedPlayer = videojs('pvp-player'); trackedPlayer.on("play", function (e) { console.log("Video playback started: " + trackedPlayer.currentTime()); }); trackedPlayer.on("pause", function (e) { console.log("Video playback paused: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeking", function (e) { console.log("Video seeking: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeked", function (e) { console.log("Video seek ended: " + trackedPlayer.currentTime()); }); trackedPlayer.on("ended", function (e) { console.log("Video playback ended."); }); ``` If I can get all the tracking I want I will replace console.log with ajax calls to store the data.
2015/04/20
[ "https://Stackoverflow.com/questions/29743729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2664914/" ]
You can listen to `timeupdate` und take the next to last value you got there before `seeking` is called as your source: ``` var previousTime = 0; var currentTime = 0; trackedPlayer.on('timeupdate', function() { previousTime = currentTime; currentTime = trackedPlayer.currentTime(); }); trackedPlayer.on('seeking', function() { console.log('seeking from', previousTime, 'to', currentTime, '; delta:', currentTime - previousTime); }); ``` This seems to work with the HTML5 tech. I have not tested with other techs. There is, however, one glitch: the first time seeking a *paused* player yields only a small delta (and the almost-same previous value for both variables). But this shouldn’t matter much since the delta is only a few hundred milliseconds (and I gather you’re only interested in the “from” value). **Update** `seeked` is triggered far more infrequently than `seeking`. Try the following. ``` var previousTime = 0; var currentTime = 0; var seekStart = null; trackedPlayer.on('timeupdate', function() { previousTime = currentTime; currentTime = trackedPlayer.currentTime(); }); trackedPlayer.on('seeking', function() { if(seekStart === null) { seekStart = previousTime; } }); trackedPlayer.on('seeked', function() { console.log('seeked from', seekStart, 'to', currentTime, '; delta:', currentTime - previousTime); seekStart = null; }); ``` There are also many libraries for debouncing function calls (in this case the call to your backend).
For a more accurate solution, you can listen to the events that trigger the seek such as mousedown on progress bar, left key, right key etc., and get the current time from these events. For example in version 7.10.2 you can do the following, ``` let seekStartTime; player.controlBar.progressControl.on('mousedown', () => seekStartTime = player.currentTime()); player.controlBar.progressControl.seekBar.on('mousedown', () => seekStartTime = player.currentTime()); player.on('keydown', (e) => { if (e.key === "ArrowLeft" || e.key === "ArrowRight") { seekStartTime = player.currentTime(); } }); console.log(seekStartTime); ``` **Note 1:** There are two seperate mousedown event listeners for progress control and seek bar. This is because the video can be seeked by clicking outside the seek bar on the progress control as well. **Note 2:** Seeking using hotkey numbers does not pause the video. However, if necessary you can add those keydown listeners too.
29,743,729
I am using video.js (<http://www.videojs.com/>) to build a video approval system and need to log user actions in the player. I can do this easily enough with play, pause, end etc. but have hit a problem when trying to log seeks. I want to be able to log the start and end times of any seeks within the plaback, so we know if the user has not actually watched a section of the video. The player seems to offer events to support this, but I am struggling to get correct timings from it. When the user skips through a video the player emits the following events in order: pause, seeking, seeked, play. If I query the player object at any of these events using currentTime() the result is always the end time for the seek, even on the initial pause event. This means I can log where the seek ended but not where it started. Can anyone help me to find the position in the video where the seek begins? If this is not possible, I'd settle for a way to disable seeking during playback. EDIT: adding code as requested. It's pretty simple: ``` var trackedPlayer = videojs('pvp-player'); trackedPlayer.on("play", function (e) { console.log("Video playback started: " + trackedPlayer.currentTime()); }); trackedPlayer.on("pause", function (e) { console.log("Video playback paused: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeking", function (e) { console.log("Video seeking: " + trackedPlayer.currentTime()); }); trackedPlayer.on("seeked", function (e) { console.log("Video seek ended: " + trackedPlayer.currentTime()); }); trackedPlayer.on("ended", function (e) { console.log("Video playback ended."); }); ``` If I can get all the tracking I want I will replace console.log with ajax calls to store the data.
2015/04/20
[ "https://Stackoverflow.com/questions/29743729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2664914/" ]
You can listen to `timeupdate` und take the next to last value you got there before `seeking` is called as your source: ``` var previousTime = 0; var currentTime = 0; trackedPlayer.on('timeupdate', function() { previousTime = currentTime; currentTime = trackedPlayer.currentTime(); }); trackedPlayer.on('seeking', function() { console.log('seeking from', previousTime, 'to', currentTime, '; delta:', currentTime - previousTime); }); ``` This seems to work with the HTML5 tech. I have not tested with other techs. There is, however, one glitch: the first time seeking a *paused* player yields only a small delta (and the almost-same previous value for both variables). But this shouldn’t matter much since the delta is only a few hundred milliseconds (and I gather you’re only interested in the “from” value). **Update** `seeked` is triggered far more infrequently than `seeking`. Try the following. ``` var previousTime = 0; var currentTime = 0; var seekStart = null; trackedPlayer.on('timeupdate', function() { previousTime = currentTime; currentTime = trackedPlayer.currentTime(); }); trackedPlayer.on('seeking', function() { if(seekStart === null) { seekStart = previousTime; } }); trackedPlayer.on('seeked', function() { console.log('seeked from', seekStart, 'to', currentTime, '; delta:', currentTime - previousTime); seekStart = null; }); ``` There are also many libraries for debouncing function calls (in this case the call to your backend).
I needed to find the start and end of a seeking action in my project and I used @Motorcykey answer and it worked, but there was a small bug. when I tried to seek to a time before the current time while the player was paused, the `position` didn't get updated. so I added just one line and it fixed it. I've tried other solutions too but so far this was the best solution that I've found. Here's the code snippet on player 'seeked' ``` player.on('seeked', function () { completeTime = Math.floor(player.currentTime()); console.log("User came from: " + position); console.log("User ended at: " + completeTime); position= Math.floor(player.currentTime()) }); ```
2,767,139
Can I do this in C++ (if yes, what is the syntax?): ``` void func(string* strs) { // do something } func({"abc", "cde"}); ``` I want to pass an array to a function, without instantiating it as a variable.
2010/05/04
[ "https://Stackoverflow.com/questions/2767139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/187141/" ]
It can't be done in the current C++, as defined by C++03. The feature you are looking for is called "compound literals". It is present in C language, as defined by C99 (with C-specific capabilities, of course), but not in C++. A similar feature is planned for C++ as well, but it is not there yet.
I don't think you can do that in C++98, but you can with [initializer\_lists](https://stackoverflow.com/questions/2357452/stdinitializer-list-as-function-argument) in C++1x.
2,767,139
Can I do this in C++ (if yes, what is the syntax?): ``` void func(string* strs) { // do something } func({"abc", "cde"}); ``` I want to pass an array to a function, without instantiating it as a variable.
2010/05/04
[ "https://Stackoverflow.com/questions/2767139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/187141/" ]
It can't be done in the current C++, as defined by C++03. The feature you are looking for is called "compound literals". It is present in C language, as defined by C99 (with C-specific capabilities, of course), but not in C++. A similar feature is planned for C++ as well, but it is not there yet.
As written, you can't do this. The function expects a pointer-to-string. Even if you were able to pass an array as a literal, the function call would generate errors because literals are considered constant (thus, the array of literals would be of type `const string*`, not `string*` as the function expects).
2,767,139
Can I do this in C++ (if yes, what is the syntax?): ``` void func(string* strs) { // do something } func({"abc", "cde"}); ``` I want to pass an array to a function, without instantiating it as a variable.
2010/05/04
[ "https://Stackoverflow.com/questions/2767139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/187141/" ]
It can't be done in the current C++, as defined by C++03. The feature you are looking for is called "compound literals". It is present in C language, as defined by C99 (with C-specific capabilities, of course), but not in C++. A similar feature is planned for C++ as well, but it is not there yet.
Use a variadic function to pass in unlimited untyped information into a function. Then do whatever you want with the passed in data, such as stuffing it into an internal array. [variadic function](http://en.wikipedia.org/wiki/Variadic_function#Variadic_functions_in_C.2C_Objective-C.2C_C.2B.2B.2C_and_D)
14,559,761
I want to use `std::initializer_list`s in Visual Studio 2012 like a guy in [this example](http://musingstudio.com/2012/11/27/stdinitializer_list-an-even-better-way-to-populate-a-vector/) does. My operating system is Windows 8 x64. Therefore I lately installed the [Visual C++ Compiler November 2012 CTP](http://www.microsoft.com/en-us/download/details.aspx?id=35515) and as mentioned by Microsoft, I changed the platform toolset of my project to use that new updated compiler. But even after doing so, there is neither a `std::initializer_list` nor a `<initializer_list>` header available. But the linked website from Microsoft tells me (under the headline "Overview") that initializer lists would be available with that update. I restarted both the IDE and my PC. I am not sure if it could be caused by the fact that I am (sadly) using the German edition of Visual Studio and the compiler update is in English. What am I doing wrong? Update: Trying to compile the line `auto a = { 0 };` which is criticized by IntelliSense the compiler output shows `'Microsoft Visual C++ Compiler Nov 2012 CTP' is for testing purposes only.` and then compiler crashes and a error window appears which reads `Microsoft (R) C/C++ Compiler Driver has stopped working`. Without any new syntax, everything compiles and works fine with the new compiler selected.
2013/01/28
[ "https://Stackoverflow.com/questions/14559761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1079110/" ]
(I work for Microsoft and with Dinkumware to maintain VC's Standard Library implementation.) [danijar] > > I am not sure if it could be caused by the fact that I am (sadly) using the German edition of Visual Studio and the compiler update is in English. > > > Unfortunately, the English-only CTP does not support German VS. The "compiler driver" cl.exe is what invokes the compiler front-end c1xx.dll, the compiler back-end c2.dll, and the linker link.exe. It is very unusual for the compiler driver to crash. I speculate that it's attempting to display one of the error messages that were added by the CTP, but since the CTP didn't update the German resources, the compiler driver can't load the error message and proceeds to crash. Note that this is different from an Internal Compiler Error in the front-end or back-end, or a normal compiler error that happens to be incorrectly emitted. (Many ICEs and bogus errors have been fixed after the CTP was released.) > > But even after doing so, there is neither a std::initializer\_list nor a <initializer\_list> header available. > > > The CTP installed <initializer\_list> in a special location. (It was actually written by the compiler team.) On the command line, the incantations to use the CTP and put <initializer\_list> on the include path are (assuming default locations): ``` "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86 set PATH=C:\Program Files (x86)\Microsoft Visual C++ Compiler Nov 2012 CTP\bin;%PATH% set INCLUDE=C:\Program Files (x86)\Microsoft Visual C++ Compiler Nov 2012 CTP\include;%INCLUDE% ``` > > Trying to compile the line auto a = { 0 }; which is criticized by IntelliSense > > > This was documented - Intellisense was not updated by the CTP, therefore it will not recognize any of the new features. [rubenvb] > > The C++ Standard Library was not updated with the compiler, leaving you without decent <tuple> and <intializer\_list> (this includes the omission of the braced init list constructors for all standard containers) > > > You may be interested to learn that we've updated the standard library to fully support scoped enums and initializer lists. This includes all initializer\_list overloads mandated by the current Working Paper (N3485), plus installing <initializer\_list> in the usual location along with all other standard headers. (It is also Dinkumware's official copy, although the differences between it and the compiler team's "fake" version were mostly cosmetic.) This stuff will be available in the next public release, whenever and whatever that is. Our next task is to update the standard library with explicit conversion operators and variadic templates, replacing our brittle simulations.
As you have noticed, the November CTP is very limited in usability for at least two reasons: 1. The compiler has numerous crash-causing bugs, such as the one you discovered. 2. The C++ Standard Library was not updated with the compiler, leaving you without decent `<tuple>` and `<intializer_list>` (this includes the omission of the braced init list constructors for *all* standard containers) Also: the linked example is very ugly code. If you want to use this feature, use a compiler like GCC or Clang that supports this syntax. They are both available for Windows. Hacking around a half-implemented language feature by writing extra code is just stupid.
19,995
I don't recall ever having the problem with the iron before, but it's been a few years since I used it, as I'm just getting back into some projects since my Electronics degree. I bought some solder for a new project (I need a lot) and it's lead-free: ``` 95% Tin 4% Silver 1% Copper ``` Now, I'm not sure how tolerant the values are for melting point but I can say that it does appear to act Eutectic, like the known combination 95.5/4/0.5 ([Indalloy 246](http://www.matweb.com/search/DataSheet.aspx?MatGUID=19662ece2a4a4bb2bbe7aa522f916185)) which has a melting point of 217 degrees Celcius. According to the manufacturer of my Iron (Antex) it has a tip temperature of 370 celcius. I sanded down the tip yesterday with a fine grain metal sanding paper to see if the tip just needed cleaning, however it's now gone "black" instead of the shiny silver it was when I first sanded it. The real question I wonder is where the problem lies, is it that my tip is dead, is my iron too low power or is it just that my iron is dead. I ask because I need to know whether to replace the iron, the tip or a higher power iron. My preference is to stick with the Antex irons, and I prefer "precision" bits like the on in my current iron, so, what are the recommendations?
2011/09/25
[ "https://electronics.stackexchange.com/questions/19995", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/5702/" ]
Your tip is dead since you have now sanded off the special coating. It will of course still get hot, but will oxidize rapidly so that solder won't wick onto it. This will make it very difficult to solder with. You say the tip is supposed to be 370C (700F), but is that temperature controlled or just some open loop guess? 12W sounds very low for a temperature controlled soldering station, and also not enough to heat much beyond a little solder and a wire or two at the same time. For example, my Weller WES51 temperature controller soldering station has a 50W iron. Of course most of the time it's not run at 50W, but that's what the control algorithm can cause it to put out when it senses low tip temperature. Since you just destroyed your tip (and the iron if it has a fixed tip), maybe it's time to get a real one that has temperature control.
A 12w iron is way under-powered for leadfree. You need a temerature-controlled iron, 40-60W minimum
38,380,164
My project demo as link: <http://jsfiddle.net/Lvc0u55v/6741/> I use AngularJS. If a movie is not found, old values should not appear in the following code ``` <form style="margin-bottom: 40px;"> <ul> <li><h2>Title: {{result().name}}</h2></li> <li><h3>Release Date: {{result().release}}</h3></li> <li><h3>Length: {{result().length}}</h3></li> <li><h3>Description: {{result().description}}</h3></li> <li><h3>IMDb Rating: {{result().rating}}</h3></li> </ul> </form> ``` When I write something in text value and click the button, if the movie is not found, the result page is not updated, so the old values are still showing. For example I wrote 'x-men' in text and clicked button, I can see about X-men movie. Then I wrote 'asdfg' and clicked the button, I can see `alert('Movie not found')` but old value is still writing in html page. I tried `ng-if`, `ng-show` , `$state.reload()` etc. but I could not get it to work. Code as snippet: ```js var app = angular.module('myApp', []); app.controller('searchMovieController', function ($scope, $http, resultFactory) { $scope.searchMovieF = function () { if ($scope.searchMovie.length > 0) { $scope.api = 'http://www.omdbapi.com/?t=' + $scope.searchMovie + '&y=&plot=short&r=json'; $http.get($scope.api) .success(function (data) { $("#movie-name").autocomplete({ source: data.Title }); if ((data.Error != "Movie not found!") && ( data.Error != "Must provide more than one character.")) { var details = { name:data.Title, release: data.Released, length: data.Runtime, description: data.Plot, rating: data.imdbRating } resultFactory.set(details) } else { alert("Movie not found !") } }); } else { alert("Please write somethings !") } } }); app.controller('resultMovieController', function ($scope,resultFactory) { $scope.result = function() { return resultFactory.details } }); app.factory('resultFactory', function() { var details = { } var set = function(obj) { var objKeys = Object.keys(obj); for(var i=0; i < objKeys.length; i++) { details[objKeys[i]] = obj[objKeys[i]]; } } return { details: details, set: set } }) ``` ```html <script src="https://code.jquery.com/jquery-3.0.0.min.js"></script> <script src="https://code.jquery.com/ui/1.12.0-rc.2/jquery-ui.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script> <div class="bs-component" ng-controller="searchMovieController"> <form class="well form-search"> <fieldset> <legend>Search Movie</legend> </fieldset> <div> <label class="control-label" for="movie-name">Movie Name : </label> <input type="text" id="movie-name" class="input-small" style="margin-left: 10px;" placeholder="Please write movie name" ng-model="searchMovie"> <a class="btn-sm btn-primary" style="margin-left: 10px;" ng-click="searchMovieF()"> <span class="glyphicon glyphicon-search"> Search</span> </a> </div> </form> <ul> <li> <h2>Title: {{name}}</h2></li> <li><h3>Release Date: {{release}}</h3></li> <li><h3>Length: {{length}}</h3></li> <li><h3>Description: {{description}}</h3></li> <li><h3>IMDb Rating: {{rating}}</h3></li> </ul> </div> <br><br><br><br><br><br> <div id="forResult" class="bs-component" ng-controller="resultMovieController"> <form class="well form-search" id="formResult"> <fieldset> <legend>Result for Search Movie</legend> </fieldset> </form> <ul> <li> <h2>Title: {{result().name}}</h2></li> <li><h3>Release Date: {{result().release}}</h3></li> <li><h3>Length: {{result().length}}</h3></li> <li><h3>Description:{{result().description}}</h3></li> <li><h3>IMDb Rating: {{result().rating}}</h3></li> </ul> <a ui-sref="/search-movie" class="btn-sm btn-primary" style="margin-left:20px;"> <span class="glyphicon glyphicon-circle-arrow-left">Back to Search Page</span> </a> </div> ```
2016/07/14
[ "https://Stackoverflow.com/questions/38380164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5257578/" ]
It would appear that the resultFactory is not being set with new values unless a film is actually found. You'll have to make sure that your resultFactory is being set even when a film does not match the user's search entry. You can simply move your resultFactory.set outside of the `if` statement and set each key to an empty string if the key is not defined in `data`. This can be done quickly per key by using two pipes (`||`) in resultFactory.set ``` resultFactory.set({ name:data.Title || '', release: data.Released || '', length: data.Runtime || '', description: data.Plot || '', rating: data.imdbRating || '' }); ``` [Here's a link to the updated JSFiddle](http://jsfiddle.net/f6uomqja/) including the fix.
You need to add this ``` var details = { name:"", release: "", length: "", description: "", rating: "" } resultFactory.set(details) ``` in the else block add the entire code: ``` var app = angular.module('myApp', []); app.controller('searchMovieController', function ($scope, $http, resultFactory) { $scope.searchMovieF = function () { if ($scope.searchMovie.length > 0) { $scope.api = 'http://www.omdbapi.com/?t=' + $scope.searchMovie + '&y=&plot=short&r=json'; $http.get($scope.api) .success(function (data) { $("#movie-name").autocomplete({ source: data.Title }); if ((data.Error != "Movie not found!") && ( data.Error != "Must provide more than one character.")) { var details = { name:data.Title, release: data.Released, length: data.Runtime, description: data.Plot, rating: data.imdbRating } resultFactory.set(details) } else { alert("Movie not found !") var details = { name:"", release: "", length: "", description: "", rating: "" } resultFactory.set(details) } }); } else { alert("Please write somethings !") } } }); app.controller('resultMovieController', function ($scope,resultFactory) { $scope.result = function() { return resultFactory.details } }); app.factory('resultFactory', function() { var details = { } var set = function(obj) { var objKeys = Object.keys(obj); for(var i=0; i < objKeys.length; i++) { details[objKeys[i]] = obj[objKeys[i]]; } } return { details: details, set: set } }) ```
4,583,801
This is a classical Sangaku problem, also known as old Japanese geometry problems, that I found out just recently. The figure shows a semicircle with a smaller circle and an equilateral triangle inscribed inside it. Note that the semicircle can be *any* general semicircle, but in this case it has a radius of $1$ unit. Also note that one of the vertices of the equilateral triangle lies on the center of the semicircle. I have solved this problem and I'll post my approach as an answer, in order to not clutter up this space. Please share your own approaches as well! [![enter image description here](https://i.stack.imgur.com/48a0g.png)](https://i.stack.imgur.com/48a0g.png)
2022/11/23
[ "https://math.stackexchange.com/questions/4583801", "https://math.stackexchange.com", "https://math.stackexchange.com/users/1092912/" ]
A slightly quicker step (2) skips the quadratic formula: Observe that the hypotenuse shared by your two 30-60-90 triangles has length $\frac 2{\sqrt 3} r$ (since the side lengths are proportional to $1:\sqrt 3:2$), hence $$r + \frac 2{\sqrt 3}r = 1$$ which yields $r=2\sqrt 3-3$.
Here's my approach for the problem: Please note that my answer uses a lemma that can be proven easily, that is, [the radii of two externally or internally tangent circles are collinear](https://youtu.be/0whTkdGBNn0). [![enter image description here](https://i.stack.imgur.com/R518H.png)](https://i.stack.imgur.com/R518H.png) 1.) First, we join the center of the semicircle with that of the circle, and draw a perpendicular from the center of the circle to the tangent points (semicircle and the vertex of the equilateral triangle). Notice that the two triangles that are formed are congruent via the SSS property, therefore we can conclude that the line connecting two centers is an angle sector. This proves that the two triangles are in fact "$30-60-90$" triangle. 2.) Now, using the fact proven above, we can say that the base of those triangles (i.e. the side opposite to the $30^\circ$ angle) is $\frac{r}{\sqrt3}$. Finally, we can finish off the problem: $$(1-r)^2=r^2+(\frac{r}{\sqrt3})^2$$ $$1-2r+r^2=r^2+\frac{r^2}{3}$$ $$r^2+6r-3=0$$ Since this isn't factorable, we can use the quadratic formula: $$r=\frac{-6±\sqrt{48}}{2}$$ Since $\frac{-6-\sqrt{48}}{2}$ would be negative, we must reject that. Therefore: $$r=-3+2\sqrt{3}$$
6,856,491
There is a file named \*.iso, where `*` is any string (dot, numbers, alphabets, spl characters). \*.iso is located at /dm2/www/html/isos/preFCS5.3/ I want to get this filename into $filename. I know it's very simple. How can I do this in Perl?
2011/07/28
[ "https://Stackoverflow.com/questions/6856491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/713200/" ]
Destructor of the Base class will be automatically called by the compiler, when your objet life time ends. you do not need to call it explicitly. ``` TMyObject::TMyObject() : TObject() ``` Does not inherit the constructor. It is called as **[Member initializer list](https://stackoverflow.com/questions/6724626/c-constructor/6724639#6724639)** and it initializes the Base class object with a particular value. When you create the object. ``` TMyObject obj; ``` The constructors will be called in order: ``` constructor of TObject constructor of TMyObject ``` When the object life time ends the destructors will be called in the order: ``` destructor of TMyObject destructr of TObject ``` The compiler will do so for you, do not need to call it explicitly.
If you destroy a `TMyObject` through a reference of type `TMyObject` you don't have to do anything. In case you have a pointer/reference of type `TObject` to a `TMyObject` things will go wrong. *Only* the `TObject` destructor will be called, not the `TMyObject` one: ``` TObject* p = new TMyObject; delete p; // Only the TObject::~TObject is called, not TMyObject::~TMyObject. ``` To have the decision on what destructor to call deferred to runtime, you need to specify the destructor as `virtual` in `TObject`. Whenever you have a class that is intended to be derived from, the destructor should be virtual. Otherwise there is always a risk for resource leaks when the derived class destructor isn't called properly.
6,856,491
There is a file named \*.iso, where `*` is any string (dot, numbers, alphabets, spl characters). \*.iso is located at /dm2/www/html/isos/preFCS5.3/ I want to get this filename into $filename. I know it's very simple. How can I do this in Perl?
2011/07/28
[ "https://Stackoverflow.com/questions/6856491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/713200/" ]
Destructor of the Base class will be automatically called by the compiler, when your objet life time ends. you do not need to call it explicitly. ``` TMyObject::TMyObject() : TObject() ``` Does not inherit the constructor. It is called as **[Member initializer list](https://stackoverflow.com/questions/6724626/c-constructor/6724639#6724639)** and it initializes the Base class object with a particular value. When you create the object. ``` TMyObject obj; ``` The constructors will be called in order: ``` constructor of TObject constructor of TMyObject ``` When the object life time ends the destructors will be called in the order: ``` destructor of TMyObject destructr of TObject ``` The compiler will do so for you, do not need to call it explicitly.
What's causing the confusion to you is that you can specifically mention "which" constructor of the base class you want to use as in the following example. But you can't/ don't need to specify the destructor. ``` TMyObject::TMyObject() : TObject() ``` You could use a different constructor, say `TObject (int i)` by writing ``` TMyObject::TMyObject() : TObject (3) ``` An object can be destructed in only one way but it can be constructed in several ways (by having different constructors). So, in short, you don't need to mention the name of the base class destructor in the derived class destructor. As soon as you destroy the derived object (say, by doing `delete derivedObj`), it will first call the derived class destructor and then base class destructor by itself.
6,856,491
There is a file named \*.iso, where `*` is any string (dot, numbers, alphabets, spl characters). \*.iso is located at /dm2/www/html/isos/preFCS5.3/ I want to get this filename into $filename. I know it's very simple. How can I do this in Perl?
2011/07/28
[ "https://Stackoverflow.com/questions/6856491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/713200/" ]
This can be solved at `TObject`'s level. Its destructor has to be virtual: ``` #include <Classes.hpp> class TObject { __fastcall TObject(); virtual __fastcall ~TObject(); }; ``` This way you can either do: ``` TObject * pobj = new TMyObject(); delete pobj; ``` or ``` TMyObject * pobj = new TMyObject(); delete pobj; ``` Both destructors will be called (`~TMyObject()` first and then `~TObject()`) and you will have no leak.
Destructor of the Base class will be automatically called by the compiler, when your objet life time ends. you do not need to call it explicitly. ``` TMyObject::TMyObject() : TObject() ``` Does not inherit the constructor. It is called as **[Member initializer list](https://stackoverflow.com/questions/6724626/c-constructor/6724639#6724639)** and it initializes the Base class object with a particular value. When you create the object. ``` TMyObject obj; ``` The constructors will be called in order: ``` constructor of TObject constructor of TMyObject ``` When the object life time ends the destructors will be called in the order: ``` destructor of TMyObject destructr of TObject ``` The compiler will do so for you, do not need to call it explicitly.
6,856,491
There is a file named \*.iso, where `*` is any string (dot, numbers, alphabets, spl characters). \*.iso is located at /dm2/www/html/isos/preFCS5.3/ I want to get this filename into $filename. I know it's very simple. How can I do this in Perl?
2011/07/28
[ "https://Stackoverflow.com/questions/6856491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/713200/" ]
This can be solved at `TObject`'s level. Its destructor has to be virtual: ``` #include <Classes.hpp> class TObject { __fastcall TObject(); virtual __fastcall ~TObject(); }; ``` This way you can either do: ``` TObject * pobj = new TMyObject(); delete pobj; ``` or ``` TMyObject * pobj = new TMyObject(); delete pobj; ``` Both destructors will be called (`~TMyObject()` first and then `~TObject()`) and you will have no leak.
If you destroy a `TMyObject` through a reference of type `TMyObject` you don't have to do anything. In case you have a pointer/reference of type `TObject` to a `TMyObject` things will go wrong. *Only* the `TObject` destructor will be called, not the `TMyObject` one: ``` TObject* p = new TMyObject; delete p; // Only the TObject::~TObject is called, not TMyObject::~TMyObject. ``` To have the decision on what destructor to call deferred to runtime, you need to specify the destructor as `virtual` in `TObject`. Whenever you have a class that is intended to be derived from, the destructor should be virtual. Otherwise there is always a risk for resource leaks when the derived class destructor isn't called properly.
6,856,491
There is a file named \*.iso, where `*` is any string (dot, numbers, alphabets, spl characters). \*.iso is located at /dm2/www/html/isos/preFCS5.3/ I want to get this filename into $filename. I know it's very simple. How can I do this in Perl?
2011/07/28
[ "https://Stackoverflow.com/questions/6856491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/713200/" ]
This can be solved at `TObject`'s level. Its destructor has to be virtual: ``` #include <Classes.hpp> class TObject { __fastcall TObject(); virtual __fastcall ~TObject(); }; ``` This way you can either do: ``` TObject * pobj = new TMyObject(); delete pobj; ``` or ``` TMyObject * pobj = new TMyObject(); delete pobj; ``` Both destructors will be called (`~TMyObject()` first and then `~TObject()`) and you will have no leak.
What's causing the confusion to you is that you can specifically mention "which" constructor of the base class you want to use as in the following example. But you can't/ don't need to specify the destructor. ``` TMyObject::TMyObject() : TObject() ``` You could use a different constructor, say `TObject (int i)` by writing ``` TMyObject::TMyObject() : TObject (3) ``` An object can be destructed in only one way but it can be constructed in several ways (by having different constructors). So, in short, you don't need to mention the name of the base class destructor in the derived class destructor. As soon as you destroy the derived object (say, by doing `delete derivedObj`), it will first call the derived class destructor and then base class destructor by itself.
5,321,883
I am very new to spring security . I picked up [this](https://rads.stackoverflow.com/amzn/click/com/1847199747) book and trying to execute the code . While I do this I am getting ``` org.springframework.beans.NotReadablePropertyException: Invalid property 'principal.username' of bean class [org.springframework.security.authentication.AnonymousAuthenticationToken]: Bean property 'principal.username' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? ``` My spring-security xml config : ``` <http auto-config="true" use-expressions="true"> <intercept-url pattern="/login.do" access="permitAll"/> <intercept-url pattern="/*" access="hasRole('ROLE_USER')"/> <form-login login-page="/login.do"/> </http> <authentication-manager alias="authenticationManager"> <authentication-provider> <user-service id="userService"> <user authorities="ROLE_USER" name="guest" password="guest"/> </user-service> </authentication-provider> <!-- Ch 3 Change Password Service --> <!-- <authentication-provider user-service-ref="userService"/> --> </authentication-manager> ``` Am I missing something ? Let me know if you need any additional information.
2011/03/16
[ "https://Stackoverflow.com/questions/5321883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571718/" ]
What the error message seems to be indicating is that something is trying to access a non-existent property on an `AnonymousAuthenticationToken` ; i.e. the authentication token that spring security uses when the session is not logged in. I suspect that the problem is actually occurring either in your servlet code, or in a JSP that is trying to access the name of the current user via a spring security tag. The complete stacktrace for the error might give us more clues. At least it should tell us where the exception is coming from. (For what it is worth, an `AnonymousAuthenticationToken` does have a `principal` property, but that property is not normally an object that has a `username` property. Indeed, it is often just a String.)
I am reading/following the "Spring Security 3" book. Just add the following lines to the header.jsp The problem is that principal.username does not exists if you are not logged in. ``` <div class="username"> Welcome, <sec:authorize access="isAuthenticated()"> <strong><sec:authentication property="principal.username"/></strong> </sec:authorize> </div> ```
5,321,883
I am very new to spring security . I picked up [this](https://rads.stackoverflow.com/amzn/click/com/1847199747) book and trying to execute the code . While I do this I am getting ``` org.springframework.beans.NotReadablePropertyException: Invalid property 'principal.username' of bean class [org.springframework.security.authentication.AnonymousAuthenticationToken]: Bean property 'principal.username' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? ``` My spring-security xml config : ``` <http auto-config="true" use-expressions="true"> <intercept-url pattern="/login.do" access="permitAll"/> <intercept-url pattern="/*" access="hasRole('ROLE_USER')"/> <form-login login-page="/login.do"/> </http> <authentication-manager alias="authenticationManager"> <authentication-provider> <user-service id="userService"> <user authorities="ROLE_USER" name="guest" password="guest"/> </user-service> </authentication-provider> <!-- Ch 3 Change Password Service --> <!-- <authentication-provider user-service-ref="userService"/> --> </authentication-manager> ``` Am I missing something ? Let me know if you need any additional information.
2011/03/16
[ "https://Stackoverflow.com/questions/5321883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571718/" ]
What the error message seems to be indicating is that something is trying to access a non-existent property on an `AnonymousAuthenticationToken` ; i.e. the authentication token that spring security uses when the session is not logged in. I suspect that the problem is actually occurring either in your servlet code, or in a JSP that is trying to access the name of the current user via a spring security tag. The complete stacktrace for the error might give us more clues. At least it should tell us where the exception is coming from. (For what it is worth, an `AnonymousAuthenticationToken` does have a `principal` property, but that property is not normally an object that has a `username` property. Indeed, it is often just a String.)
Prerequisites as follows: 1. Add spring security taglib in jsp page you want to show username, ``` <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> ``` 2. Add spring security jars, use ``` <sec:authentication property="principal" /> ``` in jsp where you want to show the username Following will show up: 1. **anonymousUser**, means user is not logged in 2. **string representation of object**, means user is logged in But do not print string representation of object on page. Here's a pseudo code: ``` if principal==anonymousUser show login button else (do not use principal here too) show username with logout button ```
5,321,883
I am very new to spring security . I picked up [this](https://rads.stackoverflow.com/amzn/click/com/1847199747) book and trying to execute the code . While I do this I am getting ``` org.springframework.beans.NotReadablePropertyException: Invalid property 'principal.username' of bean class [org.springframework.security.authentication.AnonymousAuthenticationToken]: Bean property 'principal.username' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? ``` My spring-security xml config : ``` <http auto-config="true" use-expressions="true"> <intercept-url pattern="/login.do" access="permitAll"/> <intercept-url pattern="/*" access="hasRole('ROLE_USER')"/> <form-login login-page="/login.do"/> </http> <authentication-manager alias="authenticationManager"> <authentication-provider> <user-service id="userService"> <user authorities="ROLE_USER" name="guest" password="guest"/> </user-service> </authentication-provider> <!-- Ch 3 Change Password Service --> <!-- <authentication-provider user-service-ref="userService"/> --> </authentication-manager> ``` Am I missing something ? Let me know if you need any additional information.
2011/03/16
[ "https://Stackoverflow.com/questions/5321883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571718/" ]
I am reading/following the "Spring Security 3" book. Just add the following lines to the header.jsp The problem is that principal.username does not exists if you are not logged in. ``` <div class="username"> Welcome, <sec:authorize access="isAuthenticated()"> <strong><sec:authentication property="principal.username"/></strong> </sec:authorize> </div> ```
Prerequisites as follows: 1. Add spring security taglib in jsp page you want to show username, ``` <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> ``` 2. Add spring security jars, use ``` <sec:authentication property="principal" /> ``` in jsp where you want to show the username Following will show up: 1. **anonymousUser**, means user is not logged in 2. **string representation of object**, means user is logged in But do not print string representation of object on page. Here's a pseudo code: ``` if principal==anonymousUser show login button else (do not use principal here too) show username with logout button ```
67,863
The skeleton description says that while it cannot speak it, it can understand the languages it knew in life. Can it not speak because of its undeath or could it learn to speak a language?
2015/08/31
[ "https://rpg.stackexchange.com/questions/67863", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/21781/" ]
If it was physically capable of speaking, it would be able to speak the languages it knew in life. It still retains its knowledge of them, so *knowing* how to speak a language is not the problem. The problem is that a skeleton lacks lips, a tongue, vocal cords, a voicebox, and lungs. Speaking is simply impossible. The Monster Manual entry on skeletons says: > > They can't read, speak, emote, or communicate in any way except to nod, shake their heads, or point. > > > From this, it seems clear that it is meant to be impossible for skeletons to communicate in **any** way other than the given nodding, shaking, and pointing.
Isn't this why we have Speak with Dead spells? The skeleton has no way of making vocalizations so cannot speak audibly but can understand language due to the magic that animates it.
67,863
The skeleton description says that while it cannot speak it, it can understand the languages it knew in life. Can it not speak because of its undeath or could it learn to speak a language?
2015/08/31
[ "https://rpg.stackexchange.com/questions/67863", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/21781/" ]
If it was physically capable of speaking, it would be able to speak the languages it knew in life. It still retains its knowledge of them, so *knowing* how to speak a language is not the problem. The problem is that a skeleton lacks lips, a tongue, vocal cords, a voicebox, and lungs. Speaking is simply impossible. The Monster Manual entry on skeletons says: > > They can't read, speak, emote, or communicate in any way except to nod, shake their heads, or point. > > > From this, it seems clear that it is meant to be impossible for skeletons to communicate in **any** way other than the given nodding, shaking, and pointing.
By RAW default, no. =================== As explained by others it has no basic, default, means of expressing language. It's not about learning the language, it's the capability of the spell/energy powering the skeleton(s). Undeath is not in itself an impediment to speech (see: Liches). Therefore you need to extrapolate a bit. The RAW description quoted above seems to imply the power source provides bare-minimum world interaction capabilities. And does not extend to advanced capabilities like mimicking a voice (disembodied or otherwise). But, the "talking skull/skeleton" trope is incredibly common. So... By customization, yes. (Possibly with the aid of a magic item.) =============================================================== It is your game, after all. And creativity is a core value of the gaming experience. A skeleton is already magically animated, so if you wanted a **specific skeleton** to have the ability to speak, there are several creative ways you could explain the phenomenon. * A magic item equipped by its creator, or even left over from its previous life. (An enchanted ring or amulet?) * A slightly more powerful skeleton who gained the ability to speak over time via wild magic or the like. * A skeleton created with extra riders on the creation spell by its creator. So maybe it was imbued with a secondary spell to allow a disembodied voice. You could have all skeletons speak of that's how you want to run your world, but that'd be your own custom flavoring. A speaking skeleton, otherwise, would be **special for some reason**.
67,863
The skeleton description says that while it cannot speak it, it can understand the languages it knew in life. Can it not speak because of its undeath or could it learn to speak a language?
2015/08/31
[ "https://rpg.stackexchange.com/questions/67863", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/21781/" ]
If it was physically capable of speaking, it would be able to speak the languages it knew in life. It still retains its knowledge of them, so *knowing* how to speak a language is not the problem. The problem is that a skeleton lacks lips, a tongue, vocal cords, a voicebox, and lungs. Speaking is simply impossible. The Monster Manual entry on skeletons says: > > They can't read, speak, emote, or communicate in any way except to nod, shake their heads, or point. > > > From this, it seems clear that it is meant to be impossible for skeletons to communicate in **any** way other than the given nodding, shaking, and pointing.
<https://www.dandwiki.com/wiki/Skeleton_(5e_Race)> said > > You've managed to control the energies that sustain you to allow you speak. You can speak, read and write Common, as well as the language of your creator. A Giant Skeleton may speak Giant, a God Touched may know Celestial, a Magic Fluke may randomly grant you a language and a Raised Minion may know their wizard master's draconic. > > > so im guessing you can but i think it's for players thats race is skeleton
67,863
The skeleton description says that while it cannot speak it, it can understand the languages it knew in life. Can it not speak because of its undeath or could it learn to speak a language?
2015/08/31
[ "https://rpg.stackexchange.com/questions/67863", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/21781/" ]
If it was physically capable of speaking, it would be able to speak the languages it knew in life. It still retains its knowledge of them, so *knowing* how to speak a language is not the problem. The problem is that a skeleton lacks lips, a tongue, vocal cords, a voicebox, and lungs. Speaking is simply impossible. The Monster Manual entry on skeletons says: > > They can't read, speak, emote, or communicate in any way except to nod, shake their heads, or point. > > > From this, it seems clear that it is meant to be impossible for skeletons to communicate in **any** way other than the given nodding, shaking, and pointing.
It is true, on pg 272 of the 5e Monster Manual, it states: > > They can't read, speak, emote, or communicate in any way except to nod, shake their heads, or point. > > > ... and D&D Beyond - [Skeleton entry](https://www.dndbeyond.com/monsters/skeleton) states ... > > Understands all languages it knew in life but can't speak > > > ... but both of these interpretations seem to be relatively 'new' 5e expansions to d&d skeleton lore. Wrt Habitual Behaviors in the 5e MM, if "skeletons of nobles might continue in an eternally unfinished dance" && "can load and fire a catapult or trebuchet". Also, wrt D&D Beyond, it appears to be poorly worded. If taken literally, that it simply cannot speak; then it would be able to use sign language, portions of thieves cant, or write & still communicate. I think all of the older versions are more consistent wrt skeletons in this respect; in that the creator can command them via magic (and it ignores the medium of the command.) Therefore we need to break up your question: 1. Can it not speak because of its undeath? If you look at all the lore in total, the answer here would be the skeleton cannot "communicate", speaking or otherwise. If you look at 5e literally, then the two sources are possibly contradictory & you'll have to subjectively decide for your world/campaign. 2. Could it learn to speak a language? The simple answer is no... however, again looking at all the lore, should a different necromancer, demon, etc gain control of the skeleton; the method of control would give the ability to command irrespective of language. Relatedly, an item of consideration is whether or not skeletons are deaf, & how their "vison" works.?. In my campaigns, skeletons are "unintelligent", and are deaf; with their "vision" being more animalistic/primitive in nature (they can't read, or understand complex items <missle weapons & doors included>)... This isn't to say a specific necromancer couldn't craft a "unique breed" of skeletons that have different features, including higher intelligence; but just that the "average" skeleton does not.
67,863
The skeleton description says that while it cannot speak it, it can understand the languages it knew in life. Can it not speak because of its undeath or could it learn to speak a language?
2015/08/31
[ "https://rpg.stackexchange.com/questions/67863", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/21781/" ]
By RAW default, no. =================== As explained by others it has no basic, default, means of expressing language. It's not about learning the language, it's the capability of the spell/energy powering the skeleton(s). Undeath is not in itself an impediment to speech (see: Liches). Therefore you need to extrapolate a bit. The RAW description quoted above seems to imply the power source provides bare-minimum world interaction capabilities. And does not extend to advanced capabilities like mimicking a voice (disembodied or otherwise). But, the "talking skull/skeleton" trope is incredibly common. So... By customization, yes. (Possibly with the aid of a magic item.) =============================================================== It is your game, after all. And creativity is a core value of the gaming experience. A skeleton is already magically animated, so if you wanted a **specific skeleton** to have the ability to speak, there are several creative ways you could explain the phenomenon. * A magic item equipped by its creator, or even left over from its previous life. (An enchanted ring or amulet?) * A slightly more powerful skeleton who gained the ability to speak over time via wild magic or the like. * A skeleton created with extra riders on the creation spell by its creator. So maybe it was imbued with a secondary spell to allow a disembodied voice. You could have all skeletons speak of that's how you want to run your world, but that'd be your own custom flavoring. A speaking skeleton, otherwise, would be **special for some reason**.
Isn't this why we have Speak with Dead spells? The skeleton has no way of making vocalizations so cannot speak audibly but can understand language due to the magic that animates it.
67,863
The skeleton description says that while it cannot speak it, it can understand the languages it knew in life. Can it not speak because of its undeath or could it learn to speak a language?
2015/08/31
[ "https://rpg.stackexchange.com/questions/67863", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/21781/" ]
It is true, on pg 272 of the 5e Monster Manual, it states: > > They can't read, speak, emote, or communicate in any way except to nod, shake their heads, or point. > > > ... and D&D Beyond - [Skeleton entry](https://www.dndbeyond.com/monsters/skeleton) states ... > > Understands all languages it knew in life but can't speak > > > ... but both of these interpretations seem to be relatively 'new' 5e expansions to d&d skeleton lore. Wrt Habitual Behaviors in the 5e MM, if "skeletons of nobles might continue in an eternally unfinished dance" && "can load and fire a catapult or trebuchet". Also, wrt D&D Beyond, it appears to be poorly worded. If taken literally, that it simply cannot speak; then it would be able to use sign language, portions of thieves cant, or write & still communicate. I think all of the older versions are more consistent wrt skeletons in this respect; in that the creator can command them via magic (and it ignores the medium of the command.) Therefore we need to break up your question: 1. Can it not speak because of its undeath? If you look at all the lore in total, the answer here would be the skeleton cannot "communicate", speaking or otherwise. If you look at 5e literally, then the two sources are possibly contradictory & you'll have to subjectively decide for your world/campaign. 2. Could it learn to speak a language? The simple answer is no... however, again looking at all the lore, should a different necromancer, demon, etc gain control of the skeleton; the method of control would give the ability to command irrespective of language. Relatedly, an item of consideration is whether or not skeletons are deaf, & how their "vison" works.?. In my campaigns, skeletons are "unintelligent", and are deaf; with their "vision" being more animalistic/primitive in nature (they can't read, or understand complex items <missle weapons & doors included>)... This isn't to say a specific necromancer couldn't craft a "unique breed" of skeletons that have different features, including higher intelligence; but just that the "average" skeleton does not.
Isn't this why we have Speak with Dead spells? The skeleton has no way of making vocalizations so cannot speak audibly but can understand language due to the magic that animates it.
67,863
The skeleton description says that while it cannot speak it, it can understand the languages it knew in life. Can it not speak because of its undeath or could it learn to speak a language?
2015/08/31
[ "https://rpg.stackexchange.com/questions/67863", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/21781/" ]
By RAW default, no. =================== As explained by others it has no basic, default, means of expressing language. It's not about learning the language, it's the capability of the spell/energy powering the skeleton(s). Undeath is not in itself an impediment to speech (see: Liches). Therefore you need to extrapolate a bit. The RAW description quoted above seems to imply the power source provides bare-minimum world interaction capabilities. And does not extend to advanced capabilities like mimicking a voice (disembodied or otherwise). But, the "talking skull/skeleton" trope is incredibly common. So... By customization, yes. (Possibly with the aid of a magic item.) =============================================================== It is your game, after all. And creativity is a core value of the gaming experience. A skeleton is already magically animated, so if you wanted a **specific skeleton** to have the ability to speak, there are several creative ways you could explain the phenomenon. * A magic item equipped by its creator, or even left over from its previous life. (An enchanted ring or amulet?) * A slightly more powerful skeleton who gained the ability to speak over time via wild magic or the like. * A skeleton created with extra riders on the creation spell by its creator. So maybe it was imbued with a secondary spell to allow a disembodied voice. You could have all skeletons speak of that's how you want to run your world, but that'd be your own custom flavoring. A speaking skeleton, otherwise, would be **special for some reason**.
<https://www.dandwiki.com/wiki/Skeleton_(5e_Race)> said > > You've managed to control the energies that sustain you to allow you speak. You can speak, read and write Common, as well as the language of your creator. A Giant Skeleton may speak Giant, a God Touched may know Celestial, a Magic Fluke may randomly grant you a language and a Raised Minion may know their wizard master's draconic. > > > so im guessing you can but i think it's for players thats race is skeleton
67,863
The skeleton description says that while it cannot speak it, it can understand the languages it knew in life. Can it not speak because of its undeath or could it learn to speak a language?
2015/08/31
[ "https://rpg.stackexchange.com/questions/67863", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/21781/" ]
By RAW default, no. =================== As explained by others it has no basic, default, means of expressing language. It's not about learning the language, it's the capability of the spell/energy powering the skeleton(s). Undeath is not in itself an impediment to speech (see: Liches). Therefore you need to extrapolate a bit. The RAW description quoted above seems to imply the power source provides bare-minimum world interaction capabilities. And does not extend to advanced capabilities like mimicking a voice (disembodied or otherwise). But, the "talking skull/skeleton" trope is incredibly common. So... By customization, yes. (Possibly with the aid of a magic item.) =============================================================== It is your game, after all. And creativity is a core value of the gaming experience. A skeleton is already magically animated, so if you wanted a **specific skeleton** to have the ability to speak, there are several creative ways you could explain the phenomenon. * A magic item equipped by its creator, or even left over from its previous life. (An enchanted ring or amulet?) * A slightly more powerful skeleton who gained the ability to speak over time via wild magic or the like. * A skeleton created with extra riders on the creation spell by its creator. So maybe it was imbued with a secondary spell to allow a disembodied voice. You could have all skeletons speak of that's how you want to run your world, but that'd be your own custom flavoring. A speaking skeleton, otherwise, would be **special for some reason**.
It is true, on pg 272 of the 5e Monster Manual, it states: > > They can't read, speak, emote, or communicate in any way except to nod, shake their heads, or point. > > > ... and D&D Beyond - [Skeleton entry](https://www.dndbeyond.com/monsters/skeleton) states ... > > Understands all languages it knew in life but can't speak > > > ... but both of these interpretations seem to be relatively 'new' 5e expansions to d&d skeleton lore. Wrt Habitual Behaviors in the 5e MM, if "skeletons of nobles might continue in an eternally unfinished dance" && "can load and fire a catapult or trebuchet". Also, wrt D&D Beyond, it appears to be poorly worded. If taken literally, that it simply cannot speak; then it would be able to use sign language, portions of thieves cant, or write & still communicate. I think all of the older versions are more consistent wrt skeletons in this respect; in that the creator can command them via magic (and it ignores the medium of the command.) Therefore we need to break up your question: 1. Can it not speak because of its undeath? If you look at all the lore in total, the answer here would be the skeleton cannot "communicate", speaking or otherwise. If you look at 5e literally, then the two sources are possibly contradictory & you'll have to subjectively decide for your world/campaign. 2. Could it learn to speak a language? The simple answer is no... however, again looking at all the lore, should a different necromancer, demon, etc gain control of the skeleton; the method of control would give the ability to command irrespective of language. Relatedly, an item of consideration is whether or not skeletons are deaf, & how their "vison" works.?. In my campaigns, skeletons are "unintelligent", and are deaf; with their "vision" being more animalistic/primitive in nature (they can't read, or understand complex items <missle weapons & doors included>)... This isn't to say a specific necromancer couldn't craft a "unique breed" of skeletons that have different features, including higher intelligence; but just that the "average" skeleton does not.
67,863
The skeleton description says that while it cannot speak it, it can understand the languages it knew in life. Can it not speak because of its undeath or could it learn to speak a language?
2015/08/31
[ "https://rpg.stackexchange.com/questions/67863", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/21781/" ]
It is true, on pg 272 of the 5e Monster Manual, it states: > > They can't read, speak, emote, or communicate in any way except to nod, shake their heads, or point. > > > ... and D&D Beyond - [Skeleton entry](https://www.dndbeyond.com/monsters/skeleton) states ... > > Understands all languages it knew in life but can't speak > > > ... but both of these interpretations seem to be relatively 'new' 5e expansions to d&d skeleton lore. Wrt Habitual Behaviors in the 5e MM, if "skeletons of nobles might continue in an eternally unfinished dance" && "can load and fire a catapult or trebuchet". Also, wrt D&D Beyond, it appears to be poorly worded. If taken literally, that it simply cannot speak; then it would be able to use sign language, portions of thieves cant, or write & still communicate. I think all of the older versions are more consistent wrt skeletons in this respect; in that the creator can command them via magic (and it ignores the medium of the command.) Therefore we need to break up your question: 1. Can it not speak because of its undeath? If you look at all the lore in total, the answer here would be the skeleton cannot "communicate", speaking or otherwise. If you look at 5e literally, then the two sources are possibly contradictory & you'll have to subjectively decide for your world/campaign. 2. Could it learn to speak a language? The simple answer is no... however, again looking at all the lore, should a different necromancer, demon, etc gain control of the skeleton; the method of control would give the ability to command irrespective of language. Relatedly, an item of consideration is whether or not skeletons are deaf, & how their "vison" works.?. In my campaigns, skeletons are "unintelligent", and are deaf; with their "vision" being more animalistic/primitive in nature (they can't read, or understand complex items <missle weapons & doors included>)... This isn't to say a specific necromancer couldn't craft a "unique breed" of skeletons that have different features, including higher intelligence; but just that the "average" skeleton does not.
<https://www.dandwiki.com/wiki/Skeleton_(5e_Race)> said > > You've managed to control the energies that sustain you to allow you speak. You can speak, read and write Common, as well as the language of your creator. A Giant Skeleton may speak Giant, a God Touched may know Celestial, a Magic Fluke may randomly grant you a language and a Raised Minion may know their wizard master's draconic. > > > so im guessing you can but i think it's for players thats race is skeleton
30,072,278
I am having trouble with reading in a text file full of names (some are repeated) and inputting the first and last names together on 1 line. The program works and deletes repeated names but outputs them in alphabetical order with first and last names being treated as 2 different names. Am I outputting the names wrong with: ``` string name; while (partyList >> name) { NamesList.insert(name); } cout << "Here is the party list without repetion: " << endl; while (!NamesList.empty()) { cout << ' ' << *NamesList.begin() << endl; NamesList.erase(NamesList.begin()); } ``` ? The text file is PartyList.txt and it contains: ``` Daniel Walrus Amy Giester Jim Carry Gregg Lunch Irony Max Jim Carry Daniel Walrus Gregg Lunch ``` Currently my output is: ``` Amy Carrey Daniel Giester Gregg Irony Jim Lunch Max Walrus ``` Here is my code (this is part of a larger assignment which is completed besides making the first and last names go together): ``` #include <iostream> #include <fstream> #include <string> #include <set> using namespace std; void PartyList(); int main() { PartyList(); system("PAUSE"); return 0; } void PartyList() { fstream partyList; partyList.open("PartyList.txt", fstream::in); if (!partyList) { cout << "Couldn't open file!" << endl; } set<string> NamesList; string name; while (partyList >> name) { NamesList.insert(name); } cout << "Here is the party list without repetion: " << endl; while(!NamesList.empty()) { cout << ' ' << *NamesList.begin() << endl; NamesList.erase(NamesList.begin()); } //cout << name << endl; cout << endl; } ```
2015/05/06
[ "https://Stackoverflow.com/questions/30072278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4110090/" ]
The `>>` operator in `partyList >> name` only reads from `partyList` until whitespace, which includes spaces, so `name` gets the values `"Daniel"`, `"Walrus"`, `"Amy"`, etc. on iteration. If you want to read one line at a time, use ``` while (std::getline(partyList, name)) ``` which gets you `"Daniel Walrus"` etc.
``` while (partyList >> name) ``` The `>>` operator is looking here for a first blank character. That's why your names are split this way.
47,278,674
I recently started study opencv. I only have a bachelor's degree on engineering. I am having a hard time of understanding these 2 morphological transformation: Black Hat, Top Hat. the official documents is [here](https://docs.opencv.org/master/d9/d61/tutorial_py_morphological_ops.html) Can some one give some advice of what is the intuition of these operation and what is it for?
2017/11/14
[ "https://Stackoverflow.com/questions/47278674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6898439/" ]
Hopefully you understand *”morphological opening”*. If so, the (white) Top Hat tells you the pixels that would be removed by *”opening”*. Likewise, the Black Hat tells you the pixels that would be added by *”morphological closing”*.
See the image for explanation. Simple algebra will help here. > > Top hat > > > top hat = image - opening = image - (image - false +ves) = false +ves > > Black hat > > > black hat = image - closing = image - (image - false -ves) = false -ves [Explanation](https://i.stack.imgur.com/3Y15r.jpg)

No dataset card yet

New: Create and edit this dataset card directly on the website!

Contribute a Dataset Card
Downloads last month
2
Add dataset card