## Project Euler – Problem 3

Problem 3:
The prime factors of 13195 are 5, 7, 13 and 29.

What is the largest prime factor of the number 600851475143 ?

 import math   pSieve = [] max = math.floor(math.sqrt( 600851475143 )) l = 0 i=2; while i ii ): break; if (i % pSieve[j] == 0): found = True break; j+=1 if found == False: pSieve.append(i) if (600851475143 % i == 0): l=i i+=1 print l

## Update to quick one-liner Windows unzips

So this one is taken from https://blogs.msdn.microsoft.com/daiken/2007/02/12/compress-files-with-windows-powershell-then-package-a-windows-vista-sidebar-gadget/

echo \$zipfilename=\$args[0]; \$destination=\$args[1];if(test-path(\$zipfilename)) {\$shellApplication = new-object -com shell.application;\$zipPackage = \$shellApplication.NameSpace(\$zipfilename);\$destinationFolder = \$shellApplication.NameSpace(\$destination); \$destinationFolder.CopyHere(\$zipPackage.Items()); };>unzip.ps1

powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File unzip.ps1 %FullPathToZip% %FullPathToTarget%

This was tested on PSv2.

## Buildforge CRRBF1253I Process for id [] [B] died unexpectedly.

I kept getting Completed — Failed — Died and
CRRBF1253I Build Forge: Process for id [] [B] died unexpectedly.

After checking out http://www.ibm.com/support/docview.wss?uid=swg21634022 and
http://www.ibm.com/support/docview.wss?uid=swg21634022 there was still no solution in sight.

Finally I was able to solve the issue in my buildforge instance by disabling *sticky* in my inline libraries. I was also using .bset server and .bset buildserver. My theory is that some interaction between the sticky and the bset were conflicting.

## Build Forge Agent Troubleshooting

Just in case some poor sap like me gets stuck with errors
connecting to Build Forge Agents:

com.buildforge.services.common.api.APIException:
CRRBF0158I: Unable to set user account to unknown account (builder)
at com.ibm.jas.mjc.server.refresh.AgentServerTestFiber.checkAuth(AgentServerTestFiber.java:431)

Some fixes..

sudo /usr/local/bin/bfagent -s

## Scrabble Problem

If I give you scrabble tiles and a dictionary, determine the valid words

 package joshho;   import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.Arrays;   public class Runner { ScrabbleSet set ;   private class ScrabbleSet { char[] chars; public ScrabbleSet(String[] orig){ chars = new char[orig.length]; for(int i=0;i chars.length) return false; Arrays.sort(find); int s=0; for(int i=0;i chars[j]) continue; if(find[i] == chars[j]){ s=j+1; break; } return false; } } return true; } }   public void load(String y){ set = new ScrabbleSet(y.split(" ")); }   public static void main(String[] args) throws IOException { args = new String[]{"Scrabble\\data\\english4000.dic", "g w x b d u t z q m o i e p o"}; FileReader fr = new FileReader(args[0]); BufferedReader br = new BufferedReader(fr);   Runner r = new Runner(); r.load(args[1]); System.out.println(args[1]);   String line; while((line = br.readLine()) != null) { System.out.print(line+" "); System.out.println(r.set.checkWord(line.toCharArray())); } br.close();     }   }

There’s probably a better way to do this, I am interested
to see what other solutions there are.

## Zip with ANT on Windows command line

Short two liner for ANT zipping on Windows.

 >build.xml echo ^^^ ant

Because Windows doesn’t apparently have a zip command line.

Updated here for Windows without ANT.

## Working with genrb and ICU4J

Wanting to use the messages in ICU4J, I was lead to believe one needed to run the command:

genrb root.txt

This produces root.res.
However using the following snippet results in the error message below:

UResourceBundle urb = UResourceBundle.getBundleInstance("Your package path","root");

>Data file yourPackagePath/root.res is corrupt - ICU data file error: Header authentication failed, please check if you have a valid ICU data file

## Cookie cannot be resolved to a type

“Cookie cannot be resolved to a type”

I swear I’ve seen this error like 5 times in eclipse now, and I have yet to learn my lesson.
If this error originates from a jsp file, your project doesn’t have a valid target webserver (in my case – tomcat).

So just make sure it’s configured correctly.

Thought I’d just leave this here,
because almost all top searches in google were useless to me.

Cheers.

## Bash Pitfalls

I was on IRC.. and noticed this link.. http://mywiki.wooledge.org/BashPitfalls,
if I had only known earlier…

Tons of useful information on Bash Pitfalls… as well as tons of habits to change… :/

My error was specifically #22,
cmd1 && cmd2 || cmd3 where I had assumed cmd2 is going to exit 0.

In most of my usecases… my command is in the form of cmd1 || sleep # && cmd3, I just naturally assume sleep is going to return 0.

Well, luckily for me, it has worked for the most part… but definitely need to change a number of my scripting habits…

## Been a little busy…

With my new job, I haven’t had much time to add much to this website.

So here’s this small perl script I wrote that sends a summary of the weather in SMS format from my iPhone daily.
There was a need, so I figured why not help out those who need the weather forecast =].

 use LWP::Simple; use JSON qw( decode_json );   my \$lastRun = 0; open (MYFILE, 'weatherSMS_LastRun'); while () { chomp; \$lastRun = \$_; } close (MYFILE);   my (\$S,\$M,\$H,\$d,\$m,\$Y) = localtime(\$lastRun); my (\$S2,\$M2,\$H2,\$d2,\$m2,\$Y2) = localtime(time); if ( \$Y2 == \$Y && \$m2 == \$m && \$d2 == \$d ){ exit 0; }   \$json = get("https://api.forecast.io/forecast/APIKEY/LATITUDE,LONGITUDE?units=ca&exclude=currently,minutely,hourly,flags"); my \$decoded = decode_json(\$json);   #ensure we can write the file open(F,'>weatherSMS_LastRun') || die "Could not open file to mark execution"; print F time; close(F);   my @timeslot = @{ \$decoded->{'daily'}{'data'} }; my \$forcast = ""; foreach my \$f ( @timeslot ) { my (\$S,\$M,\$H,\$d,\$m,\$Y) = localtime(\$f->{"time"}); \$m = \$m + 1; \$forcast .= "\$m/\$d: ".sprintf("%.3f",\$f->{"temperatureMin"})."-".sprintf("%.3f",\$f->{"temperatureMax"})."C ".\$f->{"summary"}."\n"; } #printf(\$forcast);   `/Applications/biteSMS.app/biteSMS -send -carrier PHONENUMBER "\$forcast"`;

In order to execute this daily, the following plist was used:

 Label com.joshho.weatherSMS LowPriorityIO Nice 1 AbandonProcessGroup OnDemand ProgramArguments /usr/local/bin/perl /location to perlscript/weatherSMS.pl StartCalendarInterval Minute 0

Submit it to be executed hourly by running `launchctl load [path to plist]`

Edit
Edits were made to cover the fact that your phone may not always have internet.
(It may be locked/sleeping – which may turn off the wifi?)