Discussion:
Where are you, sdb? I have something fun for your little morons to try
(too old to reply)
DFS
2016-12-07 17:27:40 UTC
Permalink
Get the min and max from a list of dates formatted like this:

10-Mar-1998
20-Aug-1997
06-Sep-2009
23-Jan-2010
05-Nov-2010
03-Sep-2009
07-Nov-2014
08-Mar-2013


My 5-line solution (python data structures only)
----------------------------------------------------------------
dt=['10-Mar-1998','20-Aug-1997','06-Sep-2009','23-Jan-2010','05-Nov-2010','03-Sep-2009','07-Nov-2014','08-Mar-2013']
m=[('Dec','12'),('Nov','11'),('Oct','10'),('Sep','09'),('Aug','08'),('Jul','07'),('Jun','06'),('May','05'),('Apr','04'),('Mar','03'),('Feb','02'),('Jan','01')]
dt2=[]
for d in dt:dt2.append((d[-4:]+dict(m)[d[3:6]]+d[:2],d))
print min(dt2)[1]+'\n'+max(dt2)[1]
----------------------------------------------------------------
$python getminmax.py
20-Aug-1997
07-Nov-2014


<quote>
My children, both were introduced to Linux when in grade 9-10.
By the time they left high school they were capable of installing and
configuring their own Linux systems. Now they are in university, one
is in 4th year doing mathematics concentrating on discrete
mathematics, hoping to do masters in AI. The other is in 3rd year CS.

They can both code circles around you.
</quote>


Bring those little idiots on! If they can code circles around me, they
can replicate that functionality in another language, in approx the same
# of lines, using only builtin data structures.
deplorable owl
2016-12-07 19:52:23 UTC
Permalink
Post by DFS
10-Mar-1998
20-Aug-1997
06-Sep-2009
23-Jan-2010
05-Nov-2010
03-Sep-2009
07-Nov-2014
08-Mar-2013
My 5-line solution (python data structures only)
----------------------------------------------------------------
dt=['10-Mar-1998','20-Aug-1997','06-Sep-2009','23-Jan-2010','05-Nov-2010','03-Sep-2009','07-Nov-2014','08-Mar-2013']
m=[('Dec','12'),('Nov','11'),('Oct','10'),('Sep','09'),('Aug','08'),('Jul','07'),('Jun','06'),('May','05'),('Apr','04'),('Mar','03'),('Feb','02'),('Jan','01')]
dt2=[]
for d in dt:dt2.append((d[-4:]+dict(m)[d[3:6]]+d[:2],d))
print min(dt2)[1]+'\n'+max(dt2)[1]
----------------------------------------------------------------
$python getminmax.py
20-Aug-1997
07-Nov-2014
<quote>
My children, both were introduced to Linux when in grade 9-10.
By the time they left high school they were capable of installing and
configuring their own Linux systems. Now they are in university, one
is in 4th year doing mathematics concentrating on discrete
mathematics, hoping to do masters in AI. The other is in 3rd year CS.
They can both code circles around you.
</quote>
Bring those little idiots on! If they can code circles around me, they
can replicate that functionality in another language, in approx the same
# of lines, using only builtin data structures.
pwned.

Bash one-liner:
***@lowtide:~/code/dfsdates$ wc -l blah
1 blah
***@lowtide:~/code/dfsdates$ . blah
20-Aug-1997
07-Nov-2014
***@lowtide:~/code/dfsdates$ cat blah
dt=(10-Mar-1998 20-Aug-1997 06-Sep-2009 23-Jan-2010 05-Nov-2010 03-Sep-2009 07-Nov-2014 08-Mar-2013); function sortdates { for i in $(printf '%s\n' "${dt[@]}");do date -d ${i} +%s;done|sort -n; }; date -d @$(sortdates|head -n 1) +%d-%b-%Y; date -d @$(sortdates|tail -n 1) +%d-%b-%Y
***@lowtide:~/code/dfsdates$
DFS
2016-12-08 02:28:07 UTC
Permalink
Post by deplorable owl
Post by DFS
10-Mar-1998
20-Aug-1997
06-Sep-2009
23-Jan-2010
05-Nov-2010
03-Sep-2009
07-Nov-2014
08-Mar-2013
My 5-line solution (python data structures only)
----------------------------------------------------------------
dt=['10-Mar-1998','20-Aug-1997','06-Sep-2009','23-Jan-2010','05-Nov-2010','03-Sep-2009','07-Nov-2014','08-Mar-2013']
m=[('Dec','12'),('Nov','11'),('Oct','10'),('Sep','09'),('Aug','08'),('Jul','07'),('Jun','06'),('May','05'),('Apr','04'),('Mar','03'),('Feb','02'),('Jan','01')]
dt2=[]
for d in dt:dt2.append((d[-4:]+dict(m)[d[3:6]]+d[:2],d))
print min(dt2)[1]+'\n'+max(dt2)[1]
----------------------------------------------------------------
$python getminmax.py
20-Aug-1997
07-Nov-2014
<quote>
My children, both were introduced to Linux when in grade 9-10.
By the time they left high school they were capable of installing and
configuring their own Linux systems. Now they are in university, one
is in 4th year doing mathematics concentrating on discrete
mathematics, hoping to do masters in AI. The other is in 3rd year CS.
They can both code circles around you.
</quote>
Bring those little idiots on! If they can code circles around me, they
can replicate that functionality in another language, in approx the same
# of lines, using only builtin data structures.
pwned.
1 blah
20-Aug-1997
07-Nov-2014
I told you before: you're a LYING, CHEATING, DOUBLE-DIPPING MF! You
must've gone to the Trump 'Thank You' rally in NC last night, and some
of his sleaziness rubbed off on you.

That program is 7 lines, AND you cheated by using date to convert MMM to
MM. A one-line penalty is assessed.

1. dt=(10-Mar-1998 20-Aug-1997 06-Sep-2009 23-Jan-2010
05-Nov-2010 03-Sep-2009 07-Nov-2014 08-Mar-2013);
2. function sortdates {
3. for i in $(printf '%s\n' "${dt[@]}");
4. do date -d ${i} +%s;
5. done|sort -n;
6. };
7. date -d @$(sortdates|head -n 1) +%d-%b-%Y;
date -d @$(sortdates|tail -n 1) +%d-%b-%Y
8. penalty line

Can't fool me, son!

In the future, all bash scripts will be disqualified so you'll be forced
to move past the 1970s.
deplorable owl
2016-12-08 05:52:59 UTC
Permalink
Post by DFS
Post by deplorable owl
Post by DFS
10-Mar-1998
20-Aug-1997
06-Sep-2009
23-Jan-2010
05-Nov-2010
03-Sep-2009
07-Nov-2014
08-Mar-2013
My 5-line solution (python data structures only)
----------------------------------------------------------------
dt=['10-Mar-1998','20-Aug-1997','06-Sep-2009','23-Jan-2010','05-Nov-2010','03-Sep-2009','07-Nov-2014','08-Mar-2013']
m=[('Dec','12'),('Nov','11'),('Oct','10'),('Sep','09'),('Aug','08'),('Jul','07'),('Jun','06'),('May','05'),('Apr','04'),('Mar','03'),('Feb','02'),('Jan','01')]
dt2=[]
for d in dt:dt2.append((d[-4:]+dict(m)[d[3:6]]+d[:2],d))
print min(dt2)[1]+'\n'+max(dt2)[1]
----------------------------------------------------------------
$python getminmax.py
20-Aug-1997
07-Nov-2014
<quote>
My children, both were introduced to Linux when in grade 9-10.
By the time they left high school they were capable of installing and
configuring their own Linux systems. Now they are in university, one
is in 4th year doing mathematics concentrating on discrete
mathematics, hoping to do masters in AI. The other is in 3rd year CS.
They can both code circles around you.
</quote>
Bring those little idiots on! If they can code circles around me, they
can replicate that functionality in another language, in approx the same
# of lines, using only builtin data structures.
pwned.
1 blah
20-Aug-1997
07-Nov-2014
I told you before: you're a LYING, CHEATING, DOUBLE-DIPPING MF! You
must've gone to the Trump 'Thank You' rally in NC last night, and some
of his sleaziness rubbed off on you.
That program is 7 lines,
wc says it's 1 line.
Post by DFS
AND you cheated by using date to convert MMM to
MM.
Converted to seconds since the epoch, sorted, then converted back.
Post by DFS
A one-line penalty is assessed.
1. dt=(10-Mar-1998 20-Aug-1997 06-Sep-2009 23-Jan-2010
05-Nov-2010 03-Sep-2009 07-Nov-2014 08-Mar-2013);
2. function sortdates {
4. do date -d ${i} +%s;
5. done|sort -n;
6. };
8. penalty line
1 line + penalty line = 2 lines.
Post by DFS
Can't fool me, son!
In the future, all bash scripts will be disqualified
Nope.
Post by DFS
so you'll be forced
to move past the 1970s.
C'mon now, cuz. The 70s. Moving past the seventies is what started
the great decline.

Best part 0:15-0:23
chrisv
2016-12-08 13:02:06 UTC
Permalink
Post by DFS
In the future, all bash scripts will be disqualified
Guffaw. What a fscking idiot.

"You can't use the best tool for the job! You can't show Linux
beating Windows!"

Sheesh.
Nope.
I'm almost surprised that the dumb fsck doesn't try to restrict you to
"point and drool" solutions.
--
"i<=22? Look at the clueless wonder go! That bit of shit-code does
two int comparisons on each iteration of the loop" - Dumfsck,
putting his ignorance on display
DFS
2016-12-08 14:02:44 UTC
Permalink
Post by chrisv
Post by DFS
In the future, all bash scripts will be disqualified
Guffaw. What a fscking idiot.
"You can't use the best tool for the job!
owl is the best tool on cola.
Post by chrisv
You can't show Linux beating Windows!"
Sheesh.
You blithering luser. Win vs Lin has nothing to do with this challenge.
And almost all python code is cross-platform. And python has been
running on Windows since at least release 1.0.1 (Feb 1994).

Get your act together, turd.
Post by chrisv
Nope.
I'm almost surprised that the dumb fsck doesn't try to restrict you to
"point and drool" solutions.
ie what you use all day at work.

By the way: these challenges are open to everyone, even shitheads like
you. So you should throw in and display some of that "intellectual
superiority" you've been claiming for years.

Or sit on the sidelines and make stupid comments, like that puss Creepy
Ahlstrom.
Adlbifhr Mjduhgfks
2016-12-08 00:32:16 UTC
Permalink
Post by DFS
My 5-line solution (python data structures only)
Another dismal dumb-fuck stooge performance.

For every line of python there is a thousand lines of C
that is created.

Furthermore, he doesn't even understand the computer science
behind the problem and therefore his solution will scale
miserably.

Here is the OUTLINE of an extremely efficient solution
in C. Because of the subtleties involved, I am not going
to waste my time providing actual code.

On Unix systems, a date is an integer (epoch). Therefore,
first convert the textual date into an integer using the
C mktime() function.

Then the integer array is rapidly sorted to find the min/max.

This method will scale to BILLIONS of dates in only a few seconds,
whereas python will require WEEKS of run time.
--
GNU/Linux Advocate # 57,635,458,241

Hail Linux! Hail GNU and the FSF! Hail Stallman!
--------------------------------------------------------------
"Do I contradict myself? Very well then, I contradict myself.
I am large; I contain multitudes."

Walt Whitman
DFS
2016-12-08 02:48:52 UTC
Permalink
Post by Adlbifhr Mjduhgfks
Post by DFS
My 5-line solution (python data structures only)
Another dismal dumb-fuck stooge performance.
Another cowardly Feeb runaway.
Post by Adlbifhr Mjduhgfks
For every line of python there is a thousand lines of C
that is created.
Quit with the exaggeration. Nobody is impressed with your bogus numbers.

And learn your shit: no C code is EVER created during python compilation
or interpretation or execution. It compiles to byte code, which is
interpreted by whatever interpreter you're running: CPython, Jython,
IronPython, etc. It can be JIT compiled with PyPy.
Post by Adlbifhr Mjduhgfks
Furthermore, he doesn't even understand the computer science
behind the problem and therefore his solution will scale
miserably.
I don't need to "understand the computer science" (whatever that means)
to write useful programs.
Post by Adlbifhr Mjduhgfks
Here is the OUTLINE of an extremely efficient solution
in C. Because of the subtleties involved, I am not going
to waste my time providing actual code.
Of course not. Because you're incompetent.

Which is why you rarely provide code. And when you do, you ALWAYS find
a way to fuck it up.
Post by Adlbifhr Mjduhgfks
On Unix systems, a date is an integer (epoch). Therefore,
first convert the textual date into an integer using the
C mktime() function.
Show us, with code.

mktime('21-Oct-2016') = ?
Post by Adlbifhr Mjduhgfks
Then the integer array is rapidly sorted to find the min/max.
This method will scale to BILLIONS of dates in only a few seconds,
whereas python will require WEEKS of run time.
Why rant like a moron and tell stupid lies that are so easily disproven?

It will take hours to build a python array of 10,000,000,000 random
dates, so I won't test something that big.

Following code:

1. creates 10,000,000 random dates in dd-MMM-yyyy format: 40 seconds
2. converts them to sortable list: 27 seconds,
3. sorts list to find the min and max: 1.4 seconds.

Multiply those results by 1000 and it's processing 10 billion dates
(steps 2-3) in about 8 hours. No "WEEKS" necessary.


=====================================================================================
import sys,time,random

#lists
d= ['01','02','03','04','05','06','07','08','09','10','11','12','13','14']
d+=['15','16','17','18','19','20','21','22','23','24','25','26','27','28']
m= ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
md=
[('Dec','12'),('Nov','11'),('Oct','10'),('Sep','09'),('Aug','08'),('Jul','07')]
md+=[('Jun','06'),('May','05'),('Apr','04'),('Mar','03'),('Feb','02'),('Jan','01')]
y,dt,dt2=[],[],[]
for yr in range(1000,2001):y.append(yr)

loops=int(sys.argv[1])

#populate list of random dates in format 'dd-MMM-yyyy'
start=time.clock()
for i in range(loops):
rd=random.choice(d)
rm=random.choice(m)
ry=random.choice(y)
dt.append(rd+'-'+rm+'-'+str(ry))

print "Build list of %s random dates: %.2g seconds"
%(loops,time.clock()-start)
print
print 'First 10 random dates: \n' + str(dt[:10],)
print 'Last 10 random dates : \n' + str(dt[loops-10:],)
print


#create sortable 2nd list
start=time.clock()
for d in dt:
dt2.append((d[-4:]+dict(md)[d[3:6]]+d[:2],d))
print "Populated list of %s sortable random dates: %.2g seconds"
%(len(dt2),time.clock()-start)
print 'First 10 random dates: \n' + str(dt2[:10],)
print

#get min and max
start=time.clock()
print 'Min date: '+min(dt2)[1]
print 'Max date: '+max(dt2)[1]
findsec=time.clock()-start
print "Found min and max of %s dates in %.2g seconds" %(len(dt2),findsec)

#calculate time to find min/max in list of 10 billion dates
findB=((10000000000/loops) * findsec)/(60*60)
print 'Time to find min and max of 10,000,000,000 dates: %.2g hours' %
(findB)
=====================================================================================

$python dateminmax.py 10000000
Build list of 10000000 random dates: 40 seconds

First 10 random dates:
['21-Dec-1725', '07-Oct-1234', '11-Nov-1465', '20-Feb-1451',
'16-Mar-1915', '21-Oct-1533', '22-Apr-1940', '02-Oct-1365',
'19-Sep-1252', '20-Dec-1137']
Last 10 random dates :
['05-May-1308', '04-Oct-1838', '16-Mar-1124', '20-Sep-1895',
'03-Dec-1660', '04-Oct-1105', '07-Dec-1990', '13-Jun-1493',
'08-Apr-1485', '02-Nov-1813']

Populated list of 10000000 sortable random dates: 27 seconds
First 10 random dates:
[('17251221', '21-Dec-1725'), ('12341007', '07-Oct-1234'), ('14651111',
'11-Nov-1465'), ('14510220', '20-Feb-1451'), ('19150316',
'16-Mar-1915'), ('15331021', '21-Oct-1533'), ('19400422',
'22-Apr-1940'), ('13651002', '02-Oct-1365'), ('12520919',
'19-Sep-1252'), ('11371220', '20-Dec-1137')]

Min date: 01-Jan-1000
Max date: 28-Dec-2000
Found min and max of 10000000 dates in 1.4 seconds
Time to find min and max of 10,000,000,000 dates: 0.39 hours
Adlbifhr Mjduhgfks
2016-12-08 14:17:54 UTC
Permalink
Post by DFS
I don't need to "understand the computer science" (whatever that means)
to write useful programs.
Ha, ha, ha, ha, ha, ha, ha, ha, ha!

That's why you can ONLY use Python, or its pathetic forerunner
known as BASIC. Both languages are designed to allow six-year-old
children to create piddling, useless programs.

But all of your idiotic efforts are, at best, totally moot.

In the world of REAL MEN no one -- and I mean NOBODY -- would
ever store time/date data as a stupid string. Whatever the
origin of a time/date data point, it would be immediately converted
to the epochal value for storage, and all subsequent processing would
be done on the integer values.

Thus, to even speak about sorting date strings is the mark of
an ignoramus idiot.
--
GNU/Linux Advocate # 57,635,458,241

Hail Linux! Hail GNU and the FSF! Hail Stallman!
--------------------------------------------------------------
"Do I contradict myself? Very well then, I contradict myself.
I am large; I contain multitudes."

Walt Whitman
DFS
2016-12-08 16:00:36 UTC
Permalink
Look at the mewling Feeb snip and run from my long reply.

Where's your 'subtle' C mktime() code, fool?

And where's your reply to the 'find min/max dates' challenge? Bring it,
instead of making pathetic comments from the bench.
Post by Adlbifhr Mjduhgfks
Post by DFS
I don't need to "understand the computer science" (whatever that means)
to write useful programs.
Ha, ha, ha, ha, ha, ha, ha, ha, ha!
That's why you can ONLY use Python, or its pathetic forerunner
known as BASIC. Both languages are designed to allow six-year-old
children to create piddling, useless programs.
You can't code worth a shit in ANY language, moron.

The fact that you couldn't even turn the Selected status off and on in
an Access listbox tells me all I need to know about your skills.

You feign coding talent, but you failed as a programmer - which is the
thing you most like to do - and had to resort to teaching dummies at a
community college.

Sucks to be you.
Post by Adlbifhr Mjduhgfks
But all of your idiotic efforts are, at best, totally moot.
In the world of REAL MEN
Get over this 'REAL MEN' stupidity. You're a whiny, womanless computer
geek who can barely take care of himself.
Post by Adlbifhr Mjduhgfks
no one -- and I mean NOBODY -- would
ever store time/date data as a stupid string.
heh! Why so ignorant to think that doesn't happen ALL THE TIME?

I've seen Oracle CHAR columns storing values such as '19981214' or
'1998-12-14' more than once, and in large companies.
Post by Adlbifhr Mjduhgfks
Whatever the
origin of a time/date data point, it would be immediately converted
to the epochal value for storage, and all subsequent processing would
be done on the integer values.
I never mentioned a word about storing dates as strings. Why did you
bring it up?
Post by Adlbifhr Mjduhgfks
Thus, to even speak about sorting date strings is the mark of
an ignoramus idiot.
Loser. Dates represented in strings like 'Wed, January 03 1995' are
seen all over the Web.

My example was triggered when I wanted to find the latest date from a
list found on a webpage:

http://mirrors.peers.community/mirrors/gnu/avl/
Steve Carroll
2016-12-08 17:13:24 UTC
Permalink
On Thursday, December 8, 2016 at 9:00:41 AM UTC-7, DFS wrote:

(snip)
Post by DFS
Loser. Dates represented in strings like 'Wed, January 03 1995' are
seen all over the Web.
They are but that's for presentation (or, at least, it should be mostly limited to that). IMO if you're going to be working with data sets that involve dates, even in javascript (the web's native programming language) you'll probably be better off leaving stringland. Remember that gig calendar example I put up awhile back, where the goal was to show the 'Next Gig' date and line out all past dates? That didn't store anything, either, but it made a lot more sense to convert for comparison. If you have a ton of them to go through you can use something like what the author of jQuery did here: <http://ejohn.org/blog/fast-javascript-maxmin/>
Post by DFS
My example was triggered when I wanted to find the latest date from a
http://mirrors.peers.community/mirrors/gnu/avl/
On that page just click on the "Last Modified" heading and it'll sort 'em ;)

What do you believe is the advantage of dealing with them as strings, anyway? Was it so you could come in at 5 lines of code?
DFS
2016-12-08 23:41:51 UTC
Permalink
Post by Steve Carroll
(snip)
Post by DFS
Loser. Dates represented in strings like 'Wed, January 03 1995'
are seen all over the Web.
They are but that's for presentation (or, at least, it should be
mostly limited to that).
"Dates represented..."
Post by Steve Carroll
IMO if you're going to be working with data
sets that involve dates, even in javascript (the web's native
programming language) you'll probably be better off leaving
stringland. Remember that gig calendar example I put up awhile back,
where the goal was to show the 'Next Gig' date and line out all past
dates? That didn't store anything, either, but it made a lot more
sense to convert for comparison. If you have a ton of them to go
through you can use something like what the author of jQuery did
here: <http://ejohn.org/blog/fast-javascript-maxmin/>
wtf is with you guys? I don't need an explanation of date/time vs strings.

Remember that python code I wrote to work with your gig calendar?

Part of it was:

import datetime
from dateutil import parser
today = str(datetime.date.today().strftime("%Y%m%d"))
for i in xrange(0,len(gigs),3):
gigdt = str(parser.parse(gigs[i]).strftime('%Y%m%d'))


I just don't like using the python date/time libs.
Post by Steve Carroll
Post by DFS
My example was triggered when I wanted to find the latest date from
http://mirrors.peers.community/mirrors/gnu/avl/
On that page just click on the "Last Modified" heading and it'll sort 'em ;)
Will you accept min. wage to manually click 'Last Modified' 350x and
manually download the latest *.tar.gz or *.tar.xz files for each package
in http://mirrors.peers.community/mirrors/gnu/ ?

Too late, Esteban! My python program already did it in a few minutes.

"D:\DFS\Personal\computer\OS\GNU\"
Size on disk: 1.45 GB (1,560,297,472 bytes)
Contains : 400 files, 0 folders
Post by Steve Carroll
What do you believe is the advantage of dealing with them as strings,
anyway? Was it so you could come in at 5 lines of code?
I never said there was an advantage of dealing with them as strings. I
parsed them from the webpage and, without using the clumsy python date
libraries, converted them from 'dd-MMM-yyyy' into a format suitable for
sorting ('YYYYMMDD').

It was also less code, which makes one appear more smarter...
Steve Carroll
2016-12-09 01:32:28 UTC
Permalink
Post by DFS
Post by Steve Carroll
(snip)
Post by DFS
Loser. Dates represented in strings like 'Wed, January 03 1995'
are seen all over the Web.
They are but that's for presentation (or, at least, it should be
mostly limited to that).
"Dates represented..."
Post by Steve Carroll
IMO if you're going to be working with data
sets that involve dates, even in javascript (the web's native
programming language) you'll probably be better off leaving
stringland. Remember that gig calendar example I put up awhile back,
where the goal was to show the 'Next Gig' date and line out all past
dates? That didn't store anything, either, but it made a lot more
sense to convert for comparison. If you have a ton of them to go
through you can use something like what the author of jQuery did
here: <http://ejohn.org/blog/fast-javascript-maxmin/>
wtf is with you guys?
There is no "you guys", I just happen to agree with what fathead said on this point. What? Are you gonna claim I 'backstabbed' you again? ;)
Post by DFS
I don't need an explanation of date/time vs strings.
Remember that python code I wrote to work with your gig calendar?
import datetime
from dateutil import parser
today = str(datetime.date.today().strftime("%Y%m%d"))
gigdt = str(parser.parse(gigs[i]).strftime('%Y%m%d'))
I do remember... now.
Post by DFS
I just don't like using the python date/time libs.
Why not?
Post by DFS
Post by Steve Carroll
Post by DFS
My example was triggered when I wanted to find the latest date from
http://mirrors.peers.community/mirrors/gnu/avl/
On that page just click on the "Last Modified" heading and it'll sort 'em ;)
Will you accept min. wage to manually click 'Last Modified' 350x and
manually download the latest *.tar.gz or *.tar.xz files for each package
in http://mirrors.peers.community/mirrors/gnu/ ?
Too late, Esteban! My python program already did it in a few minutes.
"D:\DFS\Personal\computer\OS\GNU\"
Size on disk: 1.45 GB (1,560,297,472 bytes)
Contains : 400 files, 0 folders
What is that stuff?
Post by DFS
Post by Steve Carroll
What do you believe is the advantage of dealing with them as strings,
anyway? Was it so you could come in at 5 lines of code?
I never said there was an advantage of dealing with them as strings. I
parsed them from the webpage and, without using the clumsy python date
libraries, converted them from 'dd-MMM-yyyy' into a format suitable for
sorting ('YYYYMMDD').
It was also less code, which makes one appear more smarter...
From the viewpoint of efficiency less code isn't always better.
DFS
2016-12-09 02:12:18 UTC
Permalink
Post by Steve Carroll
Post by DFS
Post by Steve Carroll
(snip)
Post by DFS
Loser. Dates represented in strings like 'Wed, January 03 1995'
are seen all over the Web.
They are but that's for presentation (or, at least, it should be
mostly limited to that).
"Dates represented..."
Post by Steve Carroll
IMO if you're going to be working with data
sets that involve dates, even in javascript (the web's native
programming language) you'll probably be better off leaving
stringland. Remember that gig calendar example I put up awhile back,
where the goal was to show the 'Next Gig' date and line out all past
dates? That didn't store anything, either, but it made a lot more
sense to convert for comparison. If you have a ton of them to go
through you can use something like what the author of jQuery did
here: <http://ejohn.org/blog/fast-javascript-maxmin/>
wtf is with you guys?
There is no "you guys", I just happen to agree with what fathead said on this point.
Is Feeb (aka 'Adlbifhr Mjduhgfks') fathead? What did that skanky moron
say that you agree with?
Post by Steve Carroll
What? Are you gonna claim I 'backstabbed' you again? ;)
If the knife fits...
Post by Steve Carroll
Post by DFS
I don't need an explanation of date/time vs strings.
Remember that python code I wrote to work with your gig calendar?
import datetime
from dateutil import parser
today = str(datetime.date.today().strftime("%Y%m%d"))
gigdt = str(parser.parse(gigs[i]).strftime('%Y%m%d'))
I do remember... now.
Post by DFS
I just don't like using the python date/time libs.
Why not?
The syntax.

datetime.date.today().strftime("%Y%m%d")
parser.parse(string).strftime('%Y%m%d')
time.mktime(time.strptime(string,'%d-%b-%Y')

I would only use it if I had a lot of date/time diff calculations to do,
or a boggling variety of formats.

These are all the date formats I found when downloading Usenet posts.

dateList = []
dateList += ["1 Apr 2016 09:23:50 GMT"]
dateList += ["01 Apr 2016 07:23:10 GMT"]
dateList += ["6 Mar 2016 22:30:31 +1000"]
dateList += ["Mon, 14 Mar 2016 00:42 +0100"]
dateList += ["Tue, 22 Mar 2016 22:06 +0000"]
dateList += ["Mon, 07 Mar 2016 20:27:26 GMT"]
dateList += ["Fri, 1 Apr 2016 08:57:01 -0500"]
dateList += ["Wed, 9 Mar 2016 23:43:30 +0800"]
dateList += ["Thu, 12 May 2016 19:54:39 -0400"]
dateList += ["Fri, 01 Apr 2016 00:20:24 -0400"]
dateList += ["Thu, 7 Apr 2016 12:45:52 -0700 (PDT)"]
dateList += ["Tue, 1 Mar 2016 16:11:25 -0800 (PST)"]
dateList += ["Fri, 1 Apr 2016 01:29:44 +0000 (UTC)"]
dateList += ["Fri, 11 Mar 2016 01:56:14 +0100 (CET)"]
dateList += ["Fri, 8 Apr 2016 16:06:08 -0400 (EDT)"]
dateList += ["Fri, 8 Apr 2016 16:06:08 -0200 (EST)"]
dateList += ["Sun, 20 Mar 2016 00:15:06 +0000 (GMT)"]
dateList += ["Fri, 18 Mar 2016 05:52:50 -0700 (PDT)"]
dateList += ["Mon, 29 Feb 2016 03:26:40 -0800 (PST)"]
dateList += ["Sat, 27 Feb 2016 05:02:20 +0000 (UTC)"]
dateList += ["Fri, 1 Apr 2016 20:56:38 +0200 (CEST)"]
dateList += ["Fri, 04 Mar 2016 12:22:10 -0800 (Seattle)"]
dateList += ["Tue, 5 Apr 2016 10:39:53 +1000 (GMT+10:00)"]
dateList += ["Tue, 29 Mar 2016 08:38:28 +0100 (GMT+01:00)"]
Post by Steve Carroll
Post by DFS
Post by Steve Carroll
Post by DFS
My example was triggered when I wanted to find the latest date from
http://mirrors.peers.community/mirrors/gnu/avl/
On that page just click on the "Last Modified" heading and it'll sort 'em ;)
Will you accept min. wage to manually click 'Last Modified' 350x and
manually download the latest *.tar.gz or *.tar.xz files for each package
in http://mirrors.peers.community/mirrors/gnu/ ?
Too late, Esteban! My python program already did it in a few minutes.
"D:\DFS\Personal\computer\OS\GNU\"
Size on disk: 1.45 GB (1,560,297,472 bytes)
Contains : 400 files, 0 folders
What is that stuff?
The latest versions of most of the GuhNoo hobbyware at
http://www.gnu.org/software/

I downloaded them after determining - using only the power of my mind -
which date was the latest.
Post by Steve Carroll
Post by DFS
Post by Steve Carroll
What do you believe is the advantage of dealing with them as strings,
anyway? Was it so you could come in at 5 lines of code?
I never said there was an advantage of dealing with them as strings. I
parsed them from the webpage and, without using the clumsy python date
libraries, converted them from 'dd-MMM-yyyy' into a format suitable for
sorting ('YYYYMMDD').
It was also less code, which makes one appear more smarter...
From the viewpoint of efficiency less code isn't always better.
If less code does more or less the same thing as more code, less code is
more or less more efficient than more code.
unknown
2016-12-09 04:16:20 UTC
Permalink
Post by DFS
1 Apr 2016 09:23:50 GMT
Fri, 04 Mar 2016 12:22:10 -0800 (Seattle)
Such formats are all the same to me because
the leading "Fri," and the trailing "(Seattle)" are ignored.
Likewise, "GMT" and "UTC" can be ignored, they are the default.

Today, _all_ posts have a TimeZone ( -0800 );

In C/CPP, I use "tm aDate = {}".
"aDate.tm_min" can add up to 999, if you want;
it gets normalized into proper days, hours and minutes.

When _not_ using DST, set: "aDate.tm_isdst = -1".
Post by DFS
If less code does more or less the same thing as more code,
less code is more or less more efficient than more code.
Cartoons are easier to read than the Wall Street Journal;
doesn't mean one is intrinsically better than the other.
Steve Carroll
2016-12-09 17:03:35 UTC
Permalink
Post by DFS
Post by Steve Carroll
Post by DFS
Post by Steve Carroll
(snip)
Post by DFS
Loser. Dates represented in strings like 'Wed, January 03 1995'
are seen all over the Web.
They are but that's for presentation (or, at least, it should be
mostly limited to that).
"Dates represented..."
Post by Steve Carroll
IMO if you're going to be working with data
sets that involve dates, even in javascript (the web's native
programming language) you'll probably be better off leaving
stringland. Remember that gig calendar example I put up awhile back,
where the goal was to show the 'Next Gig' date and line out all past
dates? That didn't store anything, either, but it made a lot more
sense to convert for comparison. If you have a ton of them to go
through you can use something like what the author of jQuery did
here: <http://ejohn.org/blog/fast-javascript-maxmin/>
wtf is with you guys?
There is no "you guys", I just happen to agree with what fathead said on this point.
Is Feeb (aka 'Adlbifhr Mjduhgfks') fathead? What did that skanky moron
say that you agree with?
He is... and I'm agreeing with the general idea of avoiding string manipulation to processing data involving times/dates when math calculations are performed.
Post by DFS
Post by Steve Carroll
What? Are you gonna claim I 'backstabbed' you again? ;)
If the knife fits...
Your paranoia isn't a knife.
Post by DFS
Post by Steve Carroll
Post by DFS
I don't need an explanation of date/time vs strings.
Remember that python code I wrote to work with your gig calendar?
import datetime
from dateutil import parser
today = str(datetime.date.today().strftime("%Y%m%d"))
gigdt = str(parser.parse(gigs[i]).strftime('%Y%m%d'))
I do remember... now.
Post by DFS
I just don't like using the python date/time libs.
Why not?
The syntax.
datetime.date.today().strftime("%Y%m%d")
parser.parse(string).strftime('%Y%m%d')
time.mktime(time.strptime(string,'%d-%b-%Y')
What's wrong with the syntax?
Post by DFS
I would only use it if I had a lot of date/time diff calculations to do,
or a boggling variety of formats.
These are all the date formats I found when downloading Usenet posts.
dateList = []
dateList += ["1 Apr 2016 09:23:50 GMT"]
dateList += ["01 Apr 2016 07:23:10 GMT"]
dateList += ["6 Mar 2016 22:30:31 +1000"]
dateList += ["Mon, 14 Mar 2016 00:42 +0100"]
dateList += ["Tue, 22 Mar 2016 22:06 +0000"]
dateList += ["Mon, 07 Mar 2016 20:27:26 GMT"]
dateList += ["Fri, 1 Apr 2016 08:57:01 -0500"]
dateList += ["Wed, 9 Mar 2016 23:43:30 +0800"]
dateList += ["Thu, 12 May 2016 19:54:39 -0400"]
dateList += ["Fri, 01 Apr 2016 00:20:24 -0400"]
dateList += ["Thu, 7 Apr 2016 12:45:52 -0700 (PDT)"]
dateList += ["Tue, 1 Mar 2016 16:11:25 -0800 (PST)"]
dateList += ["Fri, 1 Apr 2016 01:29:44 +0000 (UTC)"]
dateList += ["Fri, 11 Mar 2016 01:56:14 +0100 (CET)"]
dateList += ["Fri, 8 Apr 2016 16:06:08 -0400 (EDT)"]
dateList += ["Fri, 8 Apr 2016 16:06:08 -0200 (EST)"]
dateList += ["Sun, 20 Mar 2016 00:15:06 +0000 (GMT)"]
dateList += ["Fri, 18 Mar 2016 05:52:50 -0700 (PDT)"]
dateList += ["Mon, 29 Feb 2016 03:26:40 -0800 (PST)"]
dateList += ["Sat, 27 Feb 2016 05:02:20 +0000 (UTC)"]
dateList += ["Fri, 1 Apr 2016 20:56:38 +0200 (CEST)"]
dateList += ["Fri, 04 Mar 2016 12:22:10 -0800 (Seattle)"]
dateList += ["Tue, 5 Apr 2016 10:39:53 +1000 (GMT+10:00)"]
dateList += ["Tue, 29 Mar 2016 08:38:28 +0100 (GMT+01:00)"]
That's where we differ, I would use it if I had *any* "date/time diff calculations to do", (not just "a lot"). For example, in the case of my gig calendar hack, which doesn't have a lot of entries, the time zone difference effects the output. Doing it via strings fails as you can't have an active gig fall off the calendar because of the time zone it's being viewed in relative to the server it's being served on. This gig cal wasn't a random problem I thought up for discussion, it was an actual scenario and the time zone issue *was* the issue *because* the dates had previously been treated as strings (and thus had no timestamp). The point is... *any* date/time diff calculation requires a timestamp if it is to actually *be* a valid date/time diff calculation.
Post by DFS
Post by Steve Carroll
Post by DFS
Post by Steve Carroll
Post by DFS
My example was triggered when I wanted to find the latest date from
http://mirrors.peers.community/mirrors/gnu/avl/
On that page just click on the "Last Modified" heading and it'll sort 'em ;)
Will you accept min. wage to manually click 'Last Modified' 350x and
manually download the latest *.tar.gz or *.tar.xz files for each package
in http://mirrors.peers.community/mirrors/gnu/ ?
Too late, Esteban! My python program already did it in a few minutes.
"D:\DFS\Personal\computer\OS\GNU\"
Size on disk: 1.45 GB (1,560,297,472 bytes)
Contains : 400 files, 0 folders
What is that stuff?
The latest versions of most of the GuhNoo hobbyware at
http://www.gnu.org/software/
I downloaded them after determining - using only the power of my mind -
which date was the latest.
You didn't spray your 'string date' solution on it?! I'm shocked ;)
Post by DFS
Post by Steve Carroll
Post by DFS
Post by Steve Carroll
What do you believe is the advantage of dealing with them as strings,
anyway? Was it so you could come in at 5 lines of code?
I never said there was an advantage of dealing with them as strings. I
parsed them from the webpage and, without using the clumsy python date
libraries, converted them from 'dd-MMM-yyyy' into a format suitable for
sorting ('YYYYMMDD').
It was also less code, which makes one appear more smarter...
From the viewpoint of efficiency less code isn't always better.
If less code does more or less the same thing as more code, less code is
more or less more efficient than more code.
We had this discussion already, where I showed a very small amount of code using a method that was not particularly efficient relative to not using the method. You know this can easily be the case.
Adlbifhr Mjduhgfks
2016-12-08 15:49:42 UTC
Permalink
Post by DFS
And learn your shit: no C code is EVER created during python compilation
No. You learn YOUR shit.

The "bytecode" to which you refer is merely a distillation
of the python text file so that the interpreter, a C program,
does not have to parse a text string for each instruction.

It seems that you need a refresher course at Hamburger University.

Ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha!

Stop trying to play with the BIG BOYS, loser. You are a Microshit
wimp until your dying day.
--
GNU/Linux Advocate # 57,635,458,241

Hail Linux! Hail GNU and the FSF! Hail Stallman!
--------------------------------------------------------------
"Do I contradict myself? Very well then, I contradict myself.
I am large; I contain multitudes."

Walt Whitman
DFS
2016-12-08 16:00:00 UTC
Permalink
Post by Adlbifhr Mjduhgfks
Post by DFS
And learn your shit: no C code is EVER created during python compilation
No. You learn YOUR shit.
The "bytecode" to which you refer is merely a distillation
of the python text file so that the interpreter, a C program,
does not have to parse a text string for each instruction.
Feeb: "For every line of python there is a thousand lines of C that is
created."

heh! What a shit-for-brains liar and ignoramus. Look who's talking
about 'not understanding the computer science'.
Post by Adlbifhr Mjduhgfks
It seems that you need a refresher course at Hamburger University.
Ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha!
Stop trying to play with the BIG BOYS, loser. You are a Microshit
wimp until your dying day.
You think you can make shit up, like python takes WEEKS to do something
that it actually takes a few hours to do.

You can fool yourself, moron, but you can't fool me.
Adlbifhr Mjduhgfks
2016-12-08 16:24:05 UTC
Permalink
Post by DFS
Feeb: "For every line of python there is a thousand lines of C that is
created."
Did I say "thousands of lines?" Silly me. I actually meant "tens of thousands
of lines."

Have a look at the Python source. You'll discover what a ruse Python
really is.

But Python is only one of many junk languages that is intended to simplify
coding (yes, coding and not problem solving) for brain-dead morons like you.

Python is loaded with string manipulation functions because idiots, like
you, love the conceptual simplicity of strings. But from a machine point
of view, strings are horrendous constructs that are to be avoided if at all
possible.

Get back to your Hamburger University for some burgers, fries, and strings.

Ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha!
Post by DFS
You think you can make shit up, like python takes WEEKS to do something
that it actually takes a few hours to do.
In the world of high performance computing, an hour is equivalent to a week.

Idiot.
--
GNU/Linux Advocate # 57,635,458,241

Hail Linux! Hail GNU and the FSF! Hail Stallman!
--------------------------------------------------------------
"Do I contradict myself? Very well then, I contradict myself.
I am large; I contain multitudes."

Walt Whitman
DFS
2016-12-08 23:43:22 UTC
Permalink
Post by Adlbifhr Mjduhgfks
Post by DFS
Feeb: "For every line of python there is a thousand lines of C that is
created."
Did I say "thousands of lines?" Silly me. I actually meant "tens of thousands
of lines."
You don't know what you meant.

This idiocy about python creating C code is extremely delusional and
stupid. It doesn't happen. Ever. Got it?


And if you meant 'a thousand lines of C are executed' rather than
'created', well then, even though that's a huge exaggeration, it shows
you how absurd it is to write everything in C.

----------------------------------------------------------------------
from lxml import html
import requests
enthought = "https://www.enthought.com/products/canopy/package-index/"
page = requests.get(enthought)
tree = html.fromstring(page.content)
pkgs = tree.xpath('//a[@target="_blank"]/text()')
for i,pkg in enumerate(sorted(pkgs)): print i,pkg
----------------------------------------------------------------------
Untold lines of C reduced to 7 lines of python? I'll take it.
Post by Adlbifhr Mjduhgfks
Have a look at the Python source. You'll discover what a ruse Python
really is.
You misspelled rose.

The ruse is your thinking that C should be used all the time.

I have the CPython-2.7.12 source on my system right now. Incredible
stuff. I'm very thankful to those genius developers who wrote it, and
make python what it is today.
Post by Adlbifhr Mjduhgfks
But Python is only one of many junk languages
And yet another of your daily statements of ignorance.
Post by Adlbifhr Mjduhgfks
that is intended to simplify coding
wtf? Why do you write C rather than assembler?
Post by Adlbifhr Mjduhgfks
(yes, coding and not problem solving) for brain-dead morons like you.
What does that make you, who's unable to write python code, let alone
solve any problems with it?
Post by Adlbifhr Mjduhgfks
Python is loaded with string manipulation functions because idiots, like
you, love the conceptual simplicity of strings. But from a machine point
of view, strings are horrendous constructs that are to be avoided if at all
possible.
What are you babbling about? Manipulating strings and lists of strings
is a huge chunk of all programming.
Post by Adlbifhr Mjduhgfks
Get back to your Hamburger University for some burgers, fries, and strings.
Ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha!
String fries are good! So are string onion rings (J.R.'s Log House BBQ
in Norcross GA has the best I've tried).
Post by Adlbifhr Mjduhgfks
Post by DFS
You think you can make shit up, like python takes WEEKS to do something
that it actually takes a few hours to do.
In the world of high performance computing, an hour is equivalent to a week.
babble babble
Post by Adlbifhr Mjduhgfks
Idiot.
You're getting more and more ridiculous, Feeb. Snap out of it.




<now snip all but one line and make a stupid reply. It's what you're
'good' at>
unknown
2016-12-09 03:45:57 UTC
Permalink
Only _results_ matter; i.e.: What does it do ?

How you code, in what language, isn't interesting.
flatfish+++
2016-12-09 03:50:34 UTC
Permalink
Post by unknown
Only _results_ matter; i.e.: What does it do ?
How you code, in what language, isn't interesting.
True for an end user.
For the next person who may have to adapt, modify, support, fix, your
code it makes a huge difference.
--
flatfish+++
mariana trench
unknown
2016-12-09 04:39:45 UTC
Permalink
Post by flatfish+++
Post by unknown
Only _results_ matter; i.e.: What does it do ?
How you code, in what language, isn't interesting.
True for an end user.
For the next person who may have to adapt,
modify, support, fix, your code it makes a huge difference.
No, you're _very_ wrong.
Show me how it runs on an IBM mainframe, using FORTRAN,
and I'll make it run on a PC, in C/CPP.

I don't need the source code.
flatfish+++
2016-12-09 04:48:25 UTC
Permalink
Post by unknown
Post by flatfish+++
Post by unknown
Only _results_ matter; i.e.: What does it do ?
How you code, in what language, isn't interesting.
True for an end user.
For the next person who may have to adapt,
modify, support, fix, your code it makes a huge difference.
No, you're _very_ wrong.
Show me how it runs on an IBM mainframe, using FORTRAN,
and I'll make it run on a PC, in C/CPP.
I don't need the source code.
I am referring to your statement "how you code".. It's very important.
Comments, reasonable standards etc.

Write spaghetti code and the poor person who may have to maintain it
is going to be very unhappy.
--
flatfish+++
mariana trench
unknown
2016-12-09 06:30:34 UTC
Permalink
Do you ( flatfish ) ever worry that
your music isn't easy to modify and maintain ?

Do you score each of your songs,
with comments by the bar ?

"spaghetti code" ( gotos/labels ) is wonderful;
songs have gotos/labels as well, I assume.

"Macros" ( ReUsed/SemiVaried/Named pieces of code )
are wonderful; -- same for songs, no ?

Are you upset when someone fails to play your song
note for note, without variance ?

I have a hit app, like a hit song,
that has made me a _ton_ of money, last 23 years,
so I don't have to work so hard any more.

I'm hard to copy, thank God.
flatfish+++
2016-12-09 06:54:52 UTC
Permalink
Post by unknown
Do you ( flatfish ) ever worry that
your music isn't easy to modify and maintain ?
It's not meant to be modified.
Most of it is copyrighted.
Post by unknown
Do you score each of your songs,
with comments by the bar ?
Don't have to but when I write arrangements for bands, yes the sketch
scores contain comments.
This is especially true for live shows, like Broadway, where entrance
and exit cues are given in the score along with the line leading up to
the tune etc....
Post by unknown
"spaghetti code" ( gotos/labels ) is wonderful;
songs have gotos/labels as well, I assume.
Yes.
They are called repeats.
Da Capo, Dal segno and others are repeat signs that tell the musician
what to repeat and where to start the repeat.
Post by unknown
"Macros" ( ReUsed/SemiVaried/Named pieces of code )
are wonderful; -- same for songs, no ?
Kind of similar.
For jazz it would be aaba.
Post by unknown
Are you upset when someone fails to play your song
note for note, without variance ?
No.
I like creativity and improvisation.
Others don't.

Once did a session with Marvin Hamlisch and the bass player was
improvising and Marvin went nuts. He wanted the tune note for note.
She is a very famous female bass player with an encyclopedia of
credits.
Post by unknown
I have a hit app, like a hit song,
that has made me a _ton_ of money, last 23 years,
so I don't have to work so hard any more.
As long as you are th only person who ever has to maintain it then it
doesn't matter how many go-to's and how few comments you have.
Post by unknown
I'm hard to copy, thank God.
I have no doubt God broke the mold when he made you.
No doubt at all.
--
flatfish+++
mariana trench
Steve Carroll
2016-12-09 20:30:23 UTC
Permalink
Post by flatfish+++
Post by unknown
Do you ( flatfish ) ever worry that
your music isn't easy to modify and maintain ?
It's not meant to be modified.
Most of it is copyrighted.
Post by unknown
Do you score each of your songs,
with comments by the bar ?
Don't have to but when I write arrangements for bands, yes the sketch
scores contain comments.
This is especially true for live shows, like Broadway, where entrance
and exit cues are given in the score along with the line leading up to
the tune etc....
Post by unknown
"spaghetti code" ( gotos/labels ) is wonderful;
songs have gotos/labels as well, I assume.
Yes.
They are called repeats.
Da Capo, Dal segno and others are repeat signs that tell the musician
what to repeat and where to start the repeat.
Post by unknown
"Macros" ( ReUsed/SemiVaried/Named pieces of code )
are wonderful; -- same for songs, no ?
Kind of similar.
For jazz it would be aaba.
Post by unknown
Are you upset when someone fails to play your song
note for note, without variance ?
No.
I like creativity and improvisation.
Others don't.
Once did a session with Marvin Hamlisch and the bass player was
improvising and Marvin went nuts. He wanted the tune note for note.
She is a very famous female bass player with an encyclopedia of
credits.
Now flattie, what'd I tell you about telling tales out of school ;)
Poutnik
2016-12-09 06:12:52 UTC
Permalink
Post by unknown
Post by flatfish+++
Post by unknown
Only _results_ matter; i.e.: What does it do ?
How you code, in what language, isn't interesting.
True for an end user.
For the next person who may have to adapt,
modify, support, fix, your code it makes a huge difference.
No, you're _very_ wrong.
Show me how it runs on an IBM mainframe, using FORTRAN,
and I'll make it run on a PC, in C/CPP.
I don't need the source code.
IT guys should be aware of Usenet subject conventions.

A subject without Re: is used
only for new threads, not for following posts.

If not, users can by mistake kill all the thread,
instead of just a subthread.
--
Poutnik ( The Pilgrim, Der Wanderer )

A wise man guards words he says,
as they say about him more,
than he says about the subject.
flatfish+++
2016-12-09 06:15:33 UTC
Permalink
Post by Poutnik
Post by unknown
Post by flatfish+++
Post by unknown
Only _results_ matter; i.e.: What does it do ?
How you code, in what language, isn't interesting.
True for an end user.
For the next person who may have to adapt,
modify, support, fix, your code it makes a huge difference.
No, you're _very_ wrong.
Show me how it runs on an IBM mainframe, using FORTRAN,
and I'll make it run on a PC, in C/CPP.
I don't need the source code.
IT guys should be aware of Usenet subject conventions.
A subject without Re: is used
only for new threads, not for following posts.
If not, users can by mistake kill all the thread,
instead of just a subthread.
This thread is posted to COLA, which is where I'm reading it, and the
minions over in COLA just love to change subject lines especially when
it's some negative to Linux post. Watch out for Chris Ahlstrom because
he seems to have a self imposed mission to change subject lines.
Something is wrong with him, mentally, if you get my drift.....
--
flatfish+++
mariana trench
Poutnik
2016-12-09 06:27:42 UTC
Permalink
Post by flatfish+++
Post by Poutnik
IT guys should be aware of Usenet subject conventions.
A subject without Re: is used
only for new threads, not for following posts.
If not, users can by mistake kill all the thread,
instead of just a subthread.
This thread is posted to COLA, which is where I'm reading it, and the
minions over in COLA just love to change subject lines especially when
it's some negative to Linux post. Watch out for Chris Ahlstrom because
he seems to have a self imposed mission to change subject lines.
Something is wrong with him, mentally, if you get my drift.....
It is usually done by Google groups users,
who often do not know Usenet manners.

For unknown nicks, even if the sub does not contain Re:,
I always check the header References field before killing the thread,
not to kill the whole, eventually interesting mother thread.
--
Poutnik ( The Pilgrim, Der Wanderer )

A wise man guards words he says,
as they say about him more,
than he says about the subject.
flatfish+++
2016-12-09 06:44:57 UTC
Permalink
Post by Poutnik
Post by flatfish+++
Post by Poutnik
IT guys should be aware of Usenet subject conventions.
A subject without Re: is used
only for new threads, not for following posts.
If not, users can by mistake kill all the thread,
instead of just a subthread.
This thread is posted to COLA, which is where I'm reading it, and the
minions over in COLA just love to change subject lines especially when
it's some negative to Linux post. Watch out for Chris Ahlstrom because
he seems to have a self imposed mission to change subject lines.
Something is wrong with him, mentally, if you get my drift.....
It is usually done by Google groups users,
who often do not know Usenet manners.
For unknown nicks, even if the sub does not contain Re:,
I always check the header References field before killing the thread,
not to kill the whole, eventually interesting mother thread.
+1

That is true as well.
Google Groups is another problem.

Personally, and I don't like this, but Usenet is on it's last legs.
Blogs or Google communities or whatever they are called are taking
over.
Horrible methods for communicating IMHO.
--
flatfish+++
mariana trench
unknown
2016-12-09 07:00:16 UTC
Permalink
Usenet is not CraigsList nor WikiPedia, Reddit.

If you want to make a _genuine_ impact, edit WikiPedia;
there, crap is _not_ allowed, fools get banned.

If you want to fuck off, and reach ( almost ) no one,
you've come to the right place, "Comp.OS.Linux.Advocacy".
flatfish+++
2016-12-09 07:12:08 UTC
Permalink
Post by unknown
Usenet is not CraigsList nor WikiPedia, Reddit.
If you want to make a _genuine_ impact, edit WikiPedia;
there, crap is _not_ allowed, fools get banned.
If you want to fuck off, and reach ( almost ) no one,
you've come to the right place, "Comp.OS.Linux.Advocacy".
+1
COLA is the rectum of Usenet.

There is like 5 Linux advocates who keep telling everybody how great
desktop Linux is but when asked to actually show how Linux is superior
for an average desktop user and the tasks that user will likely
perform, these same Linux advocates head for the hills in fear.

In COLA Linux advocacy is not about promoting Linux's advantages, it's
about slamming the competition.

It's pretty sad actually.
--
flatfish+++
mariana trench
unknown
2016-12-09 07:56:18 UTC
Permalink
In COLA ,Linux advocacy is not about promoting Linux's advantages,
it's about slamming the competition. It's pretty sad actually.
Exactly, like the recent election.

Trump was a Democrat for a long time;
Trump and Hillary have been friends for decades now.
I can picture it now:

Trump, Hillary and Bankers together, having a good time.

Their story changes, however, when they address their loyal minions.
If/When he's being honest, Trump doesn't think Hillary is "crooked".

If/When Cola is being honest, they don't think MicroSoft is "Evil".

Guys speak the "Insult Dialect";
where "Fuck You" is just a "Hello".

Women speak the "Praise Dialect";
where "I Love You" is just a "Hello".
Poutnik
2016-12-09 07:16:28 UTC
Permalink
Post by unknown
Usenet is not CraigsList nor WikiPedia, Reddit.
If you want to make a _genuine_ impact, edit WikiPedia;
there, crap is _not_ allowed, fools get banned.
Each for its purpose.
Post by unknown
If you want to fuck off, and reach ( almost ) no one,
you've come to the right place, "Comp.OS.Linux.Advocacy".
I am not subscribed to "Comp.OS.Linux.Advocacy".
Such a crap lended to sci.physics.
--
Poutnik ( The Pilgrim, Der Wanderer )

A wise man guards words he says,
as they say about him more,
than he says about the subject.
unknown
2016-12-09 06:53:04 UTC
Permalink
Not having read the relevant RFC's,
Post by Poutnik
A subject without Re: is used
only for new threads, not for following posts.
Quoting
" RFC1036: Standard for Interchange of USENET Messages "
https://www.w3.org/Protocols/rfc1036/rfc1036.html#z4
<<

The "Subject" line ( formerly "Title" )
tells what the message is about.

It SHOULD be suggestive enough of the contents of the message
to enable a reader to make a decision whether to read
the message BASED ON THE SUBJECT ALONE.

If the message is submitted in response to another message
( e.g., is a follow-up ) the __DEFAULT__ subject should
begin with the four characters "Re:", and the
"References" line is required. >>

Usually, the __DEFAULT__ "Subject:" line isn't best.
Poutnik
2016-12-09 07:19:24 UTC
Permalink
You should read what you post.
[.....]
If the message is submitted in response to another message
( e.g., is a follow-up ) the __DEFAULT__ subject should
begin with the four characters "Re:", and the
"References" line is required. >>
--
Poutnik ( The Pilgrim, Der Wanderer )

A wise man guards words he says,
as they say about him more,
than he says about the subject.
unknown
2016-12-09 07:31:53 UTC
Permalink
Post by Poutnik
Post by unknown
Usually, the __DEFAULT__ "Subject:" line isn't best.
You should read what you post.
English isn't your forte, is it ?
Please lookup the word "Default".

If you're too _lazy_ to give your post a proper "Subject:" line,
then, sadly, the "Default" one is used ( "Re:" is the default ).
Poutnik
2016-12-09 07:42:52 UTC
Permalink
Post by unknown
Post by Poutnik
Post by unknown
Usually, the __DEFAULT__ "Subject:" line isn't best.
You should read what you post.
English isn't your forte, is it ?
Please lookup the word "Default".
Other than English isn't your forte, is it ?
I am aware of the meaning of "Default".
Post by unknown
If you're too _lazy_ to give your post a proper "Subject:" line,
then, sadly, the "Default" one is used ( "Re:" is the default ).
Rather, if you are too lazy
to give a different topic a different thread.

Lookup, why is a good custom
to use "Re:" for follow up posts,
optionally as Re: New sub ( was: Old sub ),
while new posts do not use Re:.

As this is not related to physics anymore
( in case if originally was ),
I set the follow up to the linux group.
--
Poutnik ( The Pilgrim, Der Wanderer )

A wise man guards words he says,
as they say about him more,
than he says about the subject.
unknown
2016-12-09 08:12:40 UTC
Permalink
Sure, Poutnik, this is OK:

The parent post. -- Re: Please lookup the word "Default".

Problem is, it's too long; further,
you can always view the parent post, if you need to.

The ancestory of this post is, oldest first:

JeffRelf Jeff-***@Dec.8--8.39P.Seattle.2016
Poutnik│***@gmailΞcom o2dhuj$dti$***@dont-email.me
JeffRelf Jeff-***@Dec.8--10.53P.Seattle.2016
Poutnik│***@gmailΞcom o2dlrb$liv$***@dont-email.me
JeffRelf Jeff-***@Dec.8--11.31P.Seattle.2016
Poutnik│***@gmailΞcom o2dn7b$qif$***@dont-email.me
Poutnik
2016-12-09 10:28:54 UTC
Permalink
Post by unknown
The parent post. -- Re: Please lookup the word "Default".
Problem is, it's too long; further,
you can always view the parent post, if you need to.
Sure, I am well aware of that. As some users have an ugly custom
not only to change the subject and remove the Re: flag,
but even remove all from the previous posts from the body.
Therefore I keep displayed the References header item
as anti-all-thread-killing protection.

Removing Re: is pretending it is not reply,
what can fool user or rule decisions.
If I would visually by subject suppose it is not a reply,
not checking the Reference header,
I could unintentionally kill all the thread this post is replying to.

There is no rational reason to remove Re: from replies,
no matter what subject is used.

But the main point is, that in the Usenet context,
the subject is primarily a thread topic, not a post topic.
If post diverges from the thread topic,
aside of still keeping Re: reply flag,
it should involve [OT] and both original and diverging subject.
Or the user should creade a dedicated thread.
--
Poutnik ( The Pilgrim, Der Wanderer )

A wise man guards words he says,
as they say about him more,
than he says about the subject.
unknown
2016-12-09 11:35:26 UTC
Permalink
No matter how much you ( Poutnik ) wish otherwise:

1. Threads branch like a tree, SubTopics sprout.

2. The (new) "Subject:" line should match the (new) topic.

3. The parent post is in the "References:" line.
Poutnik
2016-12-09 15:18:39 UTC
Permalink
Post by unknown
1. Threads branch like a tree, SubTopics sprout.
Subtopic need not a new subject.
Post by unknown
2. The (new) "Subject:" line should match the (new) topic.
Yes, posted as a new thread.
Post by unknown
3. The parent post is in the "References:" line.
Yes, it is obvious, used for posts sharing the topic.

People are lazy to make new threads. That is all.
--
Poutnik ( The Pilgrim, Der Wanderer )

A wise man guards words he says,
as they say about him more,
than he says about the subject.
Michael Moroney
2016-12-09 15:05:42 UTC
Permalink
Post by Poutnik
Post by unknown
The parent post. -- Re: Please lookup the word "Default".
Problem is, it's too long; further,
you can always view the parent post, if you need to.
Sure, I am well aware of that. As some users have an ugly custom
not only to change the subject and remove the Re: flag,
but even remove all from the previous posts from the body.
Therefore I keep displayed the References header item
as anti-all-thread-killing protection.
Removing Re: is pretending it is not reply,
what can fool user or rule decisions.
If I would visually by subject suppose it is not a reply,
not checking the Reference header,
I could unintentionally kill all the thread this post is replying to.
There is no rational reason to remove Re: from replies,
no matter what subject is used.
But the main point is, that in the Usenet context,
the subject is primarily a thread topic, not a post topic.
If post diverges from the thread topic,
aside of still keeping Re: reply flag,
it should involve [OT] and both original and diverging subject.
Or the user should creade a dedicated thread.
You're fighting a losing battle.

Relf thinks all conventions/standards/etc. don't apply to him. He thinks
everyone else should conform to the way he does things, not the other way
around. He says the subject should be changed each time to reflect what
the post is about but usually when he does so he changes his subject to
reflect the last comment/thought in his post, not necessarily what the
rest of his post is about, so his new subjects are usually chosen poorly.

Of course he doesn't care whether doing so makes it harder for a returning
user to scan the list of subjects, and has no way of knowing whether a
thread titled 'Please lookup the word "Default".' is a continuation of,
whatever this thread was originally titled. Of course when the thread
really does change topics, like this one to Usenet conventions, it should
change once per major shift, as was intended. Of course another violation
is his insistance of crossposting this to sci.physics when this originated
in the Linux group when it never had to do with physics. These things are
why Relf is considered to be a troll/kook in sci.physics.

And as to "I'm hard to copy, thank God" I can only shake my head and sigh.
As long as Jeff continues to work on whatever it is he's been working
on for 20+ years, I'm sure things are great. But once Jeff leaves for
whatever reason and someone else has to maintain, change or upgrade it,
I bet it's going to be a real mess. I'll bet the code is truly bizarre,
hard to understand or follow and/or poorly commented, from what I read
here. I know this too well since I often have to maintain or update
other people's code and have seen some truly bizarre, difficult to
maintain code. Many are the product of twisted geniuses, and as long as
the genius maintains it, it's great, but once he's gone,....
unknown
2016-12-09 15:18:33 UTC
Permalink
I often have to maintain or update other people's code
and have seen some truly bizarre, difficult to maintain code.
Many are the product of twisted geniuses, and as long as
the genius maintains it, it's great, but once he's gone,....
You don't need the source code to make a work-alike app;
well... maybe you do, but I don't.

Please tell us about the troubles you had maintaining
some else's source code. I want details.
Steve Carroll
2016-12-09 18:38:04 UTC
Permalink
Post by unknown
I often have to maintain or update other people's code
and have seen some truly bizarre, difficult to maintain code.
Many are the product of twisted geniuses, and as long as
the genius maintains it, it's great, but once he's gone,....
You don't need the source code to make a work-alike app;
well... maybe you do, but I don't.
Prove it by coding up a working version of this:

<https://trello.com>

Should be easy ;)
Post by unknown
Please tell us about the troubles you had maintaining
some else's source code. I want details.
There are what you could almost label 'formulas' out there now to show you how to write stuff that is difficult to maintain, here's an example:

<http://typicalprogrammer.com/how-to-develop-unmaintainable-software/>
Michael Moroney
2016-12-10 04:03:32 UTC
Permalink
Post by unknown
I often have to maintain or update other people's code
and have seen some truly bizarre, difficult to maintain code.
Many are the product of twisted geniuses, and as long as
the genius maintains it, it's great, but once he's gone,....
You don't need the source code to make a work-alike app;
well... maybe you do, but I don't.
Please tell us about the troubles you had maintaining
some else's source code. I want details.
Usually not troubles but challenges. In a previous life I worked to
upgrade and maintain a system that ran everything for an organization.
This application was homegrown and heavily modified over the years as
policies and procedures were implemented and changed. And it was obvious
that there were a lot of "cooks" in this soup, each with their own style.
Some of them must have been computer science students as it seems some
wanted to try out whatever esoteric knowledge they just learned even if
there was no need for it. I found recursion, coroutines and self-modifying
code as well as other bizarre stuff I've forgotten, all not necessary.

Much of the problem was the age of some of the code. Manual procedures
were computerized (using PDP-11s) in the 70s, using Macro-11 assembler.
Later the system was switched to the VAX, and much of the PDP-11 assembler
code was run through a converter to produce VAX assembly language code.
That by itself added strangeness, and removed comments. They heavily used
strange macros and the code converter added its own strange macros. And
new code was written in -- VAX Assembly Language. By the time I saw it it
was over 200,000 lines of mostly assembly language. Really newer stuff
was C.

Of course some strangeness was from attempting to squeeze every byte
or every millisecond of CPU time when memory was small and expensive,
laying the code out so the most likely executed path was the fastest
(minimizing branches). Creative optimization of this sort can be rather
strange.

They frequently didn't use system routines or standard APIs, instead often
creating their own versions. Imagine a C coder writing their own code to
convert and print the values of variables instead of just using "printf".
They wrote their own code to implement simple databases, too. File reads
were often done by mapping virtual address space to the data files and
letting the operating system paging mechanism "read" the data in when
accessing its memory addresses. This was probably a left over from
PDP-11's limited address space where they swapped in different overlays
into memory at different times, depending on what the system was doing.

One of the oddest were how they implemented data files of constant or
infrequently changed data. The data tables looked like normal data
tables, but each line of data was actually a VAX assembler Macro call with
many parameters. They compiled (assembled) their data using the macro
assembler and multi-layer macro definitions, linked it with the linker and
used their knowledge of how executable image files are laid out to get
their binary data. The "executables" produced by the linker were the
binary versions of their data tables. Usually the "executables" were read
in using the map to virtual address method.

They implemented their own communication protocol for their homegrown
data terminals (PCs) and remote communication. Later they ran this
protocol over TCP/IP.

Our job was to implement this on more modern hardware, as well as
implement procedure changes as needed. Some of the newer code was C,
we implemented everything in C whenever we could.

Enough for now.

As to rewriting things without old sources, extremely tempting at many
times given how bizarre things were, but management considered new code
as risky. The old code worked well, at least considering the age of the
ancient VAXes it ran on, and they liked it.
unknown
2016-12-10 05:15:56 UTC
Permalink
Post by Michael Moroney
As to rewriting things without old sources, extremely tempting at many
times, given how bizarre things were, but management considered new code
as risky. The old code worked well, at least considering the age of the
ancient VAXes it ran on, and they liked it.
This sounds like a hardware problem to me;
and you lost some " Subject Matter Experts " ( not coders ), I suppose.
I never had to deal with such problems.
Michael Moroney
2016-12-11 01:50:34 UTC
Permalink
Post by unknown
Post by Michael Moroney
As to rewriting things without old sources, extremely tempting at many
times, given how bizarre things were, but management considered new code
as risky. The old code worked well, at least considering the age of the
ancient VAXes it ran on, and they liked it.
This sounds like a hardware problem to me;
and you lost some " Subject Matter Experts " ( not coders ), I suppose.
No, the subject matter experts were quite good, and they were the ones who
came up with the specs for procedure changes or to correct incorrect
behavior.

The VAXes were old, not produced any more and service contracts were
either ridiculously expensive or unavailable. Upgrading to modern
hardware was the right thing to do. But all the VAX-specific code,
much of which was cryptically written, had to be fixed.

You shouldn't keep messing up the subject for this sub-thread.
chrisv
2016-12-09 15:37:23 UTC
Permalink
Post by Michael Moroney
Relf thinks all conventions/standards/etc. don't apply to him. He thinks
everyone else should conform to the way he does things, not the other way
around. He says the subject should be changed each time to reflect what
the post is about but usually when he does so he changes his subject to
reflect the last comment/thought in his post, not necessarily what the
rest of his post is about, so his new subjects are usually chosen poorly.
He's a sociopath.
Post by Michael Moroney
And as to "I'm hard to copy, thank God" I can only shake my head and sigh.
As long as Jeff continues to work on whatever it is he's been working
on for 20+ years, I'm sure things are great. But once Jeff leaves for
whatever reason and someone else has to maintain, change or upgrade it,
I bet it's going to be a real mess. I'll bet the code is truly bizarre,
hard to understand or follow and/or poorly commented, from what I read
here.
Check it out for yourself. It's unbelievable.

http://jeff-relf.me/X.ZIP
--
"(chrisv) claims (Relf's) code is shitty. Let's see him substantiate
it with some facts and a code analysis." - trolling fsckwit
"Ezekiel"
Michael Moroney
2016-12-09 20:32:59 UTC
Permalink
Post by chrisv
Post by Michael Moroney
And as to "I'm hard to copy, thank God" I can only shake my head and sigh.
As long as Jeff continues to work on whatever it is he's been working
on for 20+ years, I'm sure things are great. But once Jeff leaves for
whatever reason and someone else has to maintain, change or upgrade it,
I bet it's going to be a real mess. I'll bet the code is truly bizarre,
hard to understand or follow and/or poorly commented, from what I read
here.
Check it out for yourself. It's unbelievable.
http://jeff-relf.me/X.ZIP
yes, I've seen that before, now that you mention it. Truly bizarre.
chrisv
2016-12-09 12:39:00 UTC
Permalink
*plonk*
Poutnik
2016-12-09 15:19:46 UTC
Permalink
Post by chrisv
*plonk*
So what ?
--
Poutnik ( The Pilgrim, Der Wanderer )

A wise man guards words he says,
as they say about him more,
than he says about the subject.
Silver Slimer
2016-12-09 16:51:41 UTC
Permalink
Post by Poutnik
Post by chrisv
*plonk*
So what ?
chrisv believes that informing everyone of the status of her killfile
somehow empowers her. She is a fat, greasy, disgusting, purple-haired
feminist who believes that men are all inherently evil and that 400-lb
women are sexy when naked.
flatfish+++
2016-12-09 17:07:37 UTC
Permalink
Post by Silver Slimer
Post by Poutnik
Post by chrisv
*plonk*
So what ?
chrisv believes that informing everyone of the status of her killfile
somehow empowers her. She is a fat, greasy, disgusting, purple-haired
feminist who believes that men are all inherently evil and that 400-lb
women are sexy when naked.
It's amazing that she calls herself a Linux advocate but still hasn't
managed to install Linux despite people offering her help. She posts
from Forte' Agent, a Windows program.
--
flatfish+++
mariana trench
Silver Slimer
2016-12-09 17:22:47 UTC
Permalink
Post by flatfish+++
Post by Silver Slimer
Post by Poutnik
Post by chrisv
*plonk*
So what ?
chrisv believes that informing everyone of the status of her killfile
somehow empowers her. She is a fat, greasy, disgusting, purple-haired
feminist who believes that men are all inherently evil and that 400-lb
women are sexy when naked.
It's amazing that she calls herself a Linux advocate but still hasn't
managed to install Linux despite people offering her help. She posts
from Forte' Agent, a Windows program.
I think the more pressing concern is the fact that she's posting images
of herself pissing on the toilet
<http://www.thegloss.com/culture/lena-dunham-naked-cake-toilet-emmys-728/>

I'm not sure if chrisv was trying to be funny or sexy but it's totally
inappropriate.
flatfish+++
2016-12-09 17:28:34 UTC
Permalink
Post by Silver Slimer
Post by flatfish+++
Post by Silver Slimer
Post by Poutnik
Post by chrisv
*plonk*
So what ?
chrisv believes that informing everyone of the status of her killfile
somehow empowers her. She is a fat, greasy, disgusting, purple-haired
feminist who believes that men are all inherently evil and that 400-lb
women are sexy when naked.
It's amazing that she calls herself a Linux advocate but still hasn't
managed to install Linux despite people offering her help. She posts
from Forte' Agent, a Windows program.
I think the more pressing concern is the fact that she's posting images
of herself pissing on the toilet
<http://www.thegloss.com/culture/lena-dunham-naked-cake-toilet-emmys-728/>
I'm not sure if chrisv was trying to be funny or sexy but it's totally
inappropriate.
She's an idiot.
--
flatfish+++
mariana trench
Michael Moroney
2016-12-09 17:52:31 UTC
Permalink
Post by Poutnik
Post by chrisv
*plonk*
So what ?
chrisv likes to publicly plonk anyone who replies to Relf, probably
to discourage them from replying to him and thus make Relf get lonely
and go away. (won't work). I'm not sure if he follows through, he just
responded to me and surely he must have plonked me by now as I have
responded to Relf often.

Relf himself has apparently semi-plonked me. He can't stand common
sense, I guess.

As I stated before I hang around sci.physics to k00kwatch more than
anything else, so to me Relf is worth reading, for his bizarre physics
and programming ideas.
unknown
2016-12-09 18:05:17 UTC
Permalink
Post by Michael Moroney
Relf himself has apparently semi-plonked me.
He can't stand common sense, I guess.
I only have time to read a few select authors, sorry.
When you're not replying to me ( indirectly, 5 levels deep );
your posts are automatically "marked as read" ( Reddit ).
Post by Michael Moroney
As I stated before, I hang around sci.physics to k00kwatch
more than anything else; so, to me, Relf is worth reading,
for his bizarre physics and programming ideas.
Like Mr. ChrisV, you're promoting me. Thanks.
chrisv
2016-12-09 18:26:38 UTC
Permalink
Post by Michael Moroney
chrisv likes to publicly plonk anyone who replies to Relf, probably
to discourage them from replying to him and thus make Relf get lonely
and go away. (won't work).
Well, I do see less of his crap quoted.
Post by Michael Moroney
I'm not sure if he follows through,
I do, but my kill-filters for minor offenses, like quoting Relf,
usually have an expiration date of 30 days to a year.
Post by Michael Moroney
he just responded to me and surely he must have plonked me
by now as I have responded to Relf often.
I give some slack to people who I recognize and respect.
--
'The "community" is ruining what promised to be a great platform.' -
"Hadron" on Android, July 2010
Silver Slimer
2016-12-09 19:06:06 UTC
Permalink
Post by Michael Moroney
Post by Poutnik
Post by chrisv
*plonk*
So what ?
chrisv likes to publicly plonk anyone who replies to Relf, probably
to discourage them from replying to him and thus make Relf get lonely
and go away. (won't work). I'm not sure if he follows through, he just
responded to me and surely he must have plonked me by now as I have
responded to Relf often.
The fact that anyone who uses Eternal September doesn't see Relf's posts
at all might also do it.
Post by Michael Moroney
Relf himself has apparently semi-plonked me. He can't stand common
sense, I guess.
I was sincerely insulted when Relf plonked me. I cried for days on end.
Either that or it's what I want him to believe.
Post by Michael Moroney
As I stated before I hang around sci.physics to k00kwatch more than
anything else, so to me Relf is worth reading, for his bizarre physics
and programming ideas.
I can't imagine any planet where Relf is worth reading personally.
Chris Ahlstrom
2016-12-10 00:56:15 UTC
Permalink
Michael Moroney wrote this copyrighted missive and expects royalties:
"Moron"-ey? If that ain't a troll nym! :-D
--
You attempt things that you do not even plan because of your extreme stupidity.
Silver Slimer
2016-12-10 14:23:37 UTC
Permalink
Post by Chris Ahlstrom
"Moron"-ey? If that ain't a troll nym! :-D
So is Ass-Storm.
--
Silver Slimer
Fingerprint: e58428b2633833a3b0c9bb7e40819166642245b7
Gab.ai: @silverslimer
"Turning crap into solid gold since 1979"
f***@gmail.com
2016-12-09 15:17:57 UTC
Permalink
Post by unknown
Only _results_ matter; i.e.: What does it do ?
How you code, in what language, isn't interesting.
That is exactly fucking correct.

As any competent person knows, programming is NOT about coding.
Computer programming is primarily a problem solving activity
that employs the concepts of computer science to conceive an
efficient, and perhaps even elegant, solution. The actual coding
is only a SECONDARY concern.

In fact, it is a mark of programming naivete to emphasize coding
as the primary goal.

The dumb-fuck stooge (DFS) only demonstrates his pathetic
programming ineptitude when he extolls his ridiculous code
snippets, which usually involve only simplistic string manipulations,
merely to show off what he foolishly considers a major
accomplishment. But the ideas behind his coding schemes are so
simplistic and so shoddy as to be downright laughable.

A true programmer first analyzes the underlying concepts, selects
the most appropriate data structures, and then develops the
most efficient and scalable algorithm. Only after this critical
groundwork is laid does any consideration of coding begin.

But alas, the art of computer programming has fallen by the
wayside. The advent of high-level OO languages, such as the
junk-shit known as C#/.NET, allows even a totally naïve idiot
to be able to produce commercially acceptable code. In fact,
most commercial programmers have little or no background in
computer science. In today's world of cheap gimmicks and rapid
product churn a solid programming expertise is not really necessary.
Melzzzzz
2016-12-09 02:38:17 UTC
Permalink
On Wed, 7 Dec 2016 12:27:40 -0500
Post by DFS
10-Mar-1998
20-Aug-1997
06-Sep-2009
23-Jan-2010
05-Nov-2010
03-Sep-2009
07-Nov-2014
08-Mar-2013
My 5-line solution (python data structures only)
----------------------------------------------------------------
dt=['10-Mar-1998','20-Aug-1997','06-Sep-2009','23-Jan-2010','05-Nov-2010','03-Sep-2009','07-Nov-2014','08-Mar-2013']
m=[('Dec','12'),('Nov','11'),('Oct','10'),('Sep','09'),('Aug','08'),('Jul','07'),('Jun','06'),('May','05'),('Apr','04'),('Mar','03'),('Feb','02'),('Jan','01')]
dt2=[]
for d in dt:dt2.append((d[-4:]+dict(m)[d[3:6]]+d[:2],d))
print min(dt2)[1]+'\n'+max(dt2)[1]
----------------------------------------------------------------
$python getminmax.py
20-Aug-1997
07-Nov-2014
<quote>
My children, both were introduced to Linux when in grade 9-10.
By the time they left high school they were capable of installing and
configuring their own Linux systems. Now they are in university, one
is in 4th year doing mathematics concentrating on discrete
mathematics, hoping to do masters in AI. The other is in 3rd year CS.
They can both code circles around you.
</quote>
Bring those little idiots on! If they can code circles around me,
they can replicate that functionality in another language, in approx
the same # of lines, using only builtin data structures.
Golang:
It would be lot less involving if you used one of standard date formats.

[***@maxa-pc hello]$ ./date_sort
20-08-1997
10-03-1998
03-09-2009
06-09-2009
23-01-2010
05-11-2010
08-03-2013
07-11-2014

[***@maxa-pc hello]$ cat date_sort.go
package main

import (
"fmt"
"time"
"sort"
)

type MyTime []time.Time

func cvtMonth (s string) time.Month {
mmap := map[string]int{
"Jan":1,
"Feb":2,
"Mar":3,
"Apr":4,
"May":5,
"Jun":6,
"Jul":7,
"Aug":8,
"Sep":9,
"Oct":10,
"Nov":11,
}
return time.Month(mmap[s])
}
func main() {
dates := []string{"10-Mar-1998","20-Aug-1997","06-Sep-2009","23-Jan-2010",
"05-Nov-2010","03-Sep-2009","07-Nov-2014","08-Mar-2013"}
cnvrtd := make(MyTime,0)
for _,v := range dates {
var year,day int
var month string
fmt.Sscanf(v,"%2d-%3s-%4d",&day,&month,&year)
cnvrtd = append(cnvrtd,time.Date(year,cvtMonth(month),day,0,0,0,0,time.UTC))
}
sort.Sort(cnvrtd)
fmt.Println(cnvrtd)
}

func (this MyTime) Less(i,j int) bool {
return this[i].Before(this[j])
}

func (this MyTime) Len()int {
return len(this)
}

func (this MyTime) Swap(i,j int) {
this[i],this[j] = this[j],this[i]
}

func (this MyTime) String() (rc string) {
for i := range this {
rc+=fmt.Sprintf("%02d-%02d-%04d\n",this[i].Day(),this[i].Month(),this[i].Year())
}
return
}
--
press any key to continue or any other to quit
deplorable owl
2016-12-09 19:00:26 UTC
Permalink
Post by Melzzzzz
On Wed, 7 Dec 2016 12:27:40 -0500
Post by DFS
10-Mar-1998
20-Aug-1997
06-Sep-2009
23-Jan-2010
05-Nov-2010
03-Sep-2009
07-Nov-2014
08-Mar-2013
...
Post by Melzzzzz
Post by DFS
Bring those little idiots on! If they can code circles around me,
they can replicate that functionality in another language, in approx
the same # of lines, using only builtin data structures.
It would be lot less involving if you used one of standard date formats.
20-08-1997
10-03-1998
03-09-2009
06-09-2009
23-01-2010
05-11-2010
08-03-2013
07-11-2014
package main
import (
"fmt"
...
Times for bash, python, go, and C:

***@lowtide:~/code/dfsdates$ time . blah
20-Aug-1997
07-Nov-2014

real 0m0.042s
user 0m0.000s
sys 0m0.008s
***@lowtide:~/code/dfsdates$ time python getminmax.py
20-Aug-1997
07-Nov-2014

real 0m0.031s
user 0m0.020s
sys 0m0.008s
***@lowtide:~/code/dfsdates$ time ./date_sort
20-08-1997
10-03-1998
03-09-2009
06-09-2009
23-01-2010
05-11-2010
08-03-2013
07-11-2014


real 0m0.003s
user 0m0.000s
sys 0m0.000s
***@lowtide:~/code/dfsdates$ time ./flah
20-Aug-1997
07-Nov-2014

real 0m0.001s
user 0m0.000s
sys 0m0.004s
***@lowtide:~/code/dfsdates$

flah.c:
---------------------------------------
#include <stdio.h>
#define __USE_XOPEN
#include <time.h>
#include <string.h>
#include <stdlib.h>

struct mdy {
int d;
int m;
int y;
};

long getints(struct mdy *, char *);
int compar(const void *,const void *);

int main(int argc, char *argv[])
{
char * dates[] = {
"10-Mar-1998",
"20-Aug-1997",
"06-Sep-2009",
"23-Jan-2010",
"05-Nov-2010",
"03-Sep-2009",
"07-Nov-2014",
"08-Mar-2013"
};

int datecount=sizeof(dates)/sizeof(dates[0]);
time_t seconds=0;
struct tm mytm={0};
struct mdy mymdy={0};
long mylongs[datecount];
long i=0;
char buf[100]={0};

for(i=0;i<datecount;i++)
{
getints(&mymdy,dates[i]);

mytm.tm_mday=mymdy.d;
mytm.tm_mon=mymdy.m;
mytm.tm_year=mymdy.y-1900;

seconds=mktime(&mytm);
mylongs[i]=(long)seconds;
}

qsort(mylongs,datecount,sizeof(long),compar);

strftime(buf,sizeof buf,"%d-%b-%Y",
localtime((time_t *)&mylongs[0]));
printf("%s\n",buf);
strftime(buf,sizeof buf,"%d-%b-%Y",
localtime((time_t *)&mylongs[datecount-1]));
printf("%s\n",buf);

return 0;
}

long getints(struct mdy *themdy, char *str)
{
char *months[]={"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"};
char *token;
char *delim="-";
int i=0;
int j=0;
char arr[12]={0};
strcpy(arr,str);
token=strtok(arr,delim);
themdy->d=atoi(token);
while(token!=NULL)
{
i++;
token=strtok(NULL,delim);
if(i==1)
{
for(j=0;j<12;j++)
{
if( !strcmp(token,months[j]) )
{
themdy->m=j;
}
}
}
if(i==2)
{
themdy->y=atoi(token);
}
}
return 0;
}

int compar(const void *a,const void *b)
{
return ( *(long *)a -*(long *)b );
}
---------------------------------------
Melzzzzz
2016-12-09 23:33:52 UTC
Permalink
On Fri, 9 Dec 2016 19:00:26 +0000 (UTC)
Post by DFS
Post by Melzzzzz
On Wed, 7 Dec 2016 12:27:40 -0500
Post by DFS
10-Mar-1998
20-Aug-1997
06-Sep-2009
23-Jan-2010
05-Nov-2010
03-Sep-2009
07-Nov-2014
08-Mar-2013
...
Post by Melzzzzz
Post by DFS
Bring those little idiots on! If they can code circles around me,
they can replicate that functionality in another language, in
approx the same # of lines, using only builtin data structures.
It would be lot less involving if you used one of standard date formats.
20-08-1997
10-03-1998
03-09-2009
06-09-2009
23-01-2010
05-11-2010
08-03-2013
07-11-2014
package main
import (
"fmt"
...
20-Aug-1997
07-Nov-2014
real 0m0.042s
user 0m0.000s
sys 0m0.008s
20-Aug-1997
07-Nov-2014
real 0m0.031s
user 0m0.020s
sys 0m0.008s
20-08-1997
10-03-1998
03-09-2009
06-09-2009
23-01-2010
05-11-2010
08-03-2013
07-11-2014
real 0m0.003s
user 0m0.000s
sys 0m0.000s
20-Aug-1997
07-Nov-2014
real 0m0.001s
user 0m0.000s
sys 0m0.004s
---------------------------------------
#include <stdio.h>
#define __USE_XOPEN
#include <time.h>
#include <string.h>
#include <stdlib.h>
struct mdy {
int d;
int m;
int y;
};
long getints(struct mdy *, char *);
int compar(const void *,const void *);
int main(int argc, char *argv[])
{
char * dates[] = {
"10-Mar-1998",
"20-Aug-1997",
"06-Sep-2009",
"23-Jan-2010",
"05-Nov-2010",
"03-Sep-2009",
"07-Nov-2014",
"08-Mar-2013"
};
int datecount=sizeof(dates)/sizeof(dates[0]);
time_t seconds=0;
struct tm mytm={0};
struct mdy mymdy={0};
long mylongs[datecount];
long i=0;
char buf[100]={0};
for(i=0;i<datecount;i++)
{
getints(&mymdy,dates[i]);
mytm.tm_mday=mymdy.d;
mytm.tm_mon=mymdy.m;
mytm.tm_year=mymdy.y-1900;
seconds=mktime(&mytm);
mylongs[i]=(long)seconds;
}
qsort(mylongs,datecount,sizeof(long),compar);
strftime(buf,sizeof buf,"%d-%b-%Y",
localtime((time_t *)&mylongs[0]));
printf("%s\n",buf);
strftime(buf,sizeof buf,"%d-%b-%Y",
localtime((time_t *)&mylongs[datecount-1]));
printf("%s\n",buf);
return 0;
}
long getints(struct mdy *themdy, char *str)
{
char *months[]={"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"};
char *token;
char *delim="-";
int i=0;
int j=0;
char arr[12]={0};
strcpy(arr,str);
token=strtok(arr,delim);
themdy->d=atoi(token);
while(token!=NULL)
{
i++;
token=strtok(NULL,delim);
if(i==1)
{
for(j=0;j<12;j++)
{
if( !strcmp(token,months[j]) )
{
themdy->m=j;
}
}
}
if(i==2)
{
themdy->y=atoi(token);
}
}
return 0;
}
int compar(const void *a,const void *b)
{
return ( *(long *)a -*(long *)b );
}
---------------------------------------
Try to generate then sort ;p

[***@maxa-pc hello]$ time ./date_sort
93172 unique dates

03-Jan-0030
05-Jan-0030
11-Jan-0030
14-Jan-0030
16-Jan-0030
23-Jan-0030
28-Jan-0030
31-Jan-0030
07-Feb-0030
09-Feb-0030

25-Oct-2015
01-Nov-2015
05-Nov-2015
15-Nov-2015
22-Nov-2015
24-Nov-2015
01-Dec-2015
27-Dec-2015
28-Dec-2015
30-Dec-2015


real 0m0.344s
user 0m0.417s
sys 0m0.010s
[***@maxa-pc hello]$ cat date_sort.go
package main

import (
"fmt"
"math/rand"
"time"
"sort"
)

type MyTime []time.Time

func cvtToMonth (s string) time.Month {
mmap := map[string]int{
"Jan":1,
"Feb":2,
"Mar":3,
"Apr":4,
"May":5,
"Jun":6,
"Jul":7,
"Aug":8,
"Sep":9,
"Oct":10,
"Nov":11,
"Dec":12,
}
return time.Month(mmap[s])
}

func cvtFromMonth(in time.Month) string {
months := []string{"","Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"}
return months[int(in)]
}

func main() {
rand.Seed(time.Now().Unix())
dates := GenDates(30,2015,100000)
cnvrtd := make(MyTime,0)
for k,_ := range dates {
var year,day int
var month string
fmt.Sscanf(k,"%2d-%3s-%4d",&day,&month,&year)
cnvrtd = append(cnvrtd,time.Date(year,cvtToMonth(month),day,0,0,0,0,time.UTC))
}
fmt.Printf("%d unique dates\n\n",len(dates))
sort.Sort(cnvrtd)
first10 := cnvrtd[:10]
last10 := cnvrtd[len(cnvrtd)-10:]
fmt.Println(first10)
fmt.Println(last10)
}

func (this MyTime) Less(i,j int) bool {
return this[i].Before(this[j])
}

func (this MyTime) Len()int {
return len(this)
}

func (this MyTime) Swap(i,j int) {
this[i],this[j] = this[j],this[i]
}

func (this MyTime) String() (rc string) {
for i := range this {
rc+=fmt.Sprintf("%02d-%3s-%04d\n",this[i].Day(),
cvtFromMonth(this[i].Month()),this[i].Year())
}
return
}

func random(min, max int) int {
return rand.Intn(max - min + 1) + min
}

func GenDates(minyear,maxyear,count int) map[string]int {
rc := make(map[string]int,0)
for i := 0;i<count;i++ {
r := time.Date(random(minyear,maxyear),time.Month(random(1,12)),random(1,31),
0,0,0,0,time.UTC)
rc [fmt.Sprintf("%2d-%3s-%4d",r.Day(),
cvtFromMonth(r.Month()),r.Year())]++
}
return rc
}
--
press any key to continue or any other to quit
deplorable owl
2016-12-10 05:24:55 UTC
Permalink
Post by Melzzzzz
Try to generate then sort ;p
93172 unique dates
03-Jan-0030
05-Jan-0030
11-Jan-0030
14-Jan-0030
16-Jan-0030
23-Jan-0030
28-Jan-0030
31-Jan-0030
07-Feb-0030
09-Feb-0030
25-Oct-2015
01-Nov-2015
05-Nov-2015
15-Nov-2015
22-Nov-2015
24-Nov-2015
01-Dec-2015
27-Dec-2015
28-Dec-2015
30-Dec-2015
real 0m0.344s
user 0m0.417s
sys 0m0.010s
package main
...
Here's how yours runs on my machine:
***@lowtide:~/code/dfsdates$ time ./date_sort
93184 unique dates

22-Jan-0030
24-Jan-0030
26-Jan-0030
28-Jan-0030
09-Feb-0030
11-Feb-0030
12-Feb-0030
28-Feb-0030
08-Mar-0030
15-Mar-0030

17-Oct-2015
31-Oct-2015
02-Nov-2015
06-Nov-2015
13-Nov-2015
27-Nov-2015
29-Nov-2015
01-Dec-2015
08-Dec-2015
14-Dec-2015


real 0m0.719s
user 0m0.700s
sys 0m0.016s
***@lowtide:~/code/dfsdates$

Melzzz you are evil.
DAMN those randoms!. 86400 seconds per day and 100,000 days! Here's my
attempt at it (There's probably some dupes in there somewhere, but
I'm just stabbing in the dark. I'm sure you probably know a better
C approach).

***@lowtide:~/code/dfsdates$ time ./glah
---------------------------------
unsorted:

rannum[0]: 0: 31-Dec-1969
rannum[1]: 5673506200: 14-Oct-2149
rannum[2]: -3422670840: 16-Jul-1861
rannum[3]: 1639072836: 09-Dec-2021
rannum[4]: 633999516: 02-Feb-1990
...
rannum[99995]: 612173732: 26-May-1989
rannum[99996]: 681534972: 06-Aug-1991
rannum[99997]: -166082715: 26-Sep-1964
rannum[99998]: 0: 31-Dec-1969
rannum[99999]: 4202178830: 01-Mar-2103
---------------------------------
sorted:

rannum[0]: -8587301344: 16-Nov-1697
rannum[1]: -8586063768: 01-Dec-1697
rannum[2]: -8584082936: 23-Dec-1697
rannum[3]: -8581681672: 20-Jan-1698
rannum[4]: -8581265688: 25-Jan-1698
...
rannum[99995]: 8585401864: 22-Jan-2242
rannum[99996]: 8586649096: 06-Feb-2242
rannum[99997]: 8586863576: 08-Feb-2242
rannum[99998]: 8588090632: 22-Feb-2242
rannum[99999]: 8589213816: 07-Mar-2242

real 0m0.021s
user 0m0.020s
sys 0m0.000s
***@lowtide:~/code/dfsdates$

glah.c:
---------------------------------------------------------------
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <limits.h>

struct mdy {
int d;
int m;
int y;
};

long getints(struct mdy *, char *);
int compar(const void *,const void *);
int printarray(int64_t *,int);

int main(int argc, char *argv[])
{
long i=0;

int64_t rannum[100000];
srandom(time(NULL)+getpid());

for(i=0;i<100000;i++)
{
rannum[i]=random()%INT_MAX+(-INT_MAX/2);
rannum[i]*=random()%9;
}
printf("---------------------------------\n");
printf("unsorted:\n");
printf("\n");
printf("sorted:\n");
printarray(rannum,0);
printarray(rannum,1);
printarray(rannum,2);
printarray(rannum,3);
printarray(rannum,4);
printf("...\n");
printarray(rannum,99995);
printarray(rannum,99996);
printarray(rannum,99997);
printarray(rannum,99998);
printarray(rannum,99999);

qsort(rannum,100000,sizeof(long long),compar);

printf("---------------------------------\n");
printf("sorted:\n");
printf("\n");
printarray(rannum,0);
printarray(rannum,1);
printarray(rannum,2);
printarray(rannum,3);
printarray(rannum,4);
printf("...\n");
printarray(rannum,99995);
printarray(rannum,99996);
printarray(rannum,99997);
printarray(rannum,99998);
printarray(rannum,99999);

return 0;
}

long getints(struct mdy *themdy, char *str)
{
char *months[]={"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"};
char *token;
char *delim="-";
int i=0;
int j=0;
char arr[12]={0};
strcpy(arr,str);
token=strtok(arr,delim);
themdy->d=atoi(token);
while(token!=NULL)
{
i++;
token=strtok(NULL,delim);
if(i==1)
{
for(j=0;j<12;j++)
{
if( !strcmp(token,months[j]) )
{
themdy->m=j;
}
}
}
if(i==2)
{
themdy->y=atoi(token);
}
}
return 0;
}

int compar(const void *a,const void *b)
{
if( *(long long *)a < *(long long *)b)
{
return -1;
}
else if( *(long long *)a > *(long long *)b)
{
return 1;
}
else
{
return 0;
}
}

int printarray(int64_t *rannum,int x)
{
char buf[100]={0};

printf("rannum[%d]: %lld: ",x,(long long)rannum[x]);
strftime(buf,sizeof buf,"%d-%b-%Y",
localtime((time_t *)&rannum[x]));
printf("%s\n",buf);
return 0;
}
---------------------------------------------------------------
Melzzzzz
2016-12-10 05:54:15 UTC
Permalink
Post by deplorable owl
Post by Melzzzzz
Try to generate then sort ;p
93172 unique dates
03-Jan-0030
05-Jan-0030
11-Jan-0030
14-Jan-0030
16-Jan-0030
23-Jan-0030
28-Jan-0030
31-Jan-0030
07-Feb-0030
09-Feb-0030
25-Oct-2015
01-Nov-2015
05-Nov-2015
15-Nov-2015
22-Nov-2015
24-Nov-2015
01-Dec-2015
27-Dec-2015
28-Dec-2015
30-Dec-2015
real 0m0.344s
user 0m0.417s
sys 0m0.010s
package main
...
93184 unique dates
22-Jan-0030
24-Jan-0030
26-Jan-0030
28-Jan-0030
09-Feb-0030
11-Feb-0030
12-Feb-0030
28-Feb-0030
08-Mar-0030
15-Mar-0030
17-Oct-2015
31-Oct-2015
02-Nov-2015
06-Nov-2015
13-Nov-2015
27-Nov-2015
29-Nov-2015
01-Dec-2015
08-Dec-2015
14-Dec-2015
real 0m0.719s
user 0m0.700s
sys 0m0.016s
Melzzz you are evil.
DAMN those randoms!. 86400 seconds per day and 100,000 days! Here's my
attempt at it (There's probably some dupes in there somewhere, but
I'm just stabbing in the dark. I'm sure you probably know a better
C approach).
Nah, you have to create strings in DFS's format, then parse those
strings ;p It's not same program ;)
I wouldn't do it in C as I have to implement hash table first ;)
Or just create 100k random dates in one list then parse, with dupes.
--
press any key to continue or any other to quit...
deplorable owl
2016-12-10 06:25:48 UTC
Permalink
Post by Melzzzzz
Post by deplorable owl
Post by Melzzzzz
Try to generate then sort ;p
93172 unique dates
03-Jan-0030
05-Jan-0030
11-Jan-0030
14-Jan-0030
16-Jan-0030
23-Jan-0030
28-Jan-0030
31-Jan-0030
07-Feb-0030
09-Feb-0030
25-Oct-2015
01-Nov-2015
05-Nov-2015
15-Nov-2015
22-Nov-2015
24-Nov-2015
01-Dec-2015
27-Dec-2015
28-Dec-2015
30-Dec-2015
real 0m0.344s
user 0m0.417s
sys 0m0.010s
package main
...
93184 unique dates
22-Jan-0030
24-Jan-0030
26-Jan-0030
28-Jan-0030
09-Feb-0030
11-Feb-0030
12-Feb-0030
28-Feb-0030
08-Mar-0030
15-Mar-0030
17-Oct-2015
31-Oct-2015
02-Nov-2015
06-Nov-2015
13-Nov-2015
27-Nov-2015
29-Nov-2015
01-Dec-2015
08-Dec-2015
14-Dec-2015
real 0m0.719s
user 0m0.700s
sys 0m0.016s
Melzzz you are evil.
DAMN those randoms!. 86400 seconds per day and 100,000 days! Here's my
attempt at it (There's probably some dupes in there somewhere, but
I'm just stabbing in the dark. I'm sure you probably know a better
C approach).
Nah, you have to create strings in DFS's format, then parse those
strings ;p It's not same program ;)
I create teh strings in DFS format. I just do it last. :)
Post by Melzzzzz
I wouldn't do it in C as I have to implement hash table first ;)
Or just create 100k random dates in one list then parse, with dupes.
I noticed I left a whole function in there from the other code
that isn't even used.

BTW, what's the proper approach to randomizing such a huge number of
values? (A large enough pool of seconds so that randoms would have
a good chance of falling on 100,000 different days).
Melzzzzz
2016-12-10 06:28:22 UTC
Permalink
Post by deplorable owl
BTW, what's the proper approach to randomizing such a huge number of
values? (A large enough pool of seconds so that randoms would have
a good chance of falling on 100,000 different days).
You don't have to just filter out dupes ;p
It is not needed to have 100000k uniques at all.
--
press any key to continue or any other to quit...
deplorable owl
2016-12-10 19:56:49 UTC
Permalink
Post by Melzzzzz
Post by deplorable owl
BTW, what's the proper approach to randomizing such a huge number of
values? (A large enough pool of seconds so that randoms would have
a good chance of falling on 100,000 different days).
You don't have to just filter out dupes ;p
It is not needed to have 100000k uniques at all.
Yeah, but filtering is just to get uniques. Say you want 100000 unique
days using random second values, minimizing dups and generating exactly
100000 values, how would you approach that? rand() and random() both work
over range 0-RAND_MAX, which on my system is a range of 2.14 billion.
There are 8.64 billion seconds in 100,000 days. Maybe stitch larger
numbers from smaller random pieces? I used a random multiplier of 0-9
over +/-(1 billion), hoping to get range from +/-(9 billion) but that's
not working great.
DFS
2016-12-10 20:19:18 UTC
Permalink
Post by deplorable owl
Post by Melzzzzz
Post by deplorable owl
BTW, what's the proper approach to randomizing such a huge number of
values? (A large enough pool of seconds so that randoms would have
a good chance of falling on 100,000 different days).
You don't have to just filter out dupes ;p
It is not needed to have 100000k uniques at all.
Yeah, but filtering is just to get uniques. Say you want 100000 unique
days using random second values, minimizing dups and generating exactly
100000 values, how would you approach that?
1. Write 100K random dates to a table with a PK

2. Count the rows - it would very likely be less than 100K

3. Write 10 or 100 or 1000 more randoms at a time and test the row
count after every set.

4. When you get to 100K rows, read them back into an array (and shuffle
it if you need it in random order)?
Post by deplorable owl
rand() and random() both work
over range 0-RAND_MAX, which on my system is a range of 2.14 billion.
There are 8.64 billion seconds in 100,000 days. Maybe stitch larger
numbers from smaller random pieces? I used a random multiplier of 0-9
over +/-(1 billion), hoping to get range from +/-(9 billion) but that's
not working great.
DFS
2016-12-10 20:23:32 UTC
Permalink
Post by deplorable owl
Post by Melzzzzz
Post by deplorable owl
BTW, what's the proper approach to randomizing such a huge number of
values? (A large enough pool of seconds so that randoms would have
a good chance of falling on 100,000 different days).
You don't have to just filter out dupes ;p
It is not needed to have 100000k uniques at all.
Yeah, but filtering is just to get uniques. Say you want 100000 unique
days using random second values, minimizing dups and generating exactly
100000 values, how would you approach that?
1. Write 100K random dates to a table with a PK

2. Count the rows - it would very likely be less than 100K

3. Write 1 more random at a time and test the row count after every
INSERT, until you hit exactly 100K.

4. Read them back into an array (and shuffle it if you need it in
random order)?
Post by deplorable owl
rand() and random() both work
over range 0-RAND_MAX, which on my system is a range of 2.14 billion.
There are 8.64 billion seconds in 100,000 days. Maybe stitch larger
numbers from smaller random pieces? I used a random multiplier of 0-9
over +/-(1 billion), hoping to get range from +/-(9 billion) but that's
not working great.
deplorable owl
2016-12-10 20:44:24 UTC
Permalink
Post by DFS
Post by deplorable owl
Post by Melzzzzz
Post by deplorable owl
BTW, what's the proper approach to randomizing such a huge number of
values? (A large enough pool of seconds so that randoms would have
a good chance of falling on 100,000 different days).
You don't have to just filter out dupes ;p
It is not needed to have 100000k uniques at all.
Yeah, but filtering is just to get uniques. Say you want 100000 unique
days using random second values, minimizing dups and generating exactly
100000 values, how would you approach that?
1. Write 100K random dates to a table with a PK
2. Count the rows - it would very likely be less than 100K
3. Write 1 more random at a time and test the row count after every
INSERT, until you hit exactly 100K.
4. Read them back into an array (and shuffle it if you need it in
random order)?
It's not really about dates -- that's just the application here -- but
about the number range. The problem is generating the random seconds.
100,000 days is 8.64 billion seconds. How to get a random generation,
minimizing dups, while generating exactly 100,000 values (not after
stripping dups, but for exactly 100,000 iterations), over such a huge
range when rand() and random() work over a range of 0-RAND_MAX, which
is a range of 0-2.14 billion.
Post by DFS
Post by deplorable owl
rand() and random() both work
over range 0-RAND_MAX, which on my system is a range of 2.14 billion.
There are 8.64 billion seconds in 100,000 days. Maybe stitch larger
numbers from smaller random pieces? I used a random multiplier of 0-9
over +/-(1 billion), hoping to get range from +/-(9 billion) but that's
not working great.
DFS
2016-12-10 22:55:47 UTC
Permalink
Post by deplorable owl
Post by DFS
Post by deplorable owl
Post by Melzzzzz
Post by deplorable owl
BTW, what's the proper approach to randomizing such a huge number of
values? (A large enough pool of seconds so that randoms would have
a good chance of falling on 100,000 different days).
You don't have to just filter out dupes ;p
It is not needed to have 100000k uniques at all.
Yeah, but filtering is just to get uniques. Say you want 100000 unique
days using random second values, minimizing dups and generating exactly
100000 values, how would you approach that?
1. Write 100K random dates to a table with a PK
2. Count the rows - it would very likely be less than 100K
3. Write 1 more random at a time and test the row count after every
INSERT, until you hit exactly 100K.
4. Read them back into an array (and shuffle it if you need it in
random order)?
It's not really about dates -- that's just the application here -- but
about the number range. The problem is generating the random seconds.
100,000 days is 8.64 billion seconds. How to get a random generation,
minimizing dups, while generating exactly 100,000 values (not after
stripping dups, but for exactly 100,000 iterations), over such a huge
range when rand() and random() work over a range of 0-RAND_MAX, which
is a range of 0-2.14 billion.
You don't need to generate 8,640,000,000 randoms at once.

Gen 100K randoms for the days and 100K randoms for the seconds, then
concatenate them.

rand1: 20090615
rand2: 134530

becomes 2009-06-15 13:45:30
Post by deplorable owl
Post by DFS
Post by deplorable owl
rand() and random() both work
over range 0-RAND_MAX, which on my system is a range of 2.14 billion.
There are 8.64 billion seconds in 100,000 days. Maybe stitch larger
numbers from smaller random pieces? I used a random multiplier of 0-9
over +/-(1 billion), hoping to get range from +/-(9 billion) but that's
not working great.
deplorable owl
2016-12-11 00:02:20 UTC
Permalink
Post by DFS
Post by deplorable owl
Post by DFS
Post by deplorable owl
Post by Melzzzzz
Post by deplorable owl
BTW, what's the proper approach to randomizing such a huge number of
values? (A large enough pool of seconds so that randoms would have
a good chance of falling on 100,000 different days).
You don't have to just filter out dupes ;p
It is not needed to have 100000k uniques at all.
Yeah, but filtering is just to get uniques. Say you want 100000 unique
days using random second values, minimizing dups and generating exactly
100000 values, how would you approach that?
1. Write 100K random dates to a table with a PK
2. Count the rows - it would very likely be less than 100K
3. Write 1 more random at a time and test the row count after every
INSERT, until you hit exactly 100K.
4. Read them back into an array (and shuffle it if you need it in
random order)?
It's not really about dates -- that's just the application here -- but
about the number range. The problem is generating the random seconds.
100,000 days is 8.64 billion seconds. How to get a random generation,
minimizing dups, while generating exactly 100,000 values (not after
stripping dups, but for exactly 100,000 iterations), over such a huge
range when rand() and random() work over a range of 0-RAND_MAX, which
is a range of 0-2.14 billion.
You don't need to generate 8,640,000,000 randoms at once.
Gen 100K randoms for the days and 100K randoms for the seconds, then
concatenate them.
rand1: 20090615
rand2: 134530
becomes 2009-06-15 13:45:30
Which is still a day value of 20090615.
86400 different seconds values will fall on that day, hence the
huge number of seconds values required for 100000 unique days.

***@lowtide:~/code/dfsdates$ date -d "2009-06-15 13:45:30" +%s
1245087930
***@lowtide:~/code/dfsdates$ date -d "2009-06-15 4:10:12" +%s
1245053412
***@lowtide:~/code/dfsdates$ date -d @1245087930 +%d-%b-%Y
15-Jun-2009
***@lowtide:~/code/dfsdates$ date -d @1245053412 +%d-%b-%Y
15-Jun-2009
***@lowtide:~/code/dfsdates$

You can easily cheat and generate all seconds values sequentially over a
273 year period, then enter them modulo 86400 into an array of 100000, but
that's an *ordered* array, and what you want is randoms. (Randomizing the
100000 is not a problem, but that avoids the challenge). Generating the
random seconds that give 100000 unique *day* values (well, fewest dups)
for those seconds is the difficulty. Again, I don't care about this as
a "date" problem. I want to know the best approach for randomizing
over a huge range (far exceeding RAND_MAX) with minimal dups.
DFS
2016-12-11 00:39:18 UTC
Permalink
Post by deplorable owl
Post by DFS
Post by deplorable owl
Post by DFS
Post by deplorable owl
Post by Melzzzzz
Post by deplorable owl
BTW, what's the proper approach to randomizing such a huge number of
values? (A large enough pool of seconds so that randoms would have
a good chance of falling on 100,000 different days).
You don't have to just filter out dupes ;p
It is not needed to have 100000k uniques at all.
Yeah, but filtering is just to get uniques. Say you want 100000 unique
days using random second values, minimizing dups and generating exactly
100000 values, how would you approach that?
1. Write 100K random dates to a table with a PK
2. Count the rows - it would very likely be less than 100K
3. Write 1 more random at a time and test the row count after every
INSERT, until you hit exactly 100K.
4. Read them back into an array (and shuffle it if you need it in
random order)?
It's not really about dates -- that's just the application here -- but
about the number range. The problem is generating the random seconds.
100,000 days is 8.64 billion seconds. How to get a random generation,
minimizing dups, while generating exactly 100,000 values (not after
stripping dups, but for exactly 100,000 iterations), over such a huge
range when rand() and random() work over a range of 0-RAND_MAX, which
is a range of 0-2.14 billion.
You don't need to generate 8,640,000,000 randoms at once.
Gen 100K randoms for the days and 100K randoms for the seconds, then
concatenate them.
rand1: 20090615
rand2: 134530
becomes 2009-06-15 13:45:30
Which is still a day value of 20090615.
86400 different seconds values will fall on that day, hence the
huge number of seconds values required for 100000 unique days.
If you're concerned about randomness and uniqueness, you don't need to
generate 86,400 random numbers per day. All you need is 100K numbers
for the days, and 100K numbers for the seconds. For all 100K days.

Each random number from the 100K pool is just as random as one chosen
from a pool of 86,400 generated each day. You're not necessarily going
to get more unique numbers just by doing a random generation every day.

http://preshing.com/20121224/how-to-generate-a-sequence-of-unique-random-integers/
Post by deplorable owl
1245087930
1245053412
15-Jun-2009
15-Jun-2009
You can easily cheat and generate all seconds values sequentially over a
273 year period, then enter them modulo 86400 into an array of 100000, but
that's an *ordered* array, and what you want is randoms. (Randomizing the
100000 is not a problem, but that avoids the challenge). Generating the
random seconds that give 100000 unique *day* values (well, fewest dups)
for those seconds is the difficulty. Again, I don't care about this as
a "date" problem. I want to know the best approach for randomizing
over a huge range (far exceeding RAND_MAX) with minimal dups.
So you're not actually concerned about getting 100K random dates and
times?

Sounds like you're into a math problem: maybe post on sci.math
DFS
2016-12-11 00:56:18 UTC
Permalink
Post by DFS
Post by deplorable owl
Post by DFS
Post by deplorable owl
Post by Melzzzzz
Post by deplorable owl
BTW, what's the proper approach to randomizing such a huge number of
values? (A large enough pool of seconds so that randoms would have
a good chance of falling on 100,000 different days).
You don't have to just filter out dupes ;p
It is not needed to have 100000k uniques at all.
Yeah, but filtering is just to get uniques. Say you want 100000 unique
days using random second values, minimizing dups and generating exactly
100000 values, how would you approach that?
1. Write 100K random dates to a table with a PK
2. Count the rows - it would very likely be less than 100K
3. Write 1 more random at a time and test the row count after every
INSERT, until you hit exactly 100K.
4. Read them back into an array (and shuffle it if you need it in
random order)?
It's not really about dates -- that's just the application here -- but
about the number range. The problem is generating the random seconds.
100,000 days is 8.64 billion seconds. How to get a random generation,
minimizing dups, while generating exactly 100,000 values (not after
stripping dups, but for exactly 100,000 iterations), over such a huge
range when rand() and random() work over a range of 0-RAND_MAX, which
is a range of 0-2.14 billion.
You don't need to generate 8,640,000,000 randoms at once.
Gen 100K randoms for the days and 100K randoms for the seconds, then
concatenate them.
rand1: 20090615
rand2: 134530
becomes 2009-06-15 13:45:30
It won't be that easy, of course.

Unless you use my days 1-28 hack, you'll have to test each one.

DatePart Range
--------- -----------
Years 1742 - 2016 (100,000/365=~274)
Months 1 - 12
Days 1 - 28
Hrs 00 - 23
Min 00 - 59
Sec 00 - 59



I would use a python hack to build a table.

==========================================================================
import os,sys,time,random,sqlite3

y=[]
for yr in range(1742,2017):
y.append(yr)

mt = ['01','02','03','04','05','06']
mt+= ['07','08','09','10','11','12']

d= ['01','02','03','04','05','06','07','08','09','10']
d+=['11','12','13','14','15','16','17','18','19','20']
d+=['21','22','23','24','25','26','27','28']

h=[]
for i in range(24):
if i<10: h.append('0'+str(i))
else: h.append(str(i))

m,s=[],[]
for i in range(60):
if i<10: m.append('0'+str(i))
else: m.append(str(i))
s=m


#print y
#print mt
#print d
#print h
#print m
#print s


def getrdate(y,mt,d,h,m,s):
ry =str(random.choice(y))
rmt=str(random.choice(mt))
rd =str(random.choice(d))
rh =str(random.choice(h))
rm =str(random.choice(m))
rs =str(random.choice(s))
return ry+'-'+rmt+'-'+rd+' '+rh+':'+rm+':'+rs

def getrint(ds):
rs=ds.replace('-','')
rs=rs.replace(':','')
rs=rs.replace(' ','')
return int(rs)

#db and table
dbName='randomdates.sqlite'
if os.path.isfile(dbName):
os.remove(dbName)
conn=sqlite3.connect(dbName)
#conn.text_factory = str
db=conn.cursor()
db.execute("CREATE TABLE If Not Exists RANDOMDATES (dts TEXT, dti
INTEGER, PRIMARY KEY (dts));")


#populate table of random dates in format 'yyyy-mm-dd hh:mm:ss'
dts=[]
sSQL = " INSERT OR IGNORE INTO RANDOMDATES (dts,dti) VALUES (?,?) "
loops=int(sys.argv[1])
start=time.clock()
for i in range(loops):
rs=getrdate(y,mt,d,h,m,s)
ri=getrint(rs)
dts.append((rs,ri))
db.execute(sSQL,(rs,ri))



db.execute("SELECT COUNT(dts) FROM RANDOMDATES;")
print str(db.fetchone()[0]) + ' rows in table'

print "Built list of %s random dates: %.2g seconds"
%(loops,time.clock()-start)
print

if len(dts)>20:
print 'First 10 random dates:'
for i in range(10):
print dts[i][0], dts[i][1]
print
print 'Last 10 random dates:'
for i in range(len(dts)-10,len(dts)):
print dts[i][0], dts[i][1]

db.close()
conn.close()
==========================================================================
Post by DFS
Post by deplorable owl
Post by DFS
Post by deplorable owl
rand() and random() both work
over range 0-RAND_MAX, which on my system is a range of 2.14 billion.
There are 8.64 billion seconds in 100,000 days. Maybe stitch larger
numbers from smaller random pieces? I used a random multiplier of 0-9
over +/-(1 billion), hoping to get range from +/-(9 billion) but that's
not working great.
DFS
2016-12-11 01:07:27 UTC
Permalink
On 12/10/2016 07:56 PM, DFS wrote:

whoops... needs a commit right here:


conn.commit()
Post by DFS
db.execute("SELECT COUNT(dts) FROM RANDOMDATES;")
print str(db.fetchone()[0]) + ' rows in table'
I ran it 4 or 5 times, and twice it inserted just under 100K rows

[***@manjaro Downloads]$ python pop100K.py 100000
99997 rows in table
Built list of 100000 random dates: 2.1 seconds

First 10 random dates:
1768-04-25 00:27:44 17680425002744
1852-11-01 07:03:59 18521101070359
1749-11-07 05:29:12 17491107052912
1832-08-20 13:07:43 18320820130743
1822-07-19 22:37:22 18220719223722
2005-08-18 00:55:13 20050818005513
1969-06-24 23:00:28 19690624230028
1806-01-19 19:45:51 18060119194551
1908-03-11 12:20:26 19080311122026
1970-10-04 23:15:46 19701004231546

Last 10 random dates:
1853-09-28 01:34:39 18530928013439
1753-02-09 01:53:47 17530209015347
1843-06-19 00:39:08 18430619003908
1904-11-07 19:47:45 19041107194745
1795-05-07 10:12:14 17950507101214
1950-11-19 17:45:29 19501119174529
1957-07-03 14:39:04 19570703143904
1882-02-15 06:17:48 18820215061748
1901-06-21 00:09:17 19010621000917
2012-12-18 18:25:59 20121218182559
deplorable owl
2016-12-11 04:07:44 UTC
Permalink
Post by DFS
conn.commit()
Post by DFS
db.execute("SELECT COUNT(dts) FROM RANDOMDATES;")
print str(db.fetchone()[0]) + ' rows in table'
I ran it 4 or 5 times, and twice it inserted just under 100K rows
99997 rows in table
Built list of 100000 random dates: 2.1 seconds
1768-04-25 00:27:44 17680425002744
1852-11-01 07:03:59 18521101070359
1749-11-07 05:29:12 17491107052912
1832-08-20 13:07:43 18320820130743
1822-07-19 22:37:22 18220719223722
2005-08-18 00:55:13 20050818005513
1969-06-24 23:00:28 19690624230028
1806-01-19 19:45:51 18060119194551
1908-03-11 12:20:26 19080311122026
1970-10-04 23:15:46 19701004231546
1853-09-28 01:34:39 18530928013439
1753-02-09 01:53:47 17530209015347
1843-06-19 00:39:08 18430619003908
1904-11-07 19:47:45 19041107194745
1795-05-07 10:12:14 17950507101214
1950-11-19 17:45:29 19501119174529
1957-07-03 14:39:04 19570703143904
1882-02-15 06:17:48 18820215061748
1901-06-21 00:09:17 19010621000917
2012-12-18 18:25:59 20121218182559
Are those unique with respect to the YYYY-MM-DD part?

This illustrates what I'm talking about with the seconds:

***@lowtide:~/code/dfsdates$ ./getdaysec -7158654004
25-Feb-1743
***@lowtide:~/code/dfsdates$ ./getdaysec -7158654003
25-Feb-1743
***@lowtide:~/code/dfsdates$ ./getdaysec -7158654002
25-Feb-1743
***@lowtide:~/code/dfsdates$ ./getdaysec -7158654001
25-Feb-1743
***@lowtide:~/code/dfsdates$ ./getdaysec -7158654000 -t
25-Feb-1743 00:03:58
***@lowtide:~/code/dfsdates$ ./getdaysec -7158653999 -t
25-Feb-1743 00:03:59
***@lowtide:~/code/dfsdates$ ./getdaysec -7158653998 -t
25-Feb-1743 00:04:00
***@lowtide:~/code/dfsdates$
...
***@lowtide:~/code/dfsdates$ ./getdaysec -68402 -t
30-Dec-1969 23:59:58
***@lowtide:~/code/dfsdates$ ./getdaysec -68401 -t
30-Dec-1969 23:59:59
***@lowtide:~/code/dfsdates$ ./getdaysec -68400 -t
31-Dec-1969 00:00:00
***@lowtide:~/code/dfsdates$ ./getdaysec -68399 -t
31-Dec-1969 00:00:01
***@lowtide:~/code/dfsdates$ ./getdaysec -68398 -t
31-Dec-1969 00:00:02
***@lowtide:~/code/dfsdates$ ./getdaysec -68397 -t
31-Dec-1969 00:00:03
***@lowtide:~/code/dfsdates$
...
***@lowtide:~/code/dfsdates$ ./getdaysec -2 -t
31-Dec-1969 18:59:58
***@lowtide:~/code/dfsdates$ ./getdaysec -1 -t
31-Dec-1969 18:59:59
***@lowtide:~/code/dfsdates$ ./getdaysec 0 -t
31-Dec-1969 19:00:00
***@lowtide:~/code/dfsdates$ ./getdaysec 1 -t
31-Dec-1969 19:00:01
***@lowtide:~/code/dfsdates$ ./getdaysec 2 -t
31-Dec-1969 19:00:02
***@lowtide:~/code/dfsdates$ ./getdaysec 3 -t
31-Dec-1969 19:00:03
***@lowtide:~/code/dfsdates$
...
***@lowtide:~/code/dfsdates$ ./getdaysec 17997 -t
31-Dec-1969 23:59:57
***@lowtide:~/code/dfsdates$ ./getdaysec 17998 -t
31-Dec-1969 23:59:58
***@lowtide:~/code/dfsdates$ ./getdaysec 17999 -t
31-Dec-1969 23:59:59
***@lowtide:~/code/dfsdates$ ./getdaysec 18000 -t
01-Jan-1970 00:00:00
***@lowtide:~/code/dfsdates$ ./getdaysec 18001 -t
01-Jan-1970 00:00:01
***@lowtide:~/code/dfsdates$ ./getdaysec 18002 -t
01-Jan-1970 00:00:02
***@lowtide:~/code/dfsdates$ ./getdaysec 18003 -t
01-Jan-1970 00:00:03
***@lowtide:~/code/dfsdates$
...
***@lowtide:~/code/dfsdates$ ./getdaysec 1481345998 -t
09-Dec-2016 23:59:58
***@lowtide:~/code/dfsdates$ ./getdaysec 1481345999 -t
09-Dec-2016 23:59:59
***@lowtide:~/code/dfsdates$ ./getdaysec 1481346000 -t
10-Dec-2016 00:00:00
***@lowtide:~/code/dfsdates$ ./getdaysec 1481346001 -t
10-Dec-2016 00:00:01
***@lowtide:~/code/dfsdates$ ./getdaysec 1481346002 -t
10-Dec-2016 00:00:02
***@lowtide:~/code/dfsdates$ ./getdaysec 1481346003
10-Dec-2016
***@lowtide:~/code/dfsdates$ ./getdaysec 1481346004
10-Dec-2016
***@lowtide:~/code/dfsdates$ ./getdaysec 1481346005
10-Dec-2016
***@lowtide:~/code/dfsdates$ ./getdaysec 1481346006
10-Dec-2016
***@lowtide:~/code/dfsdates$


***@lowtide:~/code/dfsdates$ cat getdaysec.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
void usage(void);
int main(int argc, char *argv[])
{
time_t num=0;
char *fmtstr=NULL;
char buf[100]={0};
char *str=NULL;
char *end;
switch(argc)
{
case 2:
fmtstr="%d-%b-%Y";
break;
case 3:
if(!strcmp(argv[2],"-t"))
{
fmtstr="%d-%b-%Y %H:%M:%S";
break;
}
default:
usage();
exit(1);
}
str=argv[1];
num=(time_t)strtol(str,&end,10);
strftime(buf,sizeof buf,fmtstr,localtime(&num));
printf("%s\n",buf);
return 0;
}
void usage(void)
{
fprintf(stderr,"one or two arguments. first is a number, "
"optional second is '-t'\n");
}
***@lowtide:~/code/dfsdates$
Melzzzzz
2016-12-11 02:40:50 UTC
Permalink
On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
Post by deplorable owl
Post by Melzzzzz
Post by deplorable owl
BTW, what's the proper approach to randomizing such a huge number
of values? (A large enough pool of seconds so that randoms would
have a good chance of falling on 100,000 different days).
You don't have to just filter out dupes ;p
It is not needed to have 100000k uniques at all.
Yeah, but filtering is just to get uniques. Say you want 100000
unique days using random second values, minimizing dups and
generating exactly 100000 values, how would you approach that?
I would generate 100000 days in order, then shuffle.
--
press any key to continue or any other to quit...
deplorable owl
2016-12-11 04:00:51 UTC
Permalink
Post by Melzzzzz
On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
Post by deplorable owl
Post by Melzzzzz
Post by deplorable owl
BTW, what's the proper approach to randomizing such a huge number
of values? (A large enough pool of seconds so that randoms would
have a good chance of falling on 100,000 different days).
You don't have to just filter out dupes ;p
It is not needed to have 100000k uniques at all.
Yeah, but filtering is just to get uniques. Say you want 100000
unique days using random second values, minimizing dups and
generating exactly 100000 values, how would you approach that?
I would generate 100000 days in order, then shuffle.
Yes, that's easy, but it dodges the pre-generation randomizing
problem rather than addressing it, and also requires generation
of a full 8.64 billion numbers then modulo 86400 to get 100000
unique sequential days before shuffling. A solution that randomizes
before generation only needs to generate 100000 numbers instead
of 8.64 billion, but then you've got a RAND_MAX issue. Even
if you do something like I did,

for(i=0;i<100000;i++)
{
rannum[i]=random()%INT_MAX+(-INT_MAX/2);
rannum[i]*=random()%9;
}

to get values +/- 9 billion or so, you still have a rand pool
of only 2 billion values, so you get too many dupes. I get
average of 1200 dupes per 100000 generation each run. I would
like to have less than 10. Is that too much expect even if
the rand pool problem is solved?

changing to:

rannum[i]*=random()%99;

brings dupes down to 10-12 per 100000 generated, but the date
range then goes from 1365 BC to 5283 AD. :)

With

rannum[i]*=random()%999;

I get 0 dupes consistently, but the date range is 31895 BC to 35724 AD.
LOL. Surely there's a better way to randomize?
Melzzzzz
2016-12-11 04:08:23 UTC
Permalink
Post by deplorable owl
Post by Melzzzzz
On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
Post by deplorable owl
Post by Melzzzzz
Post by deplorable owl
BTW, what's the proper approach to randomizing such a huge number
of values? (A large enough pool of seconds so that randoms would
have a good chance of falling on 100,000 different days).
You don't have to just filter out dupes ;p
It is not needed to have 100000k uniques at all.
Yeah, but filtering is just to get uniques. Say you want 100000
unique days using random second values, minimizing dups and
generating exactly 100000 values, how would you approach that?
I would generate 100000 days in order, then shuffle.
Yes, that's easy, but it dodges the pre-generation randomizing
problem rather than addressing it, and also requires generation
of a full 8.64 billion numbers then modulo 86400 to get 100000
unique sequential days before shuffling.
Hm, I don't get it ;)
Just create 100k dates and then shuffle, what's the problem?
--
press any key to continue or any other to quit...
deplorable owl
2016-12-11 04:27:50 UTC
Permalink
Post by Melzzzzz
Post by deplorable owl
Post by Melzzzzz
On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
Post by deplorable owl
Post by Melzzzzz
Post by deplorable owl
BTW, what's the proper approach to randomizing such a huge number
of values? (A large enough pool of seconds so that randoms would
have a good chance of falling on 100,000 different days).
You don't have to just filter out dupes ;p
It is not needed to have 100000k uniques at all.
Yeah, but filtering is just to get uniques. Say you want 100000
unique days using random second values, minimizing dups and
generating exactly 100000 values, how would you approach that?
I would generate 100000 days in order, then shuffle.
Yes, that's easy, but it dodges the pre-generation randomizing
problem rather than addressing it, and also requires generation
of a full 8.64 billion numbers then modulo 86400 to get 100000
unique sequential days before shuffling.
Hm, I don't get it ;)
Just create 100k dates and then shuffle, what's the problem?
It's not really about dates. It's about the rand problem that arises
if you randomize 100,000 time_t values with the goal of 100,000 unique
DD-MM-YYYY values. Consider it generically. Forget that it's a date
function, and assume that you have a pool of input values for which output
values only change for every 86400 inputs. You want to get 100,000 random
(but hopefully unique) outputs given only 100,000 randomly chosen inputs.
How do you randomize your inputs where the input pool is minimum 8.64
billion to guarantee that you *might* get 100,000 unique outputs.
deplorable owl
2016-12-10 19:41:54 UTC
Permalink
Post by Melzzzzz
func GenDates(minyear,maxyear,count int) map[string]int {
rc := make(map[string]int,0)
for i := 0;i<count;i++ {
r := time.Date(random(minyear,maxyear),time.Month(random(1,12)),random(1,31),
0,0,0,0,time.UTC)
rc [fmt.Sprintf("%2d-%3s-%4d",r.Day(),
cvtFromMonth(r.Month()),r.Year())]++
}
return rc
}
Does time.Date() handle invalid dates, such as Feb 31?
Melzzzzz
2016-12-10 19:48:20 UTC
Permalink
On Sat, 10 Dec 2016 19:41:54 +0000 (UTC)
Post by deplorable owl
Post by Melzzzzz
func GenDates(minyear,maxyear,count int) map[string]int {
rc := make(map[string]int,0)
for i := 0;i<count;i++ {
r :=
time.Date(random(minyear,maxyear),time.Month(random(1,12)),random(1,31),
0,0,0,0,time.UTC) rc [fmt.Sprintf("%2d-%3s-%4d",r.Day(),
cvtFromMonth(r.Month()),r.Year())]++
}
return rc
}
Does time.Date() handle invalid dates, such as Feb 31?
It normalizes them, alright.
--
press any key to continue or any other to quit...
deplorable owl
2016-12-10 20:06:39 UTC
Permalink
Post by Melzzzzz
On Sat, 10 Dec 2016 19:41:54 +0000 (UTC)
Post by deplorable owl
Post by Melzzzzz
func GenDates(minyear,maxyear,count int) map[string]int {
rc := make(map[string]int,0)
for i := 0;i<count;i++ {
r :=
time.Date(random(minyear,maxyear),time.Month(random(1,12)),random(1,31),
0,0,0,0,time.UTC) rc [fmt.Sprintf("%2d-%3s-%4d",r.Day(),
cvtFromMonth(r.Month()),r.Year())]++
}
return rc
}
Does time.Date() handle invalid dates, such as Feb 31?
It normalizes them, alright.
Cool. I like how it shows the leap years as 02-Mar (your go code,
but using only Feb 31 instead of random numbers):

***@lowtide:~/code/dfsdates$ ./mds
1986 unique dates

03-Mar-0030
03-Mar-0031
02-Mar-0032
03-Mar-0033
03-Mar-0034
03-Mar-0035
02-Mar-0036
03-Mar-0037
03-Mar-0038
03-Mar-0039

03-Mar-2006
03-Mar-2007
02-Mar-2008
03-Mar-2009
03-Mar-2010
03-Mar-2011
02-Mar-2012
03-Mar-2013
03-Mar-2014
03-Mar-2015

***@lowtide:~/code/dfsdates$
DFS
2016-12-10 15:32:41 UTC
Permalink
real 0m0.042s (owl bash)
real 0m0.031s (DFS python)
real 0m0.003s (Mel Go)
real 0m0.001s (owl C)
<moved your code to bottom>

Your code seems complicated for such a task. Maybe it has some
advantages over mine, such as handling time and time zones?


[***@manjaro Downloads]$ time ./getminmax 1
Min 20-Aug-1997
Max 07-Nov-2014
real 0m0.001s

[***@manjaro Downloads]$ time ./getminmax 1000000
Min 20-Aug-1997
Max 07-Nov-2014
real 0m1.157s

============================================================================
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char *dts[] ={"10-Mar-1998","20-Aug-1997","06-Sep-2009","23-Jan-2010",
"05-Nov-2010","03-Sep-2009","07-Nov-2014","08-Mar-2013"};
char *mth[] ={"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"};
char *mthn[]={"01","02","03","04","05","06",
"07","08","09","10","11","12"};
int mindt,maxdt,currdt;
int minindex=0,maxindex=0;
int n=sizeof(dts)/sizeof(dts[0]);

//parse date string: '08-Mar-2013' return int 20130308
int dtint (int dtidx) {
char y[4],m[3],mt[2],d[3],*ptr,dtstr[8];
strncpy(y,dts[dtidx]+7,4);y[4]='\0';
strncpy(m,dts[dtidx]+3,3);m[3]='\0';
for(int j=0;j<12;j++)
{ if(strcmp(m,mth[j])==0)
{strcpy(mt,mthn[j]);mt[2]='\0';break;}
}
strncpy(d,dts[dtidx],2);d[2]='\0';
strcpy(dtstr,"");
strcat(dtstr,y);strcat(dtstr,mt);strcat(dtstr,d);
return strtol(dtstr,&ptr,10);
}

int main(int argc, char *argv[]) {
int loops=atoi(argv[1]);
mindt=dtint(0);maxdt=mindt;
for(int l=1;l<=loops;l++){
for(int i=1;i<n;i++)
{
currdt=dtint(i);
if(currdt<mindt){mindt=currdt;minindex=i;}
if(currdt>maxdt){maxdt=currdt;maxindex=i;}
}
}
printf("Min %s\nMax %s\n",dts[minindex],dts[maxindex]);
}
============================================================================
35 source lines. No time libraries and no array sorting.

It walks the dates one time, comparing the int of the prior date to the
int of the current date, and keeping track of where in the date array
the min and max was found.
---------------------------------------
#include <stdio.h>
#define __USE_XOPEN
#include <time.h>
#include <string.h>
#include <stdlib.h>
struct mdy {
int d;
int m;
int y;
};
long getints(struct mdy *, char *);
int compar(const void *,const void *);
int main(int argc, char *argv[])
{
char * dates[] = {
"10-Mar-1998",
"20-Aug-1997",
"06-Sep-2009",
"23-Jan-2010",
"05-Nov-2010",
"03-Sep-2009",
"07-Nov-2014",
"08-Mar-2013"
};
int datecount=sizeof(dates)/sizeof(dates[0]);
time_t seconds=0;
struct tm mytm={0};
struct mdy mymdy={0};
long mylongs[datecount];
long i=0;
char buf[100]={0};
for(i=0;i<datecount;i++)
{
getints(&mymdy,dates[i]);
mytm.tm_mday=mymdy.d;
mytm.tm_mon=mymdy.m;
mytm.tm_year=mymdy.y-1900;
seconds=mktime(&mytm);
mylongs[i]=(long)seconds;
}
qsort(mylongs,datecount,sizeof(long),compar);
strftime(buf,sizeof buf,"%d-%b-%Y",
localtime((time_t *)&mylongs[0]));
printf("%s\n",buf);
strftime(buf,sizeof buf,"%d-%b-%Y",
localtime((time_t *)&mylongs[datecount-1]));
printf("%s\n",buf);
return 0;
}
long getints(struct mdy *themdy, char *str)
{
char *months[]={"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"};
char *token;
char *delim="-";
int i=0;
int j=0;
char arr[12]={0};
strcpy(arr,str);
token=strtok(arr,delim);
themdy->d=atoi(token);
while(token!=NULL)
{
i++;
token=strtok(NULL,delim);
if(i==1)
{
for(j=0;j<12;j++)
{
if( !strcmp(token,months[j]) )
{
themdy->m=j;
}
}
}
if(i==2)
{
themdy->y=atoi(token);
}
}
return 0;
}
int compar(const void *a,const void *b)
{
return ( *(long *)a -*(long *)b );
}
---------------------------------------
Melzzzzz
2016-12-10 15:40:02 UTC
Permalink
On Sat, 10 Dec 2016 10:32:41 -0500
Post by DFS
real 0m0.042s (owl bash)
real 0m0.031s (DFS python)
real 0m0.003s (Mel Go)
real 0m0.001s (owl C)
<moved your code to bottom>
Your code seems complicated for such a task. Maybe it has some
advantages over mine, such as handling time and time zones?
Min 20-Aug-1997
Max 07-Nov-2014
real 0m0.001s
Min 20-Aug-1997
Max 07-Nov-2014
real 0m1.157s
============================================================================
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char *dts[] ={"10-Mar-1998","20-Aug-1997","06-Sep-2009","23-Jan-2010",
"05-Nov-2010","03-Sep-2009","07-Nov-2014","08-Mar-2013"};
char *mth[] ={"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"};
char *mthn[]={"01","02","03","04","05","06",
"07","08","09","10","11","12"};
int mindt,maxdt,currdt;
int minindex=0,maxindex=0;
int n=sizeof(dts)/sizeof(dts[0]);
//parse date string: '08-Mar-2013' return int 20130308
int dtint (int dtidx) {
char y[4],m[3],mt[2],d[3],*ptr,dtstr[8];
strncpy(y,dts[dtidx]+7,4);y[4]='\0';
strncpy(m,dts[dtidx]+3,3);m[3]='\0';
for(int j=0;j<12;j++)
{ if(strcmp(m,mth[j])==0)
{strcpy(mt,mthn[j]);mt[2]='\0';break;}
}
strncpy(d,dts[dtidx],2);d[2]='\0';
strcpy(dtstr,"");
strcat(dtstr,y);strcat(dtstr,mt);strcat(dtstr,d);
return strtol(dtstr,&ptr,10);
}
int main(int argc, char *argv[]) {
int loops=atoi(argv[1]);
mindt=dtint(0);maxdt=mindt;
for(int l=1;l<=loops;l++){
for(int i=1;i<n;i++)
{
currdt=dtint(i);
if(currdt<mindt){mindt=currdt;minindex=i;}
if(currdt>maxdt){maxdt=currdt;maxindex=i;}
}
}
printf("Min %s\nMax %s\n",dts[minindex],dts[maxindex]);
}
============================================================================
35 source lines. No time libraries and no array sorting.
It walks the dates one time, comparing the int of the prior date to
the int of the current date, and keeping track of where in the date
array the min and max was found.
Task is to create list of 100k random dates in your format then parse
it ;)
--
press any key to continue or any other to quit...
DFS
2016-12-10 16:03:11 UTC
Permalink
Post by Melzzzzz
Task is to create list of 100k random dates in your format then parse
it ;)
Exactly! Forget about date libraries - the string is the king!

I did that already in python (and ran it with 10 million random dates).
I'll do it in C later.


=====================================================================================
import sys,time,random

#lists
d= ['01','02','03','04','05','06','07','08','09','10','11','12','13','14']
d+=['15','16','17','18','19','20','21','22','23','24','25','26','27','28']
m= ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
md=
[('Dec','12'),('Nov','11'),('Oct','10'),('Sep','09'),('Aug','08'),('Jul','07')]
md+=[('Jun','06'),('May','05'),('Apr','04'),('Mar','03'),('Feb','02'),('Jan','01')]
y,dt,dt2=[],[],[]
for yr in range(1000,2001):y.append(yr)

loops=int(sys.argv[1])

#populate list of random dates in format 'dd-MMM-yyyy'
start=time.clock()
for i in range(loops):
rd=random.choice(d)
rm=random.choice(m)
ry=random.choice(y)
dt.append(rd+'-'+rm+'-'+str(ry))

print "Build list of %s random dates: %.2g seconds"
%(loops,time.clock()-start)
print
print 'First 10 random dates: \n' + str(dt[:10],)
print 'Last 10 random dates : \n' + str(dt[loops-10:],)
print


#create sortable 2nd list
start=time.clock()
for d in dt:
dt2.append((d[-4:]+dict(md)[d[3:6]]+d[:2],d))
print "Populated list of %s sortable random dates: %.2g seconds"
%(len(dt2),time.clock()-start)
print 'First 10 random dates: \n' + str(dt2[:10],)
print

#get min and max
start=time.clock()
print 'Min date: '+min(dt2)[1]
print 'Max date: '+max(dt2)[1]
findsec=time.clock()-start
print "Found min and max of %s dates in %.2g seconds" %(len(dt2),findsec)

#calculate time to find min/max in list of 10 billion dates
findB=((10000000000/loops) * findsec)/(60*60)
print 'Time to find min and max of 10,000,000,000 dates: %.2g hours' %
(findB)
=====================================================================================

$python dateminmax.py 10000000
Build list of 10000000 random dates: 40 seconds

First 10 random dates:
['21-Dec-1725', '07-Oct-1234', '11-Nov-1465', '20-Feb-1451',
'16-Mar-1915', '21-Oct-1533', '22-Apr-1940', '02-Oct-1365',
'19-Sep-1252', '20-Dec-1137']
Last 10 random dates :
['05-May-1308', '04-Oct-1838', '16-Mar-1124', '20-Sep-1895',
'03-Dec-1660', '04-Oct-1105', '07-Dec-1990', '13-Jun-1493',
'08-Apr-1485', '02-Nov-1813']

Populated list of 10000000 sortable random dates: 27 seconds
First 10 random dates:
[('17251221', '21-Dec-1725'), ('12341007', '07-Oct-1234'), ('14651111',
'11-Nov-1465'), ('14510220', '20-Feb-1451'), ('19150316',
'16-Mar-1915'), ('15331021', '21-Oct-1533'), ('19400422',
'22-Apr-1940'), ('13651002', '02-Oct-1365'), ('12520919',
'19-Sep-1252'), ('11371220', '20-Dec-1137')]

Min date: 01-Jan-1000
Max date: 28-Dec-2000
Found min and max of 10000000 dates in 1.4 seconds
Time to find min and max of 10,000,000,000 dates: 0.39 hours
Steve Carroll
2016-12-10 17:26:27 UTC
Permalink
Post by DFS
Post by Melzzzzz
Task is to create list of 100k random dates in your format then parse
it ;)
Exactly! Forget about date libraries - the string is the king!
LOL! Point taken for this ;)

Previously, you asked about an image gallery for the NASA photos. Here's a mobile ready version of one with perfect navigation... Feeb should like it ;)

var container = document.querySelector('.container');
var fragment = document.createDocumentFragment();
var xhr = new XMLHttpRequest();
xhr.open('GET', 'data.json');
xhr.onload = function() {
if (xhr.status === 200) {
var data = JSON.parse(xhr.responseText);
for(var i = 0; i < data.photos.length; i++) {
var img = document.createElement('img');
img.src = data.photos[i].img_src;
fragment.appendChild(img);
}
container.appendChild(fragment);
}
else {
alert('Error: ' + xhr.status);
}
};
xhr.send();
DFS
2016-12-10 17:38:48 UTC
Permalink
Post by Steve Carroll
Post by DFS
Post by Melzzzzz
Task is to create list of 100k random dates in your format then parse
it ;)
Exactly! Forget about date libraries - the string is the king!
LOL! Point taken for this ;)
Previously, you asked about an image gallery for the NASA photos. Here's a mobile ready version of one with perfect navigation... Feeb should like it ;)
var container = document.querySelector('.container');
var fragment = document.createDocumentFragment();
var xhr = new XMLHttpRequest();
xhr.open('GET', 'data.json');
xhr.onload = function() {
if (xhr.status === 200) {
var data = JSON.parse(xhr.responseText);
for(var i = 0; i < data.photos.length; i++) {
var img = document.createElement('img');
img.src = data.photos[i].img_src;
fragment.appendChild(img);
}
container.appendChild(fragment);
}
else {
alert('Error: ' + xhr.status);
}
};
xhr.send();
Show us some action!

We need a screencast with titles and voiceover. Maybe some background
music...


Steve Carroll
2016-12-10 17:52:08 UTC
Permalink
Post by DFS
Post by Steve Carroll
Post by DFS
Post by Melzzzzz
Task is to create list of 100k random dates in your format then parse
it ;)
Exactly! Forget about date libraries - the string is the king!
LOL! Point taken for this ;)
Previously, you asked about an image gallery for the NASA photos. Here's a mobile ready version of one with perfect navigation... Feeb should like it ;)
var container = document.querySelector('.container');
var fragment = document.createDocumentFragment();
var xhr = new XMLHttpRequest();
xhr.open('GET', 'data.json');
xhr.onload = function() {
if (xhr.status === 200) {
var data = JSON.parse(xhr.responseText);
for(var i = 0; i < data.photos.length; i++) {
var img = document.createElement('img');
img.src = data.photos[i].img_src;
fragment.appendChild(img);
}
container.appendChild(fragment);
}
else {
alert('Error: ' + xhr.status);
}
};
xhr.send();
Show us some action!
It's completely thumb driven, how much better action can you have? ;)
Post by DFS
We need a screencast with titles and voiceover. Maybe some background
music...
http://youtu.be/mQR0bXO_yI8
This is 'Feeb level' spartan, no moons involved. Put it into an HTML doc with a target container, access NASA's API on what you want and dump it into 'data.json'... give the images a width of %100 and... presto! Instant mobile ready image gallery ;)
DFS
2016-12-10 18:01:03 UTC
Permalink
Post by Steve Carroll
Post by DFS
Post by Steve Carroll
Post by DFS
Post by Melzzzzz
Task is to create list of 100k random dates in your format
then parse it ;)
Exactly! Forget about date libraries - the string is the
king!
LOL! Point taken for this ;)
Previously, you asked about an image gallery for the NASA photos.
Here's a mobile ready version of one with perfect navigation...
Feeb should like it ;)
var container = document.querySelector('.container'); var
fragment = document.createDocumentFragment(); var xhr = new
XMLHttpRequest(); xhr.open('GET', 'data.json'); xhr.onload =
function() { if (xhr.status === 200) { var data =
JSON.parse(xhr.responseText); for(var i = 0; i <
data.photos.length; i++) { var img =
document.createElement('img'); img.src = data.photos[i].img_src;
fragment.appendChild(img); } container.appendChild(fragment); }
else { alert('Error: ' + xhr.status); } }; xhr.send();
Show us some action!
It's completely thumb driven, how much better action can you have?
;)
Post by DFS
We need a screencast with titles and voiceover. Maybe some
background music...
http://youtu.be/mQR0bXO_yI8
This is 'Feeb level' spartan, no moons involved. Put it into an HTML
doc with a target container, access NASA's API on what you want and
dump it into 'data.json'... give the images a width of %100 and...
presto! Instant mobile ready image gallery ;)
You lost me after 'put it in an HTML doc'.
Steve Carroll
2016-12-10 18:06:07 UTC
Permalink
Post by DFS
Post by Steve Carroll
Post by DFS
Post by Steve Carroll
Post by DFS
Post by Melzzzzz
Task is to create list of 100k random dates in your format
then parse it ;)
Exactly! Forget about date libraries - the string is the
king!
LOL! Point taken for this ;)
Previously, you asked about an image gallery for the NASA photos.
Here's a mobile ready version of one with perfect navigation...
Feeb should like it ;)
var container = document.querySelector('.container'); var
fragment = document.createDocumentFragment(); var xhr = new
XMLHttpRequest(); xhr.open('GET', 'data.json'); xhr.onload =
function() { if (xhr.status === 200) { var data =
JSON.parse(xhr.responseText); for(var i = 0; i <
data.photos.length; i++) { var img =
document.createElement('img'); img.src = data.photos[i].img_src;
fragment.appendChild(img); } container.appendChild(fragment); }
else { alert('Error: ' + xhr.status); } }; xhr.send();
Show us some action!
It's completely thumb driven, how much better action can you have?
;)
Post by DFS
We need a screencast with titles and voiceover. Maybe some
background music...
http://youtu.be/mQR0bXO_yI8
This is 'Feeb level' spartan, no moons involved. Put it into an HTML
doc with a target container, access NASA's API on what you want and
dump it into 'data.json'... give the images a width of %100 and...
presto! Instant mobile ready image gallery ;)
You lost me after 'put it in an HTML doc'.
<http://dev-site.eu.pn/nasa-demo/>
deplorable owl
2016-12-10 19:38:11 UTC
Permalink
Post by DFS
Post by Melzzzzz
Task is to create list of 100k random dates in your format then parse
it ;)
Exactly! Forget about date libraries - the string is the king!
I did that already in python (and ran it with 10 million random dates).
I'll do it in C later.
=====================================================================================
import sys,time,random
#lists
d= ['01','02','03','04','05','06','07','08','09','10','11','12','13','14']
d+=['15','16','17','18','19','20','21','22','23','24','25','26','27','28']
So not day values beyond 28? That's smells like cheating and double dipping.
This is one way using epoch seconds helps. Randomizing on those, you don't
have to handle all that crap.
DFS
2016-12-11 00:55:00 UTC
Permalink
Post by deplorable owl
Post by DFS
Post by Melzzzzz
Task is to create list of 100k random dates in your format then parse
it ;)
Exactly! Forget about date libraries - the string is the king!
I did that already in python (and ran it with 10 million random dates).
I'll do it in C later.
=====================================================================================
import sys,time,random
#lists
d= ['01','02','03','04','05','06','07','08','09','10','11','12','13','14']
d+=['15','16','17','18','19','20','21','22','23','24','25','26','27','28']
So not day values beyond 28? That's smells like cheating and double dipping.
heh!

Go easy there, Feeb Jr. The source of date strings is irrelevant, so
not cheating.

Do those missing days do something to the randomness of the date
distribution? No.

Do they affect the speed of the min/max code? No.

Were they part of the original post? No.

Do they bring out the butthurt in you. Yes!

Thanks for playing!
Post by deplorable owl
This is one way using epoch seconds helps. Randomizing on those, you don't
have to handle all that crap.
The goal - which I didn't make clear in the first post, my bad - was to
get the min/max without using a date library; string conversion only.

In the original post I never even thought about testing for invalid
dates, which would at least double the lines of code from the miserly 5.

Adding days 29,30,31 means adding:

if isLeapYear(y) and m=='Feb' and d>29:
blah blah


Note: where's your bash script that does the string thing?
deplorable owl
2016-12-10 19:33:32 UTC
Permalink
Post by DFS
real 0m0.042s (owl bash)
real 0m0.031s (DFS python)
real 0m0.003s (Mel Go)
real 0m0.001s (owl C)
<moved your code to bottom>
Your code seems complicated for such a task. Maybe it has some
advantages over mine, such as handling time and time zones?
It has the advantage of being able to print the whole list sorted in case
you decide you want it. It also adjusts to accommodate invalid dates.
Here's what happens with "40-Dec-1950" and "31-Feb-2016" in the list:

***@lowtide:~/code/dfsdates$ ./klah
20-Aug-1997
02-Mar-2016
Post by DFS
Min 20-Aug-1997
Max 07-Nov-2014
real 0m0.001s
Min 20-Aug-1997
Max 07-Nov-2014
real 0m1.157s
============================================================================
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char *dts[] ={"10-Mar-1998","20-Aug-1997","06-Sep-2009","23-Jan-2010",
"05-Nov-2010","03-Sep-2009","07-Nov-2014","08-Mar-2013"};
char *mth[] ={"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"};
char *mthn[]={"01","02","03","04","05","06",
"07","08","09","10","11","12"};
int mindt,maxdt,currdt;
int minindex=0,maxindex=0;
int n=sizeof(dts)/sizeof(dts[0]);
//parse date string: '08-Mar-2013' return int 20130308
int dtint (int dtidx) {
char y[4],m[3],mt[2],d[3],*ptr,dtstr[8];
strncpy(y,dts[dtidx]+7,4);y[4]='\0';
strncpy(m,dts[dtidx]+3,3);m[3]='\0';
for(int j=0;j<12;j++)
{ if(strcmp(m,mth[j])==0)
{strcpy(mt,mthn[j]);mt[2]='\0';break;}
}
strncpy(d,dts[dtidx],2);d[2]='\0';
strcpy(dtstr,"");
strcat(dtstr,y);strcat(dtstr,mt);strcat(dtstr,d);
return strtol(dtstr,&ptr,10);
}
int main(int argc, char *argv[]) {
int loops=atoi(argv[1]);
mindt=dtint(0);maxdt=mindt;
for(int l=1;l<=loops;l++){
for(int i=1;i<n;i++)
{
currdt=dtint(i);
if(currdt<mindt){mindt=currdt;minindex=i;}
if(currdt>maxdt){maxdt=currdt;maxindex=i;}
}
}
printf("Min %s\nMax %s\n",dts[minindex],dts[maxindex]);
}
============================================================================
35 source lines. No time libraries and no array sorting.
It walks the dates one time, comparing the int of the prior date to the
int of the current date, and keeping track of where in the date array
the min and max was found.
But if you want to print the list sorted...
deplorable owl
2016-12-10 20:00:07 UTC
Permalink
Post by deplorable owl
Post by DFS
real 0m0.042s (owl bash)
real 0m0.031s (DFS python)
real 0m0.003s (Mel Go)
real 0m0.001s (owl C)
<moved your code to bottom>
Your code seems complicated for such a task. Maybe it has some
advantages over mine, such as handling time and time zones?
It has the advantage of being able to print the whole list sorted in case
you decide you want it. It also adjusts to accommodate invalid dates.
20-Aug-1997
02-Mar-2016
Wrong snippet. Here's what it does with those:

***@lowtide:~/code/dfsdates$ ./klah
09-Jan-1951
02-Mar-2016
***@lowtide:~/code/dfsdates$
Loading...