I’ve been working on setting up a Java based SAML provider. This means that the application needs to handle request and response over HTTPS. And, since often this is deployed in data centers where non-standard ports are blocked, it means that the HTTPS really needs to be supported on the proper port, which is 443. Here are the range of options.
Continue reading
Category Archives: shell
todo.txt done
While I like the functionality of the todo.txt structure, I do not like the fact that done tasks stay in my todo list in perpetuity, and I also don’t want to lose them. So, I’ve made a simple hack that allows me to move done items to a done folder. Here’s the code:
#!/bin/sh awk '/^x/ {print $0}' ~/Dropbox/todo/todo.txt >> ~/Dropbox/todo/done.txt awk '!/^x/ {print $0}' ~/Dropbox/todo/todo.txt > ~/Dropbox/todo/todo2.txt mv ~/Dropbox/todo/todo2.txt ~/Dropbox/todo/todo.txt |
I call it todo_done.sh.
I copied my original to /tmp/pre in order to test and make sure I have a backup. After running todo_done.sh I get:
$ diff -u /tmp/pre/todo.txt ~/Dropbox/todo/todo.txt --- /tmp/pre/todo.txt 2017-11-15 17:46:21.794510999 -0500 +++ /home/ayoung/Dropbox/todo/todo.txt 2017-11-15 17:46:24.584515043 -0500 @@ -7,7 +7,6 @@ 2017-10-02 Expenses 2017-10-04 Containerize hammer 2017-10-06 Complete steam setup -x 2017-10-12 Trrc time resource reduce cost 2017-10-12 Whiteboard training 2017-10-14 Subscription manager extensions for skis or products? 2017-10-15 Workcenter is made up of 4 things: machine, man, method, measures. |
and
$ diff -u /tmp/pre/done.txt ~/Dropbox/todo/done.txt --- /tmp/pre/done.txt 2017-11-15 17:46:17.914505377 -0500 +++ /home/ayoung/Dropbox/todo/done.txt 2017-11-15 17:46:24.580515037 -0500 @@ -26,3 +26,4 @@ x 2017-10-19 Drs appt? x 2017-11-02 Letter of Support x 2017-11-15 2017-09-27 LinkedIn TJX +x 2017-10-12 Trrc time resource reduce cost |
What is minishift ssh anyway?
The documentation says that to access a minishift-deployed VM you can use `minishift ssh` to log in, but what if you want to use other tooling (like Ansible) to get in there? How can you use standard ssh commands to connect?
MIDI, ALSA, USB, and JACK
Akai recently released a USB version of their Electronic Wind Instrument (EWI) which I was able to purchase for under $200. I was fairly quickly able to get it running using QJackCtl and QSynth. But then I wanted to understand what was happening. That involved spelunking into the four subsystems that make up the title of this post.
Continue readingShared Nothing Diskless Boot
It is possible to run a computer with no persistent storage for its root file system other than a single image downloaded an held in RAM. The computer does not needs a local disk. The computer also does not need a SAN or NAS device for the Root File system.
There are numerous uses for this style of booting. A short list:
- Debugging the installation processes of software packages
- Running computationally intensive tasks on a large array of nodes
- Inventorying the hardware on new servers
- Deploying a light management framework for virtualization hypervisors
add_todo
I forget things. A lot. I need a to do list tracker that works with me. So I wrote one. I, being me, used the technologies I use the most to make this happen: bash and git.
Finding Java Classes
I’m back on a Java project. Been a while, and I want to capture some of the tricks I’m using.
Right now, I’m just trying to import the project into eclipse. Seems that the current team members don’t use it. I’m an IDE kind of guy, at least when it comes to Java.
Building the .classpath file can be tricky. However, since I know that I have a good build, and that this project it a good participant in the Fedora build process, I have the advantage of knowing that my packages reside in /usr/share/java. Still, all eclipse gives me is a set of classes that it can’t find. how to find them?
This project uses CMake. I could look for all of the Jar files in the CMakeLists.txt files, and I might do that in the future. However, a trick I’ve developed in the past has come in handy.
class2path(){ echo $1 | sed 's!\.!\/!g' } JDIR=/usr/share/java make_alljars(){ for JAR in `find /usr/share/java -name \*.jar -type f ` do for CLASS in `jar -tf $JAR | grep \.class` do echo $JAR $CLASS done done > /tmp/alljars.txt }
First, the make_alljars function creates a map in (value key) order. The value is the Jar file name, and the key is the class name. To fine a Jar file that contains a given class (in this example netscape.ldap.LDAPConnection) , run:
grep `class2path netscape.ldap.LDAPConnection` /tmp/alljars.txt
And the output is
/usr/share/java/ldapjdk.jar netscape/ldap/LDAPConnection$ResponseControls.class /usr/share/java/ldapjdk.jar netscape/ldap/LDAPConnection.class
This works really well with eclipse, in that the error messages have the name of the class. You can then just highlight the class name, paste it into the command line in place of the class I have above, and when you get the Jar file name, you can highlight to save to the clipboard. From The right click context menu pick Java Build Path and then Add External Archive and then paste the whole path in.
Java as a scripting language
When developing in Python or Perl, it is very common to start with an executable script, and to edit/run/edit/run. Java is slowed down by the cycle of edit/compile/run. Here’s a proof of concept of coding in Java like you do in Python.
IPAddress for local Virtual Machines
When running Fedora as a KVM/Qemu host for virtual machines, you have the issue that you don’t know the IP Address for a virtual machine once you create it. IP addresses that are assigned via
The MAC Address is in the config file saved in
/etc/libvirt/qemu/$VMNAME.xml
Once you start the virtual machine, you can fetch the IP Address from the DHCP lease file in:
/var/lib/dnsmasq/dnsmasq.leases
To correlate the two:
#!/bin/bash VMNAME=$1 MAC=`cat /etc/libvirt/qemu/$VMNAME.xml | xml2 | awk 'BEGIN{FS="="} /mac..address/ {print $2}'` IP=`grep $MAC /var/lib/dnsmasq/dnsmasq.leases | cut -d' ' -f3` #$VMNAME has MAC $MAC and IPAddress $IP echo $IP
This must be called as root or via sudo.
UPDATE:
Chris Lalancette notes that the cannonical version of the MAC address can be found using
virsh -c qemu:///system dumpxml $VMNAME
Removing empy comment blocks
Eclipse can automate a lot of stuff for you. One thig is did for me was automating the serialVersionId generation for all the serializable classes in my tree.
They look like this:
/** * */ private static final long serialVersionUID = -9031744976450947933L;
However, it put an empty block comment in on top of them, something I didn’t notice until I had mixed in this commit with another. So, I want to remove those empty comment blocks.
#!/bin/bash for JAVAFILE in `find . -name \*.java` do sed -n '1h;1!H;${;g;s! */\*\*\n *\* *\n *\*/ *\n!!g;p;}' \ < $JAVAFILE > $JAVAFILE.new mv $JAVAFILE.new $JAVAFILE done
Thanks to this article for how to do the multiline search and replace.
http://austinmatzko.com/2008/04/26/sed-multi-line-search-and-replace/