tag:blogger.com,1999:blog-83733315335722153992024-03-05T12:10:59.423-05:00j4neirosMy digital hodgepodgeJ. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.comBlogger304125tag:blogger.com,1999:blog-8373331533572215399.post-90611590976942595712024-02-07T16:37:00.002-05:002024-02-07T16:37:40.345-05:00Holidays API from https://dev.timeanddate.com/holidays/<p> Sample code here: <a href="https://gist.github.com/64board/0f9485c4140f62565e02ca941417f68f" rel="nofollow" target="_blank">https://gist.github.com/64board/0f9485c4140f62565e02ca941417f68f</a></p><div class="edit-comment-hide">
<div class="comment-body markdown-body js-comment-body soft-wrap user-select-contain d-block">
<p dir="auto">Output:</p>
<p dir="auto">2024-01-01 New Year's Day<br />
2024-01-15 Martin Luther King Jr. Day<br />
2024-02-19 Presidents' Day<br />
2024-05-27 Memorial Day<br />
2024-06-19 Juneteenth<br />
2024-07-04 Independence Day<br />
2024-09-02 Labor Day<br />
2024-10-14 Columbus Day<br />
2024-11-11 Veterans Day<br />
2024-11-28 Thanksgiving Day<br />
2024-12-25 Christmas Day</p>
</div>
</div><p></p><p> </p><p> <br /></p>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-7664070419289824472024-01-25T14:25:00.003-05:002024-01-25T14:25:25.209-05:002024 Holiday Schedule<p> </p><section class="tab-content" id="2024" title="2024"><div class="ContentBody"><table class="DataTable HolidayTable"><caption></caption><thead><tr><th scope="col">Date</th>
<th scope="col">Holiday</th>
</tr>
</thead>
<tbody>
<tr>
<td>Monday, January 01 </td>
<td>New Year’s Day</td>
</tr>
<tr>
<td>Monday, January 15 </td>
<td>Birthday of Martin Luther King, Jr.</td>
</tr>
<tr>
<td>Monday, February 19 <span class="Footnote">*</span></td>
<td>Washington’s Birthday</td>
</tr>
<tr>
<td>Monday, May 27 </td>
<td>Memorial Day</td>
</tr>
<tr>
<td>Wednesday, June 19 </td>
<td>Juneteenth National Independence Day</td>
</tr>
<tr>
<td>Thursday, July 04 </td>
<td>Independence Day</td>
</tr>
<tr>
<td>Monday, September 02 </td>
<td>Labor Day</td>
</tr>
<tr>
<td>Monday, October 14 </td>
<td>Columbus Day</td>
</tr>
<tr>
<td>Monday, November 11 </td>
<td>Veterans Day</td>
</tr>
<tr>
<td>Thursday, November 28 </td>
<td>Thanksgiving Day</td>
</tr>
<tr>
<td>Wednesday, December 25 </td>
<td>Christmas Day</td>
</tr>
</tbody>
</table>
<p class="Footnote"><span>*</span>This holiday is designated
as "Washington’s Birthday" in section 6103(a) of title 5 of the United
States Code, which is the law that specifies holidays for Federal
employees. Though other institutions such as state and local governments
and private businesses may use other names, it is our policy to always
refer to holidays by the names designated in the law.</p>
</div>
</section>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-87150252045775488042023-12-13T11:36:00.010-05:002023-12-13T11:38:28.722-05:00Federal Holidays 2023<p> </p><section class="tab-content" id="2023" title="2023"><div class="ContentBody"><table class="DataTable HolidayTable"><caption></caption><thead><tr><th scope="col">Date</th>
<th scope="col">Holiday</th>
</tr>
</thead>
<tbody>
<tr>
<td>Monday, January 02 <span class="Footnote">*</span></td>
<td>New Year’s Day</td>
</tr>
<tr>
<td>Monday, January 16 </td>
<td>Birthday of Martin Luther King, Jr.</td>
</tr>
<tr>
<td>Monday, February 20 <span class="Footnote">**</span></td>
<td>Washington’s Birthday</td>
</tr>
<tr>
<td>Monday, May 29 </td>
<td>Memorial Day</td>
</tr>
<tr>
<td>Monday, June 19 </td>
<td>Juneteenth National Independence Day</td>
</tr>
<tr>
<td>Tuesday, July 04 </td>
<td>Independence Day</td>
</tr>
<tr>
<td>Monday, September 04 </td>
<td>Labor Day</td>
</tr>
<tr>
<td>Monday, October 09 </td>
<td>Columbus Day</td>
</tr>
<tr>
<td>Friday, November 10 <span class="Footnote">*</span></td>
<td>Veterans Day</td>
</tr>
<tr>
<td>Thursday, November 23 </td>
<td>Thanksgiving Day</td>
</tr>
<tr>
<td>Monday, December 25 </td>
<td>Christmas Day</td>
</tr>
</tbody>
</table>
<p class="Footnote"><span>*</span>If a holiday falls on a
Saturday, for most Federal employees, the preceding Friday will be
treated as a holiday for pay and leave purposes. (See 5 U.S.C. 6103(b).)
If a holiday falls on a Sunday, for most Federal employees, the
following Monday will be treated as a holiday for pay and leave
purposes. (See Section 3(a) of Executive Order 11582, February 11,
1971.) See also our Federal Holidays – "In Lieu Of" Determination Fact
Sheet at
https://www.opm.gov/policy-data-oversight/pay-leave/work-schedules/fact-sheets/Federal-Holidays-In-Lieu-Of-Determination.</p>
<p class="Footnote"><span>**</span>This holiday is
designated as "Washington’s Birthday" in section 6103(a) of title 5 of
the United States Code, which is the law that specifies holidays for
Federal employees. Though other institutions such as state and local
governments and private businesses may use other names, it is our policy
to always refer to holidays by the names designated in the law.</p><p class="Footnote">Taken from: <a href="https://www.opm.gov/policy-data-oversight/pay-leave/federal-holidays/#url=2023" rel="nofollow" target="_blank">https://www.opm.gov/policy-data-oversight/pay-leave/federal-holidays/#url=2023 </a><br /></p><p class="Footnote"> </p>
</div>
</section>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-26118753978657632222022-11-25T16:01:00.006-05:002022-11-25T16:01:43.744-05:00King, Bishop and Knight against King Endgame<div class="post-view-header">
<h1 class="post-category-header-title-v5"></h1>
</div>
<div class="post-view-about">
<div>
<div class="post-view-meta-component">
<a class="post-view-meta-avatar
" href="https://www.chess.com/member/64board" style="height: 3.5rem; width: 3.5rem;" title="64board">
<img alt="64board" class="post-view-meta-image" data-src="https://images.chesscomfiles.com/uploads/v1/user/7336555.9dd6d218.35x35o.adc3595edb32.jpeg" data-srcset="https://images.chesscomfiles.com/uploads/v1/user/7336555.9dd6d218.35x35o.adc3595edb32@2x.jpeg 2x" height="35" src="https://images.chesscomfiles.com/uploads/v1/user/7336555.9dd6d218.35x35o.adc3595edb32.jpeg" width="35" />
</a>
<div class="post-view-meta-details">
<div class="user-tagline-component ">
<a class="user-username-component user-username-blue-with-dark-mode user-tagline-username" href="https://www.chess.com/member/64board">
64board
</a>
<div class="country-flags-component country-2
" data-cy="user-country-flag">
</div>
<a aria-label="Show your flair!" class="user-flair flair-link" href="https://www.chess.com/settings#flair-modal">
<span class="flair-component flair-board">
</span>
</a>
</div>
<div class="post-view-meta-stats">
<time datetime="2022-07-18 10:43">
Updated: Jul 18, 2022, 10:43 AM</time> </div><div class="post-view-meta-stats"> </div><div class="post-view-meta-stats">The purpose of this post is to put together some resources about this particular endgame.</div></div></div></div></div><div class="post-view-content">
<p>I think every chess player should learn this checkmate, it requires
several techniques that are present in every day chess play like piece
coordination, kings opposition, value of waiting moves, etc.</p>
<p>Although this checkmate is consider as a basic checkmate I think it
is the trickiest one, in particular because of the 50 moves rule that
will help the defender in case the attacker makes a few mistakes.</p>
<p>The best explanation I found about this checkmate is in the book <em>"Fundamental Chess Endings"</em> by Karsten Muller and Frank Lamprecht. There is an Amazon <a href="https://www.amazon.com/Fundamental-Chess-Endings-Karsten-M%C3%BCller/dp/1901983536/ref=tmm_pap_swatch_0?_encoding=UTF8&qid=1658152617&sr=8-2" rel="ugc nofollow noreferrer noopener" target="_blank">paperback </a>version and a cheaper <a href="https://www.amazon.com/Fundamental-Chess-Endings-Karsten-M%C3%BCller-ebook/dp/B00BJ64LMW/ref=tmm_kin_swatch_0?_encoding=UTF8&qid=1658152617&sr=8-2" rel="ugc nofollow noreferrer noopener" target="_blank">Kindle </a>one.</p>
<p>This is a very well explained YouTube video about the KBNK checkmate <a href="https://youtu.be/oRK7XLhGz_c" rel="ugc nofollow noreferrer noopener" target="_blank">https://youtu.be/oRK7XLhGz_c</a></p>
<p>The following link will allow you to practice against the <strong>lichess </strong>engine. The method they explain is called <em>Deletang's triangles</em>, from the name of the person that formalized it. <a href="https://lichess.org/practice/checkmates/knight--bishop-mate/ByhlXnmM/D23EYigW" rel="ugc nofollow noreferrer noopener" target="_blank">https://lichess.org/practice/checkmates/knight--bishop-mate/ByhlXnmM/D23EYigW</a></p>
<p>Personally I prefer Phillidor's method using the Knight's W route.</p>
<p>At <strong>chess.com</strong> I use the following link to create a
custom position and challenge people to play, that way I use the
randomness that humans introduce in the game, it is amazing to see how
many players don't know how to deliver checkmate, <a href="https://www.chess.com/variants/custom">https://www.chess.com/variants/custom</a></p>
<p>When perfectioning your endgame technique I found the following link to tablebases online very useful: <a href="https://www.shredderchess.com/online/endgame-database.html" target="_blank">https://www.shredderchess.com/online/endgame-database.html</a></p>
<p>For example the following endgame requires 30 moves with perfect play:</p>
<p><img alt="" class="" data-src="https://images.chesscomfiles.com/uploads/v1/images_users/tiny_mce/64board/phpyqrDdo.png" src="https://images.chesscomfiles.com/uploads/v1/images_users/tiny_mce/64board/phpyqrDdo.png" style="margin: 0 auto;" /></p>
<p>Since August 2021 chess.com also provide the tablebase feature, see announcement: <a href="https://www.chess.com/news/view/chesscom-announces-new-tablebase-feature">https://www.chess.com/news/view/chesscom-announces-new-tablebase-feature</a></p>
<p><em>(This is a work in progress)</em></p>
</div>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-72594107675506504772022-05-05T14:06:00.003-04:002022-05-05T14:08:05.755-04:002022 Holiday Schedule<table class="DataTable HolidayTable"><thead><tr><th scope="col">Date</th>
<th scope="col">Holiday</th>
</tr>
</thead>
<tbody>
<tr>
<td>Friday, December 31 <span class="Footnote">*</span></td>
<td><span> </span><span> </span>New Year's Day</td>
</tr>
<tr>
<td>Monday, January 17 </td>
<td><span> </span><span> </span>Birthday of Martin Luther King, Jr.</td>
</tr>
<tr>
<td>Monday, February 21 <span class="Footnote">**</span></td>
<td><span> </span><span> </span>Washington’s Birthday</td>
</tr>
<tr>
<td>Monday, May 30 </td>
<td><span> </span><span> </span>Memorial Day</td>
</tr>
<tr>
<td>Monday, June 20 <span class="Footnote">*</span></td>
<td><span> </span><span> </span>Juneteenth National Independence Day</td>
</tr>
<tr>
<td>Monday, July 04 </td>
<td><span> </span><span> </span>Independence Day</td>
</tr>
<tr>
<td>Monday, September 05 </td>
<td><span> </span><span> </span>Labor Day</td>
</tr>
<tr>
<td>Monday, October 10 </td>
<td><span> </span><span> </span>Columbus Day</td>
</tr>
<tr>
<td>Friday, November 11 </td>
<td><span> </span><span> </span>Veterans Day</td>
</tr>
<tr>
<td>Thursday, November 24 </td>
<td><span> </span><span> </span>Thanksgiving Day</td>
</tr>
<tr>
<td>Monday, December 26 <span class="Footnote">*</span></td>
<td><span> </span><span> </span>Christmas Day</td>
</tr>
</tbody>
</table>
<p class="Footnote"><span>*</span>If a holiday falls on a
Saturday, for most Federal employees, the preceding Friday will be
treated as a holiday for pay and leave purposes. (See 5 U.S.C. 6103(b).)
If a holiday falls on a Sunday, for most Federal employees, the
following Monday will be treated as a holiday for pay and leave
purposes. (See Section 3(a) of Executive Order 11582, February 11,
1971.) See also our Federal Holidays – "In Lieu Of" Determination Fact
Sheet at
https://www.opm.gov/policy-data-oversight/pay-leave/work-schedules/fact-sheets/Federal-Holidays-In-Lieu-Of-Determination.</p>
<p class="Footnote"><span>**</span>This holiday is
designated as "Washington’s Birthday" in section 6103(a) of title 5 of
the United States Code, which is the law that specifies holidays for
Federal employees. Though other institutions such as state and local
governments and private businesses may use other names, it is our policy
to always refer to holidays by the names designated in the law.</p><p class="Footnote"><a href="https://www.opm.gov/policy-data-oversight/pay-leave/federal-holidays/#url=2022" rel="nofollow" target="_blank">https://www.opm.gov/policy-data-oversight/pay-leave/federal-holidays/#url=2022</a></p>
</div>
</section>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-24174418214980607302021-12-29T17:01:00.005-05:002021-12-29T17:01:46.877-05:00Chess 960 posible starting positions<p>Examples in several programming languages<br /><a href="http://rosettacode.org/wiki/Generate_Chess960_starting_position" rel="nofollow" target="_blank">http://rosettacode.org/wiki/Generate_Chess960_starting_position</a><br /><br />All the positions with the standard ID number<br /><a href="https://chess960.net/wp-content/uploads/2018/02/chess960-starting-positions.pdf" rel="nofollow" target="_blank">https://chess960.net/wp-content/uploads/2018/02/chess960-starting-positions.pdf</a><br /><br /><a href="https://www.chessprogramming.org/Chess960" rel="nofollow" target="_blank">https://www.chessprogramming.org/Chess960<br /></a><br /><a href="https://github.com/MichaelB7/Chess960-Lookup/blob/master/src/960v09.c" rel="nofollow" target="_blank">https://github.com/MichaelB7/Chess960-Lookup/blob/master/src/960v09.c<br /></a><br /><a href="https://en.wikipedia.org/wiki/Fischer_Random_Chess_starting_position" rel="nofollow" target="_blank">https://en.wikipedia.org/wiki/Fischer_Random_Chess_starting_position<br /></a><br />Very good explanation of the rules<br /><a href="https://codegolf.stackexchange.com/questions/12322/chess960-position-lookup/12333#12333" rel="nofollow" target="_blank">https://codegolf.stackexchange.com/questions/12322/chess960-position-lookup/12333#12333</a><br /><br />B B Q N N R K R<br />4 * 4 * 6 * 5 * 4 * 1 = 1920<br /><br />Bishops have to be of different colors (4 black squares, 4 whites squares).<br /><br />There is only 1 possible position for the King and Rooks because it has to go<br />between the Rooks and there are only 3 squares available at that time.<br /><br />Because the Knights change color when they move they could be interchanged<br />without any difference then 5 * 4 should be divided by 2 then<br />total number of positions = 960.<br /><br /></p>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com1tag:blogger.com,1999:blog-8373331533572215399.post-74036889653030417572021-12-29T16:53:00.001-05:002021-12-29T16:53:12.501-05:00Tmux commands<p><span style="font-family: courier;"># List sessions<br /># Alias ls<br />tmux list-sessions<br />tmux ls<br /><br /># Create new session<br /># It is good practice to name sessions<br />tmux new -s right_window<br /><br /># Detach a session<br />Ctrl-b d<br /><br /># Attach a session using name<br />tmux a -t right_window<br /><br /># Use mouse to select pane<br />Ctrl-b :<br /># then type<br />set -g mouse on<br /><br /># Zoom a pane<br />Ctrl-b z<br /><br /># Scroll<br />Ctrl-b [<br /># Quit<br />q </span><br /></p>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-72260582898113096752021-12-29T16:04:00.006-05:002021-12-29T16:04:47.253-05:00Backup bash script<p><a href="https://github.com/64board/Bash/blob/main/backup.sh" rel="nofollow" target="_blank">https://github.com/64board/Bash/blob/main/backup.sh</a></p><p> </p>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-61719231414067266682021-12-29T14:22:00.005-05:002021-12-29T14:22:46.007-05:00Perl sort example<p>Sorting in Perl with user defined subroutines.</p><p><a href="https://github.com/64board/Perl/blob/main/sort.pl" rel="nofollow" target="_blank">https://github.com/64board/Perl/blob/main/sort.pl </a><br /></p>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-40729557066300049732021-12-29T14:19:00.004-05:002021-12-29T14:19:49.792-05:00Perl Getopt::Std example<p>Example of using Getopt::Std module. <br /></p><p></p><p><a href="https://github.com/64board/Perl/blob/main/get_opt.pl" rel="nofollow" target="_blank">https://github.com/64board/Perl/blob/main/get_opt.pl </a><br /></p>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-71682013102429839172021-08-31T10:14:00.002-04:002021-08-31T10:15:12.419-04:00Perl Date::Manip::Date business day<p><span style="font-size: x-small;"><span style="font-family: courier;"> #!/usr/bin/perl<br /><br /># Creates /etc/cron.d file entries, one per month,<br /># for a program that should run on the previous<br /># day to last business day of the month.<br /># Uses Date::Manip::Date module, https://metacpan.org/dist/Date-Manip/view/lib/Date/Manip/Date.pod.<br /># 64board@gmail.com<br /># 2021-08-31<br /> <br />use strict;<br />use warnings;<br /><br />use Date::Manip::Date;<br /><br />sub cron_entry {<br /><br /> my ($date) = @_;<br /><br /> return $date->printf("30 19 %d %m %a\troot\t/opt/balmo_id/run.sh");<br />}<br /><br />##MAIN##<br /><br />my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);<br /><br />my $date = new Date::Manip::Date;<br /><br />foreach my $month (@months) {<br /><br /> print "Month: $month\n";<br /><br /> # Get the last day of the month of current year.<br /> $date->parse("last day in $month");<br /><br /> print 'Last day of the month: ', $date->printf('%Y-%m-%d, %a'), "\n";<br /><br /> # Don't check time for business day.<br /> my $checktime = 0;<br /><br /> my $offset = 1;<br /> # Case of last day of the month is not a business day.<br /> if (!$date->is_business_day($checktime)) {<br /> $offset = 2;<br /> }<br /><br /> # The pevious day to last business day of the month.<br /> $date->prev_business_day($offset, $checktime);<br /><br /> print 'Previous business day: ', $date->printf('%Y-%m-%d, %a'), "\n";<br /><br /> # The CRON entry, use CRON: label to filter the cron entries<br /> # from the output.<br /> print "CRON: ", cron_entry($date), "\n";<br />}<br /><br />__END__</span></span></p>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-5055037763919949532021-07-03T06:50:00.006-04:002021-07-03T06:52:00.229-04:00SSH Passwordless Login Using SSH Keygen in 5 Easy Steps.<p> Step 1: Create Authentication SSH-Keygen Keys on the originating machine.<br /><br />$ ssh-keygen -t rsa<br /><br />On Windows you could use puttygen.exe<br /><br />Use a passphrase to protect keys.<br /><br />On Linux private key goes to .ssh/id_rsa<br />Public key goes to id_rsa.pub<br /><br />Step 2: Create .ssh Directory on the destination machine.<br /><br />Step 3: Upload Generated Public Keys to the destination machine.<br /><br />$ cat .ssh/id_rsa.pub | ssh <username>@<destination_ip> 'cat >> .ssh/authorized_keys'<br /><br /><username> should be the login on the destination machine.<br /><destination_ip> is the public IP of the destination machine.<br /><br />Step 4: Set Permissions on the destination machine.<br /><br />$ ssh <username>@<destination_ip> "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"<br /><br /><username> should be the login on the destination machine.<br /><destination_ip> is the public IP of the destination machine.<br /><br />Step 5: Login from originating machine to destination machine without password.<br /><br />$ ssh <username>@<destination_ip><br /><br /><username> should be the login on the destination machine.<br /><destination_ip> is the public IP of the destination machine.<br /><br />On Windows you could use putty.exe<br /><br />Taken from <a href="https://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/" rel="nofollow" target="_blank">https://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/<br /></a></p><p><br /></p>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-59915167864083853222021-02-28T10:33:00.004-05:002021-02-28T10:36:30.296-05:002021 Holiday Schedule<div style="text-align: left;">
<table class="DataTable" style="width: 100%;"><thead><tr><th scope="col">Date</th><th scope="col">Holiday</th></tr></thead><tbody>
<tr>
<td>Friday, January 1</td>
<td>New Year’s Day</td>
</tr>
<tr>
<td>Monday, January 18</td>
<td>Birthday of Martin Luther King, Jr.</td>
</tr>
<tr>
<td>Wednesday, January 20<span class="Footnote">*</span></td>
<td>Inauguration Day</td>
</tr>
<tr>
<td>Monday, February 15<span class="Footnote">**</span></td>
<td>Washington’s Birthday</td>
</tr>
<tr>
<td>Monday, May 31</td>
<td>Memorial Day</td>
</tr>
<tr>
<td>Monday, July 5<span class="Footnote">***</span></td>
<td>Independence Day</td>
</tr>
<tr>
<td>Monday, September 6</td>
<td>Labor Day</td>
</tr>
<tr>
<td>Monday, October 11</td>
<td>Columbus Day</td>
</tr>
<tr>
<td>Thursday, November 11</td>
<td>Veterans Day</td>
</tr>
<tr>
<td>Thursday, November 25</td>
<td>Thanksgiving Day</td>
</tr>
<tr>
<td>Friday, December 24<span class="Footnote">****</span></td>
<td>Christmas Day</td>
</tr>
</tbody></table>
<p class="Footnote"><span> *</span>This holiday is designated as
"Inauguration Day" in section 6103(c) of title 5 of the United States
Code, which is the law that specifies holidays for Federal employees.
Federal employees in the Washington, DC area are entitled to a holiday
on the day a President is inaugurated, January 20 for each fourth year
after 1965. Though other institutions such as state and local
governments and private businesses may use other names, it is our policy
to always refer to holidays by the names designated in the law.</p>
<p class="Footnote"><span>**</span>This holiday is designated as
"Washington’s Birthday" in section 6103(a) of title 5 of the United
States Code, which is the law that specifies holidays for Federal
employees. Though other institutions such as state and local governments
and private businesses may use other names, it is our policy to always
refer to holidays by the names designated in the law.</p>
<p class="Footnote"><span>***</span>July 4, 2021 (the legal public
holiday for Independence Day), falls on a Sunday. For most Federal
employees, Monday, July 5, will be treated as a holiday for pay and
leave purposes. (See 5 U.S.C. 6103(b).)</p>
<p class="Footnote"><span>****</span>December 25, 2021 (the legal public
holiday for Christmas Day), falls on a Saturday. For most Federal
employees, Friday, December 24, will be treated as a holiday for pay and
leave purposes. (See section 3(a) of Executive order 11582, February
11, 1971.) </p><p class="Footnote"> <i>Taken from: <a href="https://www.opm.gov/policy-data-oversight/pay-leave/federal-holidays/#url=2021">https://www.opm.gov/policy-data-oversight/pay-leave/federal-holidays/#url=2021</a></i><br /> <i><br /></i></p>
</div>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-61706280244596321922021-02-28T10:20:00.001-05:002021-02-28T10:21:16.904-05:00Capturing with Perl and REGEX two numbers on a line, one of them is optional<div style="text-align: left;"> <span style="font-family: courier;">#!/usr/bin/perl<br /><br />use strict;<br />use warnings;<br /><br />sub get_long_short {<br /> my ($number, $spaces1, $spaces2) = @_;<br /> my ($long, $short) = ('', '');<br /><br /> if (length($spaces1) > length($spaces2))<br /> {<br /> $short = $number;<br /> } else {<br /> $long = $number;<br /> }<br /><br /> return ($long, $short);<br />}<br /><br />while (<DATA>) {<br /><br /> chomp();<br /><br /> if (my ($b1, $n1, $n2, $b2, $s) = /<br /> ^(\s*) # First spaces ($b1)<br /> ([\d,.]+) # First number always exists ($n1)<br /> (?: # Don't want to capture spaces<br /> \s+ # in front<br /> ([\d,.]+) # Second number ($n2)<br /> )? # Second number is optional<br /> (\s+) # Space always exists ($b2)<br /> (\w{2,3})$ # Two or three letters symbol ($s)<br /> /x)<br /> {<br /> my ($long, $short);<br /><br /> if (defined($n2)) {<br /> $long = $n1;<br /> $short = $n2;<br /> } else {<br /> ($long, $short) = get_long_short($n1, $b1, $b2);<br /> }<br /><br /> $long =~ s/,//g;<br /> $short =~ s/,//g;<br /><br /> print("$long|$short|$s\n");<br /><br /> } else {<br /> print("NOT MATCHED: $_\n");<br /> }<br />}<br /><br />__END__<br />long short symbol<br />12 3 NG<br />1,234 1,222 CL<br />1,333 PL<br />123.4 9,088 HNG<br />123.4 9,088 BBBB<br /> 90.65 HO<br /> 1 RB<br /> 2 RB<br /> 3 RB<br />4 RB<br /> 100,000.00 CL<br /> CL<br /><br /></span></div>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com1tag:blogger.com,1999:blog-8373331533572215399.post-67362548065599623762021-01-18T14:20:00.002-05:002021-01-18T14:20:30.903-05:00isLeapYear in PHP<div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, 'Courier New', monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;"><div><span style="color: #6a9955;">// Returns TRUE if a year is a leap year</span></div><div><span style="color: #6a9955;">// The year must be evenly divisible by 4</span></div><div><span style="color: #6a9955;">// if the year can be evenly divisible by 100 is not a leap year</span></div><div><span style="color: #6a9955;">// unless it is also evenly divisible by 400 then it is a leap year</span></div><div><span style="color: #6a9955;">// https://en.wikipedia.org/wiki/Leap_year</span></div><div><span style="color: #569cd6;">public</span><span style="color: #d4d4d4;"> </span><span style="color: #569cd6;">static</span><span style="color: #d4d4d4;"> </span><span style="color: #569cd6;">function</span><span style="color: #d4d4d4;"> </span><span style="color: #dcdcaa;">isLeapYear</span><span style="color: #d4d4d4;">(</span><span style="color: #569cd6;">int</span><span style="color: #d4d4d4;"> </span><span style="color: #9cdcfe;">$year</span><span style="color: #d4d4d4;">):</span><span style="color: #569cd6;">bool</span><span style="color: #d4d4d4;"> {</span></div><div><span style="color: #d4d4d4;"> </span><span style="color: #c586c0;">return</span><span style="color: #d4d4d4;"> ((</span><span style="color: #9cdcfe;">$year</span><span style="color: #d4d4d4;"> % </span><span style="color: #b5cea8;">4</span><span style="color: #d4d4d4;"> == </span><span style="color: #b5cea8;">0</span><span style="color: #d4d4d4;">) && ((</span><span style="color: #9cdcfe;">$year</span><span style="color: #d4d4d4;"> % </span><span style="color: #b5cea8;">100</span><span style="color: #d4d4d4;"> != </span><span style="color: #b5cea8;">0</span><span style="color: #d4d4d4;">) || (</span><span style="color: #9cdcfe;">$year</span><span style="color: #d4d4d4;"> % </span><span style="color: #b5cea8;">400</span><span style="color: #d4d4d4;"> == </span><span style="color: #b5cea8;">0</span><span style="color: #d4d4d4;">)));</span></div><div><span style="color: #d4d4d4;">}</span></div></div><p> </p>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-72309474710919336002020-06-12T10:35:00.001-04:002020-06-12T10:38:10.274-04:00VBA Excel module for reading INI files.<span style="font-size: small;"><span style="font-family: "courier new" , "courier" , monospace;">Attribute VB_Name = "ReadINIFile"<br />Option Explicit<br /><br />' Retrieves a string from the specified section in an initialization file.<br />' See here: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getprivateprofilestring?redirectedfrom=MSDN<br />' lpApplicationName The name of the section containing the key name.<br />' lpKeyName The name of the key whose associated string is to be retrieved.<br />' lpDefault A default string.<br />' lpReturnedString A pointer to the buffer that receives the retrieved string.<br />' nSize The size of the buffer pointed to by the lpReturnedString parameter, in characters.<br />' lpFileName The name of the initialization file.<br /><br />Private Declare Function GetPrivateProfileString Lib "Kernel32" Alias "GetPrivateProfileStringA" ( _<br /> ByVal lpApplicationName As String, _<br /> ByVal lpKeyName As Any, _<br /> ByVal lpDefault As String, _<br /> ByVal lpReturnedString As String, _<br /> ByVal nSize As Long, _<br /> ByVal lpFileName As String) As Long<br /><br />' Given a key it returns the associated value from an INI file.<br />' iniFileName should specify a valid path.<br />' jesus.aneiros@gmail.com<br />' 2020.06.11<br />Public Function readIniFileString(ByVal iniFileName As String, ByVal sectionName As String, ByVal keyName As String) As String<br /><br /> Dim lResult As Long<br /> Dim retString As String * 255<br /> Dim retStringSize As Long<br /><br /> ' The buffer<br /> retString = Space(255)<br /> <br /> ' Returns the number of caracters copied to the buffer retString<br /> lResult = GetPrivateProfileString(sectionName, keyName, "", retString, Len(retString), iniFileName)<br /> <br /> If (lResult) Then<br /> readIniFileString = Left$(retString, lResult)<br /> Else<br /> readIniFileString = ""<br /> End If<br /><br />End Function<br /><br />Public Sub test()<br /> Debug.Print readIniFileString(ThisWorkbook.Path & "\model_c.ini", "DB", "host")<br /> Debug.Print readIniFileString(ThisWorkbook.Path & "\model_c.ini", "EMAIL", "host")<br />End Sub</span></span>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-30375372408566048252020-06-11T11:12:00.000-04:002020-06-11T11:14:18.211-04:00VBA Excel copy sheets from closed workbook<span style="font-family: "courier new" , "courier" , monospace;">Option Explicit<br /><br />' Copies sheets ranges (values and formats) from a closed workbook into<br />' a sheet on the opened workbook.<br />Private Sub copySheets(fileName As String, sheetName As String, dstSheetName As String, rng As String)<br /><br /> Sheets(dstSheetName).Cells.Clear<br /> <br /> Dim srcWB As Workbook<br /> <br /> ' Open the source workbook and copy the values<br /> Set srcWB = Workbooks.Open(fileName)<br /><br /> srcWB.Sheets(sheetName).Range(rng).Copy<br /><br /> ThisWorkbook.Activate<br /> <br /> ' Paste values and formats<br /> With Sheets(dstSheetName)<br /> .Range(rng).PasteSpecial Paste:=xlPasteFormats<br /> .Range(rng).PasteSpecial Paste:=xlPasteColumnWidths<br /> .Range(rng).PasteSpecial Paste:=xlPasteValuesAndNumberFormats<br /> End With<br /> <br /> ' Get out of the copy mode<br /> Application.CutCopyMode = False<br /> <br /> ' Close the source workbook without saving<br /> srcWB.Close savechanges:=False<br /><br />End Sub</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br />' An example of use </span><br />
<span style="font-family: "courier new" , "courier" , monospace;">Public Sub diff()<br /> Dim fileName As String<br /> <br /> ' Copy 2 sheets from 2 different files<br /> <br /> ' The first file<br /> ' Get the file names from a cell<br /> fileName = Sheets("Main").Range("B1").Value<br /> copySheets fileName, "Summary", "Summary", "A1:M26"<br /> copySheets fileName, "Day Positions", "DayPositions", "A1:N32"<br /> <br /> ' The second file<br /> fileName = Sheets("Main").Range("B2").Value<br /> copySheets fileName, "Summary", "SummaryNew", "A1:M26"<br /> copySheets fileName, "Day Positions", "DayPositionsNew", "A1:N32"<br /> <br /> ThisWorkbook.Sheets("Diff").Activate<br /> ThisWorkbook.Save<br /> <br />End Sub</span>J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-86269718988512072402020-04-04T09:48:00.000-04:002020-04-04T09:48:37.117-04:00Project Valhalla<br />
<div style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;">
</div>
<br />
<b>The OpenJDK page:</b><br />
<br />
<a href="http://openjdk.java.net/projects/valhalla/" rel="nofollow" target="_blank">http://openjdk.java.net/projects/valhalla/</a><br />
<br />
<b>State of Valhalla (Brian Goetz):</b><br />
<br />
<ol>
<li><a href="http://cr.openjdk.java.net/~briangoetz/valhalla/sov/01-background.html" rel="nofollow" target="_blank">The Road to Valhalla</a>.</li>
<li><a href="http://cr.openjdk.java.net/~briangoetz/valhalla/sov/02-object-model.html" rel="nofollow" target="_blank">Language Model</a>.</li>
<li><a href="http://cr.openjdk.java.net/~briangoetz/valhalla/sov/03-vm-model.html" rel="nofollow" target="_blank">JVM Model</a></li>
<li><a href="http://cr.openjdk.java.net/~briangoetz/valhalla/sov/04-translation.html" rel="nofollow" target="_blank">Translation Scheme</a>.</li>
</ol>
<br />
<i>Basically going from:</i><br />
<br />
<a href="http://cr.openjdk.java.net/~briangoetz/valhalla/sov/xy-points.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img alt="Layout of XY points" border="0" height="97" src="https://cr.openjdk.java.net/~briangoetz/valhalla/sov/xy-points.png" style="width: 100%;" width="320" /></a><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<i>To:</i><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://cr.openjdk.java.net/~briangoetz/valhalla/sov/flattened-points.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img alt="Flattened layout of XY points" border="0" height="200" src="https://cr.openjdk.java.net/~briangoetz/valhalla/sov/flattened-points.png" style="width: 60%;" width="131" /></a></div>
<br />J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-52729920971810756972020-01-13T10:23:00.000-05:002020-01-13T10:25:30.942-05:002020 Holiday Schedule <table><thead>
<tr><th>Date</th><th>Holiday</th></tr>
</thead>
<tbody>
<tr>
<td>Wednesday, January 1</td>
<td>New Year’s Day</td>
</tr>
<tr>
<td>Monday, January 20</td>
<td>Birthday of Martin Luther King, Jr.</td>
</tr>
<tr>
<td>Monday, February 17<span class="Footnote">*</span></td>
<td>Washington’s Birthday</td>
</tr>
<tr>
<td>Monday, May 25</td>
<td>Memorial Day</td>
</tr>
<tr>
<td>Friday, July 3<span class="Footnote">**</span></td>
<td>Independence Day</td>
</tr>
<tr>
<td>Monday, September 7</td>
<td>Labor Day</td>
</tr>
<tr>
<td>Monday, October 12</td>
<td>Columbus Day</td>
</tr>
<tr>
<td>Wednesday, November 11</td>
<td>Veterans Day</td>
</tr>
<tr>
<td>Thursday, November 26</td>
<td>Thanksgiving Day</td>
</tr>
<tr>
<td>Friday, December 25</td>
<td>Christmas Day</td>
</tr>
</tbody>
</table>
<div class="Footnote">
<br /></div>
<div class="Footnote">
*This holiday is designated as
"Washington’s Birthday" in section 6103(a) of title 5 of the United
States Code, which is the law that specifies holidays for Federal
employees. Though other institutions such as state and local governments
and private businesses may use other names, it is our policy to always
refer to holidays by the names designated in the law.</div>
<div class="Footnote">
<br />
**July 4, 2020 (the legal public
holiday for Independence Day), falls on a Saturday. For most Federal
employees, Friday, July 3, will be treated as a holiday for pay and
leave purposes. (See 5 U.S.C. 6103(b).)</div>
J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-64563788153573261792019-05-31T15:46:00.001-04:002019-05-31T15:46:48.526-04:00GNU date and relatives datesI was writing a simple script to delete some log files, all the log filenames contain the date of creation in the form YYYYMMDD and I needed to delete the files from previous month keeping the current month. The script will run on the last day of every month.<br /><br />I thought the task will be very easy as I could use the GNU date command to build the date string, something like:<br /><br /># The year<br />date +%Y<br /><br />Use the date relative option for getting the previous month, something like:<br /><br />date --date="-1 month" +%m<br /><br />Then concatenate both strings and build a file pattern using wildcards like ? and *.<br /><br />The system date was 2019-05-31 ahd I was expecting the 04 string as the output, instead 05 was printed.<br /><br />I tried several variants and all printed the same, 05:<br /><br />$ date --date="-1 month" +%m<br />05<br /><br />$ date --date="last month" +%m<br />05<br /><br />I DuckDuckGoed the Internet and found this answer:<br /><br /><a href="https://stackoverflow.com/questions/13168463/using-date-command-to-get-previous-current-and-next-month" rel="nofollow" target="_blank">https://stackoverflow.com/questions/13168463/using-date-command-to-get-previous-current-and-next-month</a><br /><br />This is from the coreutils manual online:<br /><br /><a href="https://www.gnu.org/software/coreutils/manual/html_node/Relative-items-in-date-strings.html#Relative-items-in-date-strings" rel="nofollow" target="_blank">https://www.gnu.org/software/coreutils/manual/html_node/Relative-items-in-date-strings.html#Relative-items-in-date-strings</a><br /><br />$ date --date="$(date +%Y%m15) -1 month" +%m<br />04<br />J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-15565758232687267022019-05-08T12:11:00.000-04:002019-05-08T12:12:22.395-04:00PDFs don't open automatically in Chrome<h1 style="-webkit-text-stroke-width: 0px; background-color: white; color: #202124; font-family: "Google Sans", Roboto, sans-serif; font-size: 2rem; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 2.5rem; margin: 0px 0px 0.5rem; orphans: 2; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
</h1>
<div class="cc" style="-webkit-text-stroke-width: 0px; background-color: white; color: #3c4043; font-family: Roboto, "Helvetica Neue", Helvetica, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; orphans: 2; outline: none; overflow-wrap: break-word; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<div style="margin: 0.25rem 0px 0.75rem;">
</div>
<div style="margin: 0.25rem 0px 0.75rem;">
You can normally open PDFs automatically in Chrome by clicking on the file you want to see. If your PDFs are downloading instead of opening automatically in Chrome, Chrome PDF viewer could be turned off.</div>
<h2 style="color: #202124; font-family: "Google Sans", Roboto, sans-serif; font-size: 1.5rem; font-weight: 400; line-height: 2rem; margin: 2rem 0px 0.5rem;">
Open PDFs in Chrome</h2>
<ol style="margin: 0.25rem 0px 0.75rem; outline: 0px; padding: 0px; vertical-align: baseline;">
<li style="margin: 0.25rem 0px 0.25rem 1.25rem;">On your computer, open Chrome.</li>
<li style="margin: 0.25rem 0px 0.25rem 1.25rem;">At the top right, click More <img alt="More" height="18" src="https://storage.googleapis.com/support-kms-prod/ArAlBcUAe8h1l5m69uxnwElxkqwW0QdtIc3F" style="max-width: 100%; vertical-align: middle;" title="More" width="18" /> <img alt="and then" height="18" src="https://lh3.googleusercontent.com/nHFGZ_9xjCh-mP83zMzXQVJF5VYf2n6kwoBIxB2zv3V4VPT4gNTtBye8lYznogLqLPY=w13-h18" style="max-width: 100%; vertical-align: middle;" title="and then" width="13" /> <b style="font-weight: 500;">Settings</b>.</li>
<li style="margin: 0.25rem 0px 0.25rem 1.25rem;">At the bottom, click <b style="font-weight: 500;">Advanced</b>.</li>
<li style="margin: 0.25rem 0px 0.25rem 1.25rem;">Under "Privacy and security," click <b style="font-weight: 500;">Site settings</b>.</li>
<li style="margin: 0.25rem 0px 0.25rem 1.25rem;">Near the bottom, click <b style="font-weight: 500;">PDF documents</b>.</li>
<li style="margin: 0.25rem 0px 0.25rem 1.25rem;">Turn off <b style="font-weight: 500;">Download PDF files instead of automatically opening them in Chrome</b>.</li>
</ol>
<div style="margin: 0.25rem 0px 0.75rem;">
Chrome will now open PDFs automatically when you click them.</div>
<div style="margin: 0.25rem 0px 0.75rem;">
Taken from:<i> <a href="https://support.google.com/chrome/answer/6213030?hl=en" rel="nofollow" target="_blank">https://support.google.com/chrome/answer/6213030?hl=en</a></i> </div>
<div style="margin: 0.25rem 0px 0.75rem;">
<br /></div>
</div>
J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-86755183113736596662019-03-04T11:29:00.000-05:002019-03-04T11:29:02.373-05:002019 Holiday Schedule<div class="ContentBody">
<table class="DataTable" style="width: 70%;">
<thead>
<tr><th scope="col">Date</th><th scope="col">Holiday</th></tr>
</thead>
<tbody>
<tr>
<td>Tuesday, January 1</td>
<td>New Year’s Day</td>
</tr>
<tr>
<td>Monday, January 21</td>
<td>Birthday of Martin Luther King, Jr.</td>
</tr>
<tr>
<td>Monday, February 18<span class="Footnote">*</span></td>
<td>Washington’s Birthday</td>
</tr>
<tr>
<td>Monday, May 27</td>
<td>Memorial Day</td>
</tr>
<tr>
<td>Thursday, July 4</td>
<td>Independence Day</td>
</tr>
<tr>
<td>Monday, September 2</td>
<td>Labor Day</td>
</tr>
<tr>
<td>Monday, October 14</td>
<td>Columbus Day</td>
</tr>
<tr>
<td>Monday, November 11</td>
<td>Veterans Day</td>
</tr>
<tr>
<td>Thursday, November 28</td>
<td>Thanksgiving Day</td>
</tr>
<tr>
<td>Wednesday, December 25</td>
<td>Christmas Day</td>
</tr>
</tbody>
</table>
<div class="Footnote">
<br />
*This holiday is designated as
"Washington’s Birthday" in section 6103(a) of title 5 of the United
States Code, which is the law that specifies holidays for Federal
employees. Though other institutions such as state and local governments
and private businesses may use other names, it is our policy to always
refer to holidays by the names designated in the law.<br />
<br />
<i>Taken from: <a href="https://www.opm.gov/policy-data-oversight/snow-dismissal-procedures/federal-holidays/#url=2019" rel="nofollow" target="_blank">https://www.opm.gov/policy-data-oversight/snow-dismissal-procedures/federal-holidays/#url=2019</a></i><br />
<i> </i></div>
</div>
J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-61372225556693348282018-10-01T10:24:00.003-04:002018-10-03T08:59:19.035-04:00How to Find Multiple Missing Integers in Given Array With Duplicates in Java?<br />
I found this interesting problem here: <br />
<a href="https://javarevisited.blogspot.com/2014/11/how-to-find-missing-number-on-integer-array-java.html" rel="nofollow" target="_blank">https://javarevisited.blogspot.com/2014/11/how-to-find-missing-number-on-integer-array-java.html</a><br />
but I think the solution is too long, see mine below:<br />
<br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;">import java.util.Arrays;<br />import java.util.HashSet;<br />import java.util.Set;<br />import java.util.stream.Collectors;<br />import java.util.stream.IntStream;<br /><br />public class MissingIntegers {<br /><br /> public static void main(String[] args) {<br /> <br /> Set<Integer> s1 = new HashSet<>(Arrays.asList(new Integer[]{1, 2, 3, 4, 9, 8}));<br /> Set<Integer> s2 = new HashSet<>(IntStream.rangeClosed(1, 10).boxed().collect(Collectors.toList()));<br /><br /> s2.removeAll(s1);<br /> System.out.println(s2);<br /> }<br /> <br />}</span></span><br />
<br />
In fact we don't need the intermediate List in the case of Set 2, we can use the toCollection method of Collectors:<br />
<br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;">Set<Integer> s2 = IntStream.rangeClosed(1, 10).boxed().collect(Collectors.toCollection(HashSet::new));</span></span><br />
<br />
Next day I came up with another solution:<br />
<br />
<span style="font-size: x-small;"><span style="font-family: "Courier New", Courier, monospace;">import java.util.ArrayList;<br />import java.util.Arrays;<br />import java.util.List;<br />import java.util.stream.Collectors;<br />import java.util.stream.IntStream;<br /><br />public class MissingIntegers {<br /><br /> public static void main(String[] args) {<br /> <br /> List<Integer> L1 = Arrays.asList(new Integer[]{1, 2, 3, 4, 9, 2, 8});<br /> List<Integer> L2 = IntStream.rangeClosed(1, 10).boxed().collect(Collectors.toCollection(ArrayList::new));<br /> <br /> L2.removeAll(L1);<br /> System.out.println(L2);<br /> }<br /> <br />}</span></span><br />
<br />J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-76300229509667794132018-08-31T12:39:00.000-04:002018-10-01T10:58:30.958-04:00Using Apache Ant in NetbeansThe following ant code is run inside the -post-jar target in a Netbeans Java project.<br />
<br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"><!--<br /> Copy the .jar file and the zipped directory dist<br /> to deploy folder in Z: drive</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;">--></span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"><br /><echo message="Zip and copy: ${application.title}" /><br /> <br /><!--<br /> A file name property for the zip file we are going to create<br />--><br /><local name="zipfile" /><br /><property name="zipfile" value="${application.title}-dist.zip" /><br /><br /><!-- The creation of the zip file --><br /><zip destfile="${zipfile}"><br /> <fileset dir="${dist.dir}/" /><br /></zip><br /> <br /><!-- Copying the 2 files --><br /> <copy todir="Z:/deploy" overwrite="true"><br /> <resources><br /> <file file="${dist.jar}" /><br /> <file file="${zipfile}" /><br /> </resources><br /> </copy><br /><br /><delete file="${zipfile}" /><br /> <br /><!-- End of the copy --></span></span><br />
<br />
<br />J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0tag:blogger.com,1999:blog-8373331533572215399.post-30599605306409891822018-03-27T14:24:00.003-04:002018-03-27T14:24:37.779-04:00Style Guidelines for Local Variable Type Inference in Java<br />
Stuart W. Marks just published a very useful guidelines for the use of the newly introduced local variable type inference in Java 10:<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="background-color: yellow;">var</span> list = List.of("One", "Two", 3);</span><br />
<br />
<a href="http://openjdk.java.net/projects/amber/LVTIstyle.html" rel="nofollow" target="_blank"><i>http://openjdk.java.net/projects/amber/LVTIstyle.html</i></a><br />
<br />
<br />J. Ernesto Aneiroshttp://www.blogger.com/profile/15587633878909019151noreply@blogger.com0