All objects in Java are references and you can use them like pointers. abstract class Animal {... } class Lion extends Animal {... } class Tiger extends Animal { public Tiger() {...} public void growl(){...} } Tiger first = null; Tiger second = new Tiger(); Tiger third; Dereferencing a null: first.growl(); // ERROR, first is null. third.growl(); // ERROR, third has … [Read more...]
TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
Perhaps the error message is somewhat misleading, but the gist is that X_train is a list, not a numpy array. You cannot use array indexing on it. Make it an array first: out_images = np.array(X_train)[indices.astype(int)] I get this error whenever I use np.concatenate the wrong way: >>> a = np.eye(2) >>> np.concatenate(a, a) Traceback (most recent call last): File "", line … [Read more...]
Find (and kill) process locking port 3000 on Mac
You can try netstat netstat -vanp tcp | grep 3000 For macOS El Capitan and newer (or if your netstat doesn't support -p), use lsof lsof -i tcp:3000 For Centos 7 use: netstat -vanp --tcp | grep 3000 Find: sudo lsof -i :3000 Kill: kill -9 … [Read more...]
JavaFX – Exception in Application start method? [duplicate]
A simple fix: copy your fxml file/s into the package in which your main method is currently located. Save & re-run. … [Read more...]
How do I force git pull to overwrite everything on every pull?
Really the ideal way to do this is to not use pull at all, but instead fetch and reset: git fetch origin master git reset --hard FETCH_HEAD git clean -df (Altering master to whatever branch you want to be following.) pull is designed around merging changes together in some way, whereas reset is designed around simply making your local copy match a specific commit. You may want … [Read more...]
MySQL query String contains
Quite simple actually: mysql_query(" SELECT * FROM `table` WHERE `column` LIKE '%{$needle}%' "); The % is a wildcard for any characters set (none, one or many). Do note that this can get slow on very large datasets so if your database grows you'll need to use fulltext indices. Use: SELECT * FROM `table` WHERE INSTR(`column`, '{$needle}') > 0 Reference: INSTR … [Read more...]
What does “SyntaxError: Missing parentheses in call to ‘print'” mean in Python?
This error message means that you are attempting to use Python 3 to follow an example or run a program that uses the Python 2 print statement: print "Hello, World!" The statement above does not work in Python 3. In Python 3 you need to add parentheses around the value to be printed: print("Hello, World!") “SyntaxError: Missing parentheses in call to 'print'” is a new error … [Read more...]
Changing image size in Markdown
You could just use some HTML in your Markdown: Or via style attribute (not supported by GitHub) Or you could use a custom CSS file as described in this answer on Markdown and image alignment ![drawing](drawing.jpg) CSS in another file: img[alt=drawing] { width: 200px; } With certain Markdown implementations (including Mou and Marked 2 (only macOS)) you can append … [Read more...]
The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path [duplicate]
Add a runtime first and select project properties. Then check the server name from the 'Runtimes' tab as shown in the image. Include servlet-api-3.1.jar in your dependencies. Maven javax.servlet javax.servlet-api 3.1.0 provided Gradle configurations { provided } sourceSets { main { compileClasspath += configurations.provided } } dependencies { … [Read more...]
Django TemplateDoesNotExist?
First solution: These settings TEMPLATE_DIRS = ( os.path.join(SETTINGS_PATH, 'templates'), ) mean that Django will look at the templates from templates/ directory under your project. Assuming your Django project is located at /usr/lib/python2.5/site-packages/projectname/ then with your settings django will look for the templates under … [Read more...]