The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Create A KSUID For A Specific Date In Python

TODO: Pull subtitle into page object

NOTE: I'm using `ulid` now instead of `ksuid` since it allows going back to epoch (Jan. 1, 1970) instead of KSUID's epock of May 2014.

NOTE: I need to go back and review this one

NOTE: KSUIDs epoch is May 13th, 2014. You can't go before that. They run out in somewhere over 100 years too. Less of a problem there, but something to know.

code_start_default_section code_end_default_section
Results
0wRwD3sllvzEOg53Grv73EA5815
  0wRwD3sllvzE

(NOTE: Be cafeful if you try the ruby version. I got incorrect dates when examining the values)

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Create A KSUID For A Specific Date In Python

-- p

NOTE: I'm using `ulid` now instead of `ksuid` since
it allows going back to epoch (Jan. 1, 1970) instead
of KSUID's epock of May 2014.

-- p

NOTE: I need to go back and review this one

-- p

NOTE: KSUIDs epoch is May 13th, 2014. You can't go before that.
They run out in somewhere over 100 years too. Less of a problem
there, but something to know.

-- code/
-- shell

python3 -i -c "from ksuid import Ksuid; from datetime import datetime; datetime = datetime(year=2015, month=1, day=1, hour=10, minute=22, second=13); print(Ksuid(datetime))"

-- /code

-- results/

0AbwgV4iNcd543b9khXluR2QJj7

-- /results

-- p

The <<link|original ksuid package|https://github.com/segmentio/ksuid>> doesn't
have a way to generate KSUIDs for a specific date. I need that feature
to go back and add KSUIDs to my previous notes/posts.

-- p

This <<link|python module|https://github.com/svix/python-ksuid>> provides the
functionality.

-- p

Install with:

-- code/
-- python

pip install svix-ksuid

-- /code

-- p

And then run it with:

-- code/
-- python

from ksuid import Ksuid
  from datetime import datetime

  year = 2017
  month = 11
  day = 16 
  hour = 12 
  minute = 0
  second = 0 

  datetime = datetime(year=year, month=month, day=day, hour=hour, minute=minute, second=second)

  the_id = Ksuid(datetime)

  print(the_id)

  # This 12 character version is what I use for the slugs on my site
  print(str(the_id)[0:12])

-- /code

-- results/

0wRwD3sllvzEOg53Grv73EA5815
  0wRwD3sllvzE

-- /results

-- p

(NOTE: Be cafeful if you try the <<link|ruby version|https://www.rubydoc.info/gems/ksuid>>. I got incorrect dates
when examining the values)


-- categories
-- Python 

-- metadata
-- date: 2022-05-29 13:46:02
-- id: 29qh8qmd
-- status: scratch 
-- type: post
-- SCRUBBED_NEO: false
-- site: aws