Re: Slow code


Brian Christmas
 

G’day Nigel

Thank you.

Luckily the seed I REALLY used is 8 digits. I deliberately altered my code for posting.

Very, very useful knowledge, but I HAD extensively tested the overall code to ensure it’s consistency.

Interestingly, the orginal site I got the seed generator/hider handler code from was using a 16 digit number, but NOT for a seed.

Just luck I picked an 8 digit seed! Sometimes, things actually go my way!



I only have one hurdle to overcome now. My trying to get the list of active subscritions from FastSpring is not working. FastSpring's site is utterly awful in not giving examples of what to actually code.

Luckily they have good support, so I’m hoping that overnight my Oz time they’ll tell me how to fix my last problem, then my site can go live, I think. Many minor details fixed in last week.



Quote


Access
Obtain your "API Key", which consists of a username and password. To obtain your API Key, login to the Dashboard and navigate to Integrations > Get API Credentials. The username and password are used for "Basic Authentication" when making requests to the API. A "User-Agent" header is also required by the API to be included in all requests.
Make all requests to https://api.fastspring.com 

unQuote


I’ve tried


fully knowing it would be useless. BUT, I have no idea of what a “User-Agent’ header is...


Regards

Santa




On 13 Sep 2017, at 7:48 pm, Nigel Garvey <gngarvey@...> wrote:

Brian Christmas wrote on Tue, 12 Sep 2017 05:36:56 +1000:

I’m trying to generate 10,000 serial numbers, as text, in groups of
8,8,6,6
numbers, with dash separators.

Brian Christmas wrote on Wed, 13 Sep 2017 10:25:30 +1000

However, I want a reproducable list of codes.

On my machine, the codes are only reproduceable if the random number
seed integer is restricted to nine digits or fewer.

 use AppleScript version "2.4" -- Yosemite (10.10) or later
 use framework "Foundation"
 use scripting additions

 set theSeed to fixit()
 random number with seed theSeed

 -- Generate serial numbers and gather them into a set to ensure no dupes. Stop at 10,000 unique entries.
 set serialNumbers to current application's class "NSMutableSet"'s new()
 set astid to AppleScript's text item delimiters
 set AppleScript's text item delimiters to "-"
 repeat until (serialNumbers's |count|() is 10000)
   tell serialNumbers to addObject:({(random number 89999999) + 10000000, (random number 89999999) + 10000000, (random number 899999) + 100000, (random number 899999) + 100000} as text)
 end repeat
 set AppleScript's text item delimiters to astid
 set serialNumbers to serialNumbers's allObjects()

 -- Either:
 -- set serialNumbers to serialNumbers as list
 -- Or:
 set serialNumbers to (serialNumbers's componentsJoinedByString:(linefeed)) as text

 on fixit()
   set c1 to "743196734015346789"
   set c2 to "025694701243831634"
   set c3 to "690116383350418453"
   set x to text 9 through 11 of c1 & text 2 through 5 of c2 & text 11 through 12 of c3 as integer
   return x
 end fixit


NG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (applescript-users@...)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/applescript-users/ozsanta%40gmail.com
Archives: http://lists.apple.com/archives/applescript-users

This email sent to ozsanta@...

Join applescript@apple-dev.groups.io to automatically receive all group messages.