Scipy.optimize Inequality Constraint – Which side of the inequality is considered?

Refer to https://docs.scipy.org/doc/scipy-0.18.1/reference/tutorial/optimize.html and scroll down to Constrained minimization of multivariate scalar functions (minimize), you can find that This algorithm allows to deal with constrained minimization problems of the form: where the inequalities are of the form C_j(x) >= 0. So when you define the constraint as def constraint1(x): return x[0]+x[1]+x[2]+x[3]-1 and specify the type … Read more

How to hide a JFrame in system tray of taskbar

import java.awt.*; import java.awt.event.*; import javax.swing.JFrame; import javax.swing.UIManager; /** * * @author Mohammad Faisal * ermohammadfaisal.blogspot.com * facebook.com/m.faisal6621 * */ public class HideToSystemTray extends JFrame{ TrayIcon trayIcon; SystemTray tray; HideToSystemTray(){ super(“SystemTray test”); System.out.println(“creating instance”); try{ System.out.println(“setting look and feel”); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }catch(Exception e){ System.out.println(“Unable to set LookAndFeel”); } if(SystemTray.isSupported()){ System.out.println(“system tray supported”); tray=SystemTray.getSystemTray(); Image image=Toolkit.getDefaultToolkit().getImage(“/media/faisal/DukeImg/Duke256.png”); ActionListener … Read more

Painted content invisible while resizing in Java

For reference, here is the same program using Swing. Because JPanel is double buffered, it doesn’t flicker as the mouse is released after resizing. import java.awt.*; import java.awt.event.*; import java.util.Random; import javax.swing.*; public class SwingPaint { public static void main(String[] args) { JFrame frame = new JFrame(); frame.add(new CirclePanel()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } private static … Read more

How do I put a Java app in the system tray?

As of Java 6, this is supported in the SystemTray and TrayIcon classes. SystemTray has a pretty extensive example in its Javadocs: TrayIcon trayIcon = null; if (SystemTray.isSupported()) { // get the SystemTray instance SystemTray tray = SystemTray.getSystemTray(); // load an image Image image = Toolkit.getDefaultToolkit().getImage(“your_image/path_here.gif”); // create a action listener to listen for default … Read more

Minimizing all open windows in C#

PInvoke.net is your friend 🙂 using System; using System.Runtime.InteropServices; namespace ConsoleApplication1 { class Program { [DllImport(“user32.dll”, EntryPoint = “FindWindow”, SetLastError = true)] static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport(“user32.dll”, EntryPoint = “SendMessage”, SetLastError = true)] static extern IntPtr SendMessage(IntPtr hWnd, Int32 Msg, IntPtr wParam, IntPtr lParam); const int WM_COMMAND = 0x111; const int MIN_ALL … Read more