Tuesday, August 19, 2014

seeing the progress of Windows Update in windows 8

Just upgraded to windows 8, and I'm not happy about a lot of it, but I kept digging to see if the answers I wanted are perhaps in there somewhere.

Most particularly I was very frustrated that I could not see the progress of windows update as it ran from the app.  It took me a long time to figure this out, but if you go to the control panel in the desktop and look at windows update there, you get to see it all as it happens!







Wednesday, May 14, 2014

Charity must begin at home

We have changed ourselves as a country and as a people when we think that the social safety net MUST come from government. When my grandparents came to Lynn in 1904 they came to a community that took them in and shared responsibility for them. If a kid was misbehaving, the first adult in the neighborhood to it would pass that information on to the parent. If someone was struggling their family was invited to dinner. Simple concepts that are rarely practiced any more.
Charity does more than help the recipient -- it integrates the giver into the community. We learn more about ourselves and our communities through our own acts of charity. In particular we learn that our society is not as hopeless as the doomsayers would have us believe. If we can all find a way to be a little more involved and have a closer relationship with our neighbors, we would find that we can solve more problems.
Sadly, some people would rather wash their hands of the responsibilities of humanity. When I hear people say "that's what I pay taxes for" as an excuse to look the other way -- it bothers me. There's a lot about our system that can be remedied if we can just work a little bit at being good towards each other and finding a way to be give of ourselves.
And that's what bothered me about this story. I think there is a concerted effort by some to make the social safety net be solely the responsibility of government. This doesn't work because government is whimsical. Today's charity is tomorrows pariah with a new majority in power. Republicans won't allow government funds to Democratic causes and vice versa.
But hopefully our hearts ARE constant. Where people want to step up and engage in charity, we should not punish them.

Friday, October 25, 2013

Public OpenPGP key of Daniel Fishman

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: OpenPGP.js v.1.20130820
Comment: http://openpgpjs.org

xsBNBFJnxlkBCAC9lUd4l1rYa4WGb8SqvHsYRKm3IVWc2nhUj5feBNBsOXNZ
Dtg2oSjASXfiUQFiv18SX7NM8IeJjYX4GaU6zxJP3VjhieqU02nvty1qZixt
D6IPwQ7Bqyoh2n5w5Gcp+afRmy2Jh4/XRMgbMmPEhkFITZIUYVt55kv6UJhD
tGa/GLSCD1H7LfL6neFOOP2kKjU7cOFlKbPbQT9mZBphPkGEouHD2HK29ytz
WnI4RC8BXjNAgLgMrQQNYl/WvoPABCI/Nyp3Y0I2Rl+H7JvL4ge+6fUuB7CQ
JTUViylF3aPAETL4P0rlLPfndhQez/RUupESokLHGg5MxxlKOl7CgSuHABEB
AAHNIkRhbmllbCBGaXNobWFuIDxmaXNoZGFuQHlhaG9vLmNvbT7CwFwEEAEI
ABAFAlJnxlwJEHFfiQpx5t5BAADg/wf+IyR4JWJtRP9foenLKQa17Iriuvuf
+gMZ7cW/0SYSEWQ6tMvvJguF9+z+CvpEhQBVnK6GW1qjnY11rw1Qi8xvWz70
3gQqfNJfa/DLB49pUAivwfQmKVoS3LIauNTHY+XIDpqZt3Sh9PjqkCdsNjrh
qXvAAdRJQcjPC/+WdG8t7yAhu/bI+7bv0u/bqXSqsq6SzBAsK3d5xWJZlGjy
RT77HGhROdk0cip13xlcW8R73AHyTHyh1U8VocwFIb3NRRVf3y9zmvwF5QdX
jrvJVbTC/AtWKEJhjircXP2TJostQ2udd+rm0S1bx2IKZNPgl8XuQT9gLheB
bUfzbXa5yubyCg==
=wSrX
-----END PGP PUBLIC KEY BLOCK-----

*** exported with www.mailvelope.com ***P key of Daniel Fishman

Saturday, April 28, 2012

OSX single user repair permissions 10.6



After the Command-S startup, type the following on the command prompts, allowing time for each to do its thing:



 
/sbin/fsck -y<return> 
/sbin/mount -uw /<return> 
/sbin/autodiskmount -va<return> 

launchctl load /System/Library/LaunchDaemons/com.apple.diskarbitrationd.plist
/usr/sbin/diskutil repairPermissions / 

Thursday, March 08, 2012

mcp -- copying a file to multiple machines via scp

I have a series of 6 machines that I need to occasionally deploy the same file to in exactly the same place.  I got tired of it being such a pain so I wrote this little script I call mcp.sh  It's certainly easy enough for a shell script master to do this, but for me?  I struggled for 30 mins to get this right -- hopefully this saves you some pain.

I assume you have already passed your ssh key to the machines you want to connect to so you can scp without a password.  If not please read  http://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id/

You call mcp.sh with the absolute path to the file you want to copy, and it will copy it to exactly the same location on the target machine.

Put names of the machines (one per line) you want to update in the file hosts.txt

#mcp.sh

firstChar=`expr substr $1 1 1`
if [ -z $1 ]; then
        echo "usage mcp </absolute/path/to/file.txt>"
        exit 1
fi
if [ $firstChar  != / ]; then
        echo "Must use absolute path"
        exit 1
fi
for line in `cat hosts.txt`
do
 `scp $1 root@$line:$1`
done


improvement comments welcome

Monday, December 05, 2011

Using a Servlet to generate chart images for BIRT

I've been working with Google's chart tools -- specifically their Image Chart tools.  My problem -- I'm using BIRT as my PDF report engine, but I have a web interface.  I want the report to look the same on the web as it does in BIRT (which has it's own excellent native charting library).  I decided the easiest way is to use an
image tag, but I have the potential for copious data, so I have to use a POST instead of a GET.

Google lists an excellent hack using a form and an Iframe as a way to submit the post and that works for me from the web.   It does not work inside of BIRT -- because as far as I know there is no way to submit a form inside of a report.  Instead I decided to use an image tag which runs through a servlet I host.

So now I can write on my web page:

<img src="../chart/chart.png">

and I can include in a dynamic text in my BIRT report

"<img src='http://mywebserver/chart/chart.png'>"  //outside quotes required for BIRT dynamic text

And now I have the same chart in both!  Voila.



import org.apache.commons.io.IOUtils;


import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.*;
import java.net.*;
import java.util.Enumeration;
import java.util.Hashtable;


public class ChartServlet extends HttpServlet {


    public void service(HttpServletRequest request, HttpServletResponse response) {
        response.setHeader("content-type", "image/png");
        try {
            // Construct data
            Hashtable dataHash = new Hashtable();
            dataHash.put("cht", "lc");
            dataHash.put("chtt", "This is my chart");
            dataHash.put("chs", "600x300");
            dataHash.put("chxt", "x");
            dataHash.put("chd", "t:40,20,50,20,100");
            StringBuilder postBuffer = new StringBuilder();
            Enumeration enumeration = dataHash.keys();
            boolean first = true;
            while (enumeration.hasMoreElements()) {
                String key = (String) enumeration.nextElement();
                String value = (String) dataHash.get(key);
                String prefix = "&";
                if (first) {
                    prefix = "";
                    first = false;
                }
                postBuffer.append(getURLPair(prefix, key, value));
            }
            String params = postBuffer.toString();
            // Send data
            URL url = new URL("http://chart.googleapis.com/chart");
              //?chid=a"+String.valueOf(Math.random()).substring(2)); to avoid caching
            URLConnection conn = url.openConnection();
            conn.setDoOutput(true);
            OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream(),"UTF-8");
            wr.write(params);
            wr.flush();
          // Get the response and write it directly to your response
            IOUtils.copy(conn.getInputStream(), response.getOutputStream());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static String getURLPair(String prefix, String key, String value) {
        try {
            String parameterString = prefix + URLEncoder.encode(key, "UTF-8") + "=" 
            + URLEncoder.encode(value, "UTF-8");
return parameterString;
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();  
        }
        return null;
    }

}

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.

Sunday, August 21, 2011

Followup to the Integer toggle code

My good friend Greg mentioned that I should use bitwise operators to perform a toggle, as opposed to my earlier method of using integer math to manipulate the state.  I had not done that because the bitwise implementation is imho not comprehensible by a developer who does not have a CS degree.

As an example it is not at ALL clear to most people that ~2<<10 != ~(2<<10)

Although I suppose that's the point of a method name.



/**
 * A simple way to implement a toggle switch using an integer to store the state
 * and bitwise operators to manipulate the toggle
 * 
 * @author Dan Fishman http://www.fishdan.com
 *
 * This code released to the public under the CreativeCommons 3.0 license by
 * the author on 8/21/2011
 * 
 * http://creativecommons.org/licenses/by/3.0/
 */

public class TestToggle {

  public static int toggleState=0;
  
  public static void main(String argv[]){
      for(int x=0;x<32;x++){
        System.out.println(x+":"+Integer.toBinaryString(toggleState));
        System.out.println(x+":"+Integer.toBinaryString(2 << x));
        toggle(true,x);
        System.out.println("-----------------------");
        System.out.println(x+":"+Integer.toBinaryString(toggleState));
        System.out.println("isOn "+x+" == "+toggleIsOn(x));
        toggle (false,x);
        System.out.println("isOn "+x+" == "+toggleIsOn(x));
        System.out.println("");
      }    
      
      //PAY ATTENTION TO THESE TWO LINES  order of operations can be tricky in bitwise
      // see http://www.uni-bonn.de/~manfear/javaoperators.php
      System.out.println("**"+Integer.toBinaryString(~2<<10));
      System.out.println("**"+Integer.toBinaryString(~(2<<10)));
  }

  /**
  * if onOff==true we set the value at pos == 1 aka on
  * else we set it to 0;
  * @param onOff
  * @param pos
  */
 public static void toggle(boolean onOff, int pos){
     if(onOff==true){
         toggleState |= 2 << pos;
     }
     else{
         toggleState &= ~(2<<pos);
     }
 }
 
 public static boolean toggleIsOn(int x){
     return (toggleState & 2<<x) == 2<<x;
 }        
    
}