April 25, 2024
  • April 25, 2024

Articles Posted by Johnny Thunder

PSQL in Java Connection and Select Query Example

by on November 25, 2018 0
import java.io.IOException; import java.net.URISyntaxException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class PSQLConn { public static void main(String[] args) throws InterruptedException, IOException, URISyntaxException, SQLException { String database = "MyDatabase"; String dbUser = "myUser"; String dbPass = "mySecurePass"; String dbPort = "5432"; Connection c = null; try { Class.forName("org.postgresql.Driver"); c = DriverManager.getConnection("jdbc:postgresql://localhost:" [...] Read More

Java Permutations Method (Handles Large Numbers)

by on November 25, 2018 0
Permutations are unique orderings for a set.  Our favorite flavor of permutations is the nPr formula which calculates the number of subsets that can be selected from the total number of items (order matters!) note: with nPr the order of the subset matters in the subset (unline nCr where order doesn't matter) import java.math.BigInteger; public [...] Read More

Get One Frame of Video With AVConv/ FFMPEG

by on November 24, 2018 0
Get one frame from video at 2 sec ffmpeg -ss 2 -i vid.mp4 -qscale:v 4 -frames:v 1 vid.jpg avconv -ss 2 -i vid.mp4 -qscale:v 4 -frames:v 1 vid.jpg Wondering the difference between ffmpeg and avconv? They have about the same flags and parameters and much of the same codebase, so use whichever one is installed [...] Read More

Copy Contents of PostgreSQL Table to CSV File w/ Headers

by on November 8, 2018 0
Whether migrating to another server or dumping data to an Excel friendly server, PostgreSQL's cover has got you covered.  This turorial will cover how to save to csv format COPY "myTableName" TO '/tmp/myCsvFile.csv' DELIMITER ',' CSV HEADER; It's that easy.  Run this in psql client shell in your Linux server. If you see the following [...] Read More

How to Show an Alert in iOS

by on November 6, 2018 0
var alert = UIAlertController(title: "Hello!", message: "Thanks for stopping by!!!", preferredStyle: UIAlertController.Style.alert) let alertOKAction=UIAlertAction(title:"OK", style: UIAlertAction.Style.default,handler: { action in print("OK Button Pressed") }) let alertCancelAction=UIAlertAction(title:"Cancel", style: UIAlertAction.Style.destructive,handler: { action in print("Cancel Button Pressed") }) alert.addAction(alertOKAction) alert.addAction(alertCancelAction) self.present(alert, animated: true, completion: nil) Read More

Updating the Solr Schema

by on October 28, 2018 0
We'll often need a custom schema for our solr instances.  This article show how to do this. It's always a good idea to back up the current working schema.xml before making any changes sudo cp /etc/solr/conf/schema.xml /etc/solr/conf/schemaOrig.xml Let's now edit the schema file: sudo nano /etc/solr/conf/schema.xml I usually start with the fields and the dynamicfields [...] Read More

Solr Tomcat Add Password for Admin Portal

by on October 28, 2018 0
Edit the tomcat users and add the following line sudo nano /etc/tomcat7/tomcat-users.xml <role rolename="solr_admin"/> <user username="your_username" password="your_password" roles="solr_admin" /> sudo nano /etc/tomcat7/web.xml Add the following lines within the web-app xml node <security-constraint> <web-resource-collection> <web-resource-name>Solr Lockdoawn</web-resource-name> <url-pattern>/</url-pattern> </web-resource-collection> <auth-constraint> <role-name>solr_admin</role-name> <role-name>admin</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>BASIC</auth-method> <realm-name>Solr</realm-name></login-config> Restart Tomcat: sudo service tomcat7 restart Read More

Install Solr on Ubuntu

by on October 28, 2018 0
sudo apt-get -y install solr-tomcat Then go to your admin portal: http://<Your-IP>:8080/solr/admin/ sudo nano /etc/solr/conf/solrconfig.xml sudo nano /etc/solr/conf/schema.xml <dataDir> : Data Directory Used to specify an alternate directory to hold all index data other than the default ./data under the Solr home. If replication is in use, this should match the replication configuration.   <!-- Commit [...] Read More