Wednesday, December 13, 2023

Federal Holidays 2023

 

Date Holiday
Monday, January 02 * New Year’s Day
Monday, January 16 Birthday of Martin Luther King, Jr.
Monday, February 20 ** Washington’s Birthday
Monday, May 29 Memorial Day
Monday, June 19 Juneteenth National Independence Day
Tuesday, July 04 Independence Day
Monday, September 04 Labor Day
Monday, October 09 Columbus Day
Friday, November 10 * Veterans Day
Thursday, November 23 Thanksgiving Day
Monday, December 25 Christmas Day

*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.

**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.

Taken from: https://www.opm.gov/policy-data-oversight/pay-leave/federal-holidays/#url=2023

 

Friday, November 25, 2022

King, Bishop and Knight against King Endgame

64board
 
 
The purpose of this post is to put together some resources about this particular endgame.

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.

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.

The best explanation I found about this checkmate is in the book "Fundamental Chess Endings" by Karsten Muller and Frank Lamprecht. There is an Amazon paperback version and a cheaper Kindle one.

This is a very well explained YouTube video about the KBNK checkmate https://youtu.be/oRK7XLhGz_c

The following link will allow you to practice against the lichess engine. The method they explain is called Deletang's triangles, from the name of the person that formalized it. https://lichess.org/practice/checkmates/knight--bishop-mate/ByhlXnmM/D23EYigW

Personally I prefer Phillidor's method using the Knight's W route.

At chess.com 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, https://www.chess.com/variants/custom

When perfectioning your endgame technique I found the following link to tablebases online very useful: https://www.shredderchess.com/online/endgame-database.html

For example the following endgame requires 30 moves with perfect play:

Since August 2021 chess.com also provide the tablebase feature, see announcement: https://www.chess.com/news/view/chesscom-announces-new-tablebase-feature

(This is a work in progress)

Thursday, May 5, 2022

2022 Holiday Schedule

Date Holiday
Friday, December 31 *         New Year's Day
Monday, January 17         Birthday of Martin Luther King, Jr.
Monday, February 21 **         Washington’s Birthday
Monday, May 30         Memorial Day
Monday, June 20 *         Juneteenth National Independence Day
Monday, July 04         Independence Day
Monday, September 05         Labor Day
Monday, October 10         Columbus Day
Friday, November 11         Veterans Day
Thursday, November 24         Thanksgiving Day
Monday, December 26 *         Christmas Day

*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.

**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.

https://www.opm.gov/policy-data-oversight/pay-leave/federal-holidays/#url=2022

Wednesday, December 29, 2021

Chess 960 posible starting positions

Examples in several programming languages
http://rosettacode.org/wiki/Generate_Chess960_starting_position

All the positions with the standard ID number
https://chess960.net/wp-content/uploads/2018/02/chess960-starting-positions.pdf

https://www.chessprogramming.org/Chess960

https://github.com/MichaelB7/Chess960-Lookup/blob/master/src/960v09.c

https://en.wikipedia.org/wiki/Fischer_Random_Chess_starting_position

Very good explanation of the rules
https://codegolf.stackexchange.com/questions/12322/chess960-position-lookup/12333#12333

B   B   Q   N   N   R K R
4 * 4 * 6 * 5 * 4 * 1     = 1920

Bishops have to be of different colors (4 black squares, 4 whites squares).

There is only 1 possible position for the King and Rooks because it has to go
between the Rooks and there are only 3 squares available at that time.

Because the Knights change color when they move they could be interchanged
without any difference then 5 * 4 should be divided by 2 then
total number of positions = 960.

Tmux commands

# List sessions
# Alias ls
tmux list-sessions
tmux ls

# Create new session
# It is good practice to name sessions
tmux new -s right_window

# Detach a session
Ctrl-b d

# Attach a session using name
tmux a -t right_window

# Use mouse to select pane
Ctrl-b :
# then type
set -g mouse on

# Zoom a pane
Ctrl-b z

# Scroll
Ctrl-b [
# Quit
q

Backup bash script

https://github.com/64board/Bash/blob/main/backup.sh

 

Perl sort example

Sorting in Perl with user defined subroutines.

https://github.com/64board/Perl/blob/main/sort.pl

Perl Getopt::Std example

Example of using Getopt::Std module.

https://github.com/64board/Perl/blob/main/get_opt.pl

Tuesday, August 31, 2021

Perl Date::Manip::Date business day

 #!/usr/bin/perl

# Creates /etc/cron.d file entries, one per month,
# for a program that should run on the previous
# day to last business day of the month.
# Uses Date::Manip::Date module, https://metacpan.org/dist/Date-Manip/view/lib/Date/Manip/Date.pod.
# 64board@gmail.com
# 2021-08-31
 
use strict;
use warnings;

use Date::Manip::Date;

sub cron_entry {

    my ($date) = @_;

    return $date->printf("30 19 %d %m %a\troot\t/opt/balmo_id/run.sh");
}

##MAIN##

my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);

my $date = new Date::Manip::Date;

foreach my $month (@months) {

    print "Month: $month\n";

    # Get the last day of the month of current year.
    $date->parse("last day in $month");

    print 'Last day of the month: ', $date->printf('%Y-%m-%d, %a'), "\n";

    # Don't check time for business day.
    my $checktime = 0;

    my $offset = 1;
    # Case of last day of the month is not a business day.
    if (!$date->is_business_day($checktime)) {
    $offset = 2;
    }

    # The pevious day to last business day of the month.
    $date->prev_business_day($offset, $checktime);

    print 'Previous business day: ', $date->printf('%Y-%m-%d, %a'), "\n";

    # The CRON entry, use CRON: label to filter the cron entries
    # from the output.
    print "CRON: ", cron_entry($date), "\n";
}

__END__

Saturday, July 3, 2021

SSH Passwordless Login Using SSH Keygen in 5 Easy Steps.

 Step 1: Create Authentication SSH-Keygen Keys on the originating machine.

$ ssh-keygen -t rsa

On Windows you could use puttygen.exe

Use a passphrase to protect keys.

On Linux private key goes to .ssh/id_rsa
Public key goes to id_rsa.pub

Step 2: Create .ssh Directory on the destination machine.

Step 3: Upload Generated Public Keys to the destination machine.

$ cat .ssh/id_rsa.pub | ssh <username>@<destination_ip> 'cat >> .ssh/authorized_keys'

<username> should be the login on the destination machine.
<destination_ip> is the public IP of the destination machine.

Step 4: Set Permissions on the destination machine.

$ ssh <username>@<destination_ip> "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"

<username> should be the login on the destination machine.
<destination_ip> is the public IP of the destination machine.

Step 5: Login from originating machine to destination machine without password.

$ ssh <username>@<destination_ip>

<username> should be the login on the destination machine.
<destination_ip> is the public IP of the destination machine.

On Windows you could use putty.exe

Taken from https://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/


Sunday, February 28, 2021

2021 Holiday Schedule

DateHoliday
Friday, January 1 New Year’s Day
Monday, January 18 Birthday of Martin Luther King, Jr.
Wednesday, January 20* Inauguration Day
Monday, February 15** Washington’s Birthday
Monday, May 31 Memorial Day
Monday, July 5*** Independence Day
Monday, September 6 Labor Day
Monday, October 11 Columbus Day
Thursday, November 11 Veterans Day
Thursday, November 25 Thanksgiving Day
Friday, December 24**** Christmas Day

 *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.

**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.

***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).)

****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.) 

 Taken from:  https://www.opm.gov/policy-data-oversight/pay-leave/federal-holidays/#url=2021
 

Capturing with Perl and REGEX two numbers on a line, one of them is optional

 #!/usr/bin/perl

use strict;
use warnings;

sub get_long_short {
   my ($number, $spaces1, $spaces2) = @_;
   my ($long, $short) = ('', '');

   if (length($spaces1) > length($spaces2))
   {
      $short = $number;
   } else {
      $long = $number;
   }

   return ($long, $short);
}

while (<DATA>) {

   chomp();

   if (my ($b1, $n1, $n2, $b2, $s) = /
      ^(\s*)            # First spaces ($b1)
      ([\d,.]+)         # First number always exists ($n1)
      (?:               # Don't want to capture spaces
      \s+               # in front
      ([\d,.]+)         # Second number ($n2)
      )?                # Second number is optional
      (\s+)             # Space always exists ($b2)
      (\w{2,3})$        # Two or three letters symbol ($s)
      /x)
   {
      my ($long, $short);

      if (defined($n2)) {
         $long = $n1;
         $short = $n2;
      } else {
         ($long, $short) = get_long_short($n1, $b1, $b2);
      }

      $long =~ s/,//g;
      $short =~ s/,//g;

      print("$long|$short|$s\n");

   } else {
      print("NOT MATCHED: $_\n");
   }
}

__END__
long short symbol
12 3  NG
1,234 1,222 CL
1,333       PL
123.4 9,088     HNG
123.4 9,088     BBBB
       90.65 HO
   1   RB
    2  RB
     3 RB
4      RB
  100,000.00     CL
  CL

Monday, January 18, 2021

isLeapYear in PHP

// Returns TRUE if a year is a leap year
// The year must be evenly divisible by 4
// if the year can be evenly divisible by 100 is not a leap year
// unless it is also evenly divisible by 400 then it is a leap year
// https://en.wikipedia.org/wiki/Leap_year
public static function isLeapYear(int $year):bool {
    return (($year % 4 == 0) && (($year % 100 != 0) || ($year % 400 == 0)));
}

 

Friday, June 12, 2020

VBA Excel module for reading INI files.

Attribute VB_Name = "ReadINIFile"
Option Explicit

' Retrieves a string from the specified section in an initialization file.
' See here: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getprivateprofilestring?redirectedfrom=MSDN
' lpApplicationName     The name of the section containing the key name.
' lpKeyName             The name of the key whose associated string is to be retrieved.
' lpDefault             A default string.
' lpReturnedString      A pointer to the buffer that receives the retrieved string.
' nSize                 The size of the buffer pointed to by the lpReturnedString parameter, in characters.
' lpFileName            The name of the initialization file.

Private Declare Function GetPrivateProfileString Lib "Kernel32" Alias "GetPrivateProfileStringA" ( _
    ByVal lpApplicationName As String, _
    ByVal lpKeyName As Any, _
    ByVal lpDefault As String, _
    ByVal lpReturnedString As String, _
    ByVal nSize As Long, _
    ByVal lpFileName As String) As Long

' Given a key it returns the associated value from an INI file.
' iniFileName should specify a valid path.
' jesus.aneiros@gmail.com
' 2020.06.11
Public Function readIniFileString(ByVal iniFileName As String, ByVal sectionName As String, ByVal keyName As String) As String

    Dim lResult As Long
    Dim retString As String * 255
    Dim retStringSize As Long

    ' The buffer
    retString = Space(255)
       
    ' Returns the number of caracters copied to the buffer retString
    lResult = GetPrivateProfileString(sectionName, keyName, "", retString, Len(retString), iniFileName)
       
    If (lResult) Then
        readIniFileString = Left$(retString, lResult)
    Else
        readIniFileString = ""
    End If

End Function

Public Sub test()
    Debug.Print readIniFileString(ThisWorkbook.Path & "\model_c.ini", "DB", "host")
    Debug.Print readIniFileString(ThisWorkbook.Path & "\model_c.ini", "EMAIL", "host")
End Sub

Thursday, June 11, 2020

VBA Excel copy sheets from closed workbook

Option Explicit

' Copies sheets ranges (values and formats) from a closed workbook into
' a sheet on the opened workbook.
Private Sub copySheets(fileName As String, sheetName As String, dstSheetName As String, rng As String)

    Sheets(dstSheetName).Cells.Clear
   
    Dim srcWB As Workbook
   
    ' Open the source workbook and copy the values
    Set srcWB = Workbooks.Open(fileName)

    srcWB.Sheets(sheetName).Range(rng).Copy

    ThisWorkbook.Activate
   
    ' Paste values and formats
    With Sheets(dstSheetName)
        .Range(rng).PasteSpecial Paste:=xlPasteFormats
        .Range(rng).PasteSpecial Paste:=xlPasteColumnWidths
        .Range(rng).PasteSpecial Paste:=xlPasteValuesAndNumberFormats
    End With
   
    ' Get out of the copy mode
    Application.CutCopyMode = False
   
    ' Close the source workbook without saving
    srcWB.Close savechanges:=False

End Sub



' An example of use

Public Sub diff()
    Dim fileName As String
   
    ' Copy 2 sheets from 2 different files
   
    ' The first file
    ' Get the file names from a cell
    fileName = Sheets("Main").Range("B1").Value
    copySheets fileName, "Summary", "Summary", "A1:M26"
    copySheets fileName, "Day Positions", "DayPositions", "A1:N32"
   
    ' The second file
    fileName = Sheets("Main").Range("B2").Value
    copySheets fileName, "Summary", "SummaryNew", "A1:M26"
    copySheets fileName, "Day Positions", "DayPositionsNew", "A1:N32"
   
    ThisWorkbook.Sheets("Diff").Activate
    ThisWorkbook.Save
   
End Sub

Saturday, April 4, 2020

Monday, January 13, 2020

2020 Holiday Schedule

DateHoliday
Wednesday, January 1 New Year’s Day
Monday, January 20 Birthday of Martin Luther King, Jr.
Monday, February 17* Washington’s Birthday
Monday, May 25 Memorial Day
Friday, July 3** Independence Day
Monday, September 7 Labor Day
Monday, October 12 Columbus Day
Wednesday, November 11 Veterans Day
Thursday, November 26 Thanksgiving Day
Friday, December 25 Christmas Day

*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.

**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).)

Friday, May 31, 2019

GNU date and relatives dates

I 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.

I thought the task will be very easy as I could use the GNU date command to build the date string, something like:

# The year
date +%Y

Use the date relative option for getting the previous month, something like:

date --date="-1 month" +%m

Then concatenate both strings and build a file pattern using wildcards like ? and *.

The system date was 2019-05-31 ahd I was expecting the 04 string as the output, instead 05 was printed.

I tried several variants and all printed the same, 05:

$ date --date="-1 month" +%m
05

$ date --date="last month" +%m
05

I DuckDuckGoed the Internet and found this answer:

https://stackoverflow.com/questions/13168463/using-date-command-to-get-previous-current-and-next-month

This is from the coreutils manual online:

https://www.gnu.org/software/coreutils/manual/html_node/Relative-items-in-date-strings.html#Relative-items-in-date-strings

$ date --date="$(date +%Y%m15) -1 month" +%m
04

Wednesday, May 8, 2019

PDFs don't open automatically in Chrome

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.

Open PDFs in Chrome

  1. On your computer, open Chrome.
  2. At the top right, click More More and then Settings.
  3. At the bottom, click Advanced.
  4. Under "Privacy and security," click Site settings.
  5. Near the bottom, click PDF documents.
  6. Turn off Download PDF files instead of automatically opening them in Chrome.
Chrome will now open PDFs automatically when you click them.

Monday, March 4, 2019

2019 Holiday Schedule

DateHoliday
Tuesday, January 1 New Year’s Day
Monday, January 21 Birthday of Martin Luther King, Jr.
Monday, February 18* Washington’s Birthday
Monday, May 27 Memorial Day
Thursday, July 4 Independence Day
Monday, September 2 Labor Day
Monday, October 14 Columbus Day
Monday, November 11 Veterans Day
Thursday, November 28 Thanksgiving Day
Wednesday, December 25 Christmas Day

*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.

Taken from:  https://www.opm.gov/policy-data-oversight/snow-dismissal-procedures/federal-holidays/#url=2019