depicus

changing the digital world one bit at a time...

Blants (noun) the rants of a blogger

  1. Wake on Tweet – because you never asked for it…

    December 30, 2014 by The Man
    Wake on Tweet

    Wake on Tweet

    tl:dr Just send a tweet with the hashtag #wakeonlan and a properly formatted mac address like AA:BB:CC:DD:EE:FF, an ip address or FQDN and a port number and that is it. Easy.

    It all started a few weeks ago when I was looking at Slack to use at a clients site so we could integrate more. If you haven’t tried Slack I would highly recommend taking a look – it’s WhatsApp for groups with a steroid injection of crazy fun stuff for developers. One of those fun things are hooks where you can define actions when things happen. So I have Slack hook alert to a group called #twitter whenever a tweet mentions @depicus it would call a webpage on a server. Sadly the info Slack passes wasn’t enough for me as it doesn’t include the message body of the tweet. So sadly my brave idea of Wake on Lan via Twitter died….

    (more…)


  2. Android TextView making clickable url links

    December 9, 2011 by The Man

    So simple

    
    	public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.help);
            
            TextView urlText;
            urlText = (TextView) findViewById(R.id.lblInfo4);
            String text = "Finally if you need more information then please pop over to support.depicus.com or " +
            		"tweet me @depicus.";
            urlText.setText(Html.fromHtml(text));
            urlText.setMovementMethod(LinkMovementMethod.getInstance());
    	}
    
    

    And it should look like this


  3. Android: Getting the Broadcast Address of your Wifi connection

    May 1, 2011 by The Man

    If you ever need to know the broadcast address of your wifi connection…

    private InetAddress getBroadcastAddress() throws IOException {
    	WifiManager myWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
    	DhcpInfo myDhcpInfo = myWifiManager.getDhcpInfo();
    	if (myDhcpInfo == null) {
    		System.out.println("Could not get broadcast address");
    		return null;
    	}
    	int broadcast = (myDhcpInfo.ipAddress & myDhcpInfo.netmask)
    				| ~myDhcpInfo.netmask;
    	byte[] quads = new byte[4];
    	for (int k = 0; k < 4; k++)
    	quads[k] = (byte) ((broadcast >> k * 8) & 0xFF);
    	return InetAddress.getByAddress(quads);
    }
    

  4. Android: Getting the Wifi Ip Address

    by The Man

    This is how to get the ip address of your Android phone.

    WifiManager myWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
    WifiInfo myWifiInfo = myWifiManager.getConnectionInfo();
    int ipAddress = myWifiInfo.getIpAddress();
    System.out.println("WiFi address is " + android.text.format.Formatter.formatIpAddress(ipAddress));
    

    Make sure you also add

    to your Application Manifest.


  5. AS400 iSeries Java program completed with exit code 134

    December 6, 2010 by The Man

    Having spent a few days stuck on this issue.

    FATAL ERROR in native method: Received NULL object reference
    java.lang.Throwable
    Java program completed with exit code 134

    Most of the google hits talked about PTF’s not being up to day. For me the error was the jar file I referenced was not in /QIBM/Userdata/Java400/ext. Stupid rookie mistake I know but the test system had the file from a previous project so I didn’t even check it. I had the CLASSPATH set to a directory where the jar file was but despite this when we went live it didn’t work. I was suitably red faced but at least this may help you avoid the embarrassment,