
For a number of reasons my blog has been having something of a rest, but I have been busy in a number of fields and I will be posting about those shortly.
The dog image comes from Wikimedia and is in the public domain courtesy of Zsóka Darnyi.
For a number of reasons my blog has been having something of a rest, but I have been busy in a number of fields and I will be posting about those shortly.
The dog image comes from Wikimedia and is in the public domain courtesy of Zsóka Darnyi.
When working with Cloudflare Workers you sometimes need to use a feature which Cloudflare calls “Secrets” .
To create a “Secret” called “FOO” you do this …
$ wrangler secret put
FOO
… and you’ll get prompted for what value you want to associate with ‘FOO’.
The strange thing is that if you go into your Cloudflare dashboard there’s no sign of any “Secret”.
After a good deal of digging around I found the “Secret” I had created but it’s not referred to as “Secret” it’s labelled “Environment Variables”. That’s actually a better name for it than “Secret” but it’s pretty confusing and there’s no reference that I can find for it in the Cloudflare documentation.
So just to be clear this is how you find your “Secret” …
When developing Cloudflare Workers which make use of Cloudflare KV there’s an error message you might get which reads like this :
Error: In order to preview a worker with KV namespaces, you must designate a preview_id in your configuration file for each KV namespace you'd like to preview.
There’s a couple of things it’s useful to know when resolving this, and as far as I can see it’s not clearly documented in the Cloudflare Workers, or KV documentation.
If you’re seeing this you need to go and inspect your wrangler.toml
file. You probably have something that looks like this :
kv_namespaces = [
{ binding = "FOO", id = "bb12cc34dd56eebb12cc34dd56eebb12" }
]
Or you may have no kv_name_spaces
entry at all. Either way this is how to resolve the situation.
Execute the following command.
$ wrangler kv:namespace create "FOO" --preview
If you do have an existing entry for kv_namespaces
be sure to use the binding
property value that’s already in use, in this example ‘FOO’, otherwise use whatever name you want as your namespace name.
Once you’ve executed that command you should see output which looks like the following :
Add the following to your configuration file in your kv_namespaces array:{ binding = "FOO", preview_id = "d94ab232f1ef23acdeaeef0add746a48", id = "bb12cc34dd56eebb12cc34dd56eebb12" }
Go ahead and place that in the wrangler.toml
and you should find the …
Error: In order to preview a worker with KV namespaces, you must designate a preview_id in your configuration file for each KV namespace you'd like to preview.
… message doesn’t appear any longer when using wrangler dev
or wrangler preview
.
The Fake library has a whole lot of built in properties that you can use to generate fake data for testing, etc. Unfortunately the documentation hasn’t kept up with the available properties so here’s a list of most of them as they are in the current release. It’s ‘most of them’ because some properties, such as ‘tar’, don’t lend themselves to easily being on a web page.
Once I get some time I’ll do a pull request for the documentation for the actual project so that this page will become redundant.
fake.aba | 065144370 |
fake.address | 34370 Pace Radial Nortontown, NC 29290 |
fake.administrative_unit | South Carolina |
fake.am_pm | PM |
fake.android_platform_tok en | Android 3.2.6 |
fake.ascii_company_email | dsmith@watts.org |
fake.ascii_email | christineporter@gmail.com |
fake.ascii_free_email | jensenalyssa@gmail.com |
fake.ascii_safe_email | christopher46@example.org |
fake.bank_country | GB |
fake.bban | QIEV11003029338014 |
fake.boolean | True |
fake.bothify | 87 gf |
fake.bs | enable collaborative applications |
fake.building_number | 9389 |
fake.catch_phrase | Profit-focused analyzing collaboration |
fake.century | XV |
fake.chrome | Mozilla/5.0 (Windows NT 5.1) AppleWebKit/531.0 (KHTML, like Gecko) Chrome/26.0.813.0 Safari/531.0 |
fake.city | Petersonchester |
fake.city_spanfix | East |
fake.city_suffix | mouth |
fake.color | #58910e |
fake.color_name | Tomato |
fake.company | Thompson LLC |
fake.company_email | yjohnson@mcneil-johnson.com |
fake.company_suffix | and Sons |
fake.coordinate | 39.909401 |
fake.country | Armenia |
fake.country_calling_code | +1 869 |
fake.country_code | CG |
fake.credit_card_expire | 04/30 |
fake.credit_card_full | VISA 19 digit John Henderson 4388782482398195841 03/29 CVC: 602 |
fake.credit_card_number | 2238435833272261 |
fake.credit_card_provider | JCB 15 digit |
fake.credit_card_security_code | 796 |
fake.cryptocurrency | (‘ETH’, ‘Ethereum’) |
fake.cryptocurrency_code | XPM |
fake.cryptocurrency_name | Bitcoin |
fake.csv | “Robert Anderson”,”06446 Nathan Forks Lanefurt, NY 27437″ “Robert Anderson”,”92218 Cassandra Locks Lake Todd, SC 84356″ “Bradley Johnston”,”9518 Jason Centers Suite 333 West Jefferyberg, UT 20673″ “Austin Hudson”,”27678 Lauren Estate Scottview, WI 21027″ “Ryan Hart”,”834 Don Crest Apt. 132 South Chelsea, MO 06160″ “Joel Bullock”,”65224 Samuel Island Apt. 999 Yatesmouth, MS 41571″ “Joy Leonard”,”950 Gentry Place Port Bryan, WI 91489″ “Dr. Mary Lawrence”,”8994 Anna Mountain Owenburgh, NY 90689″ “Sarah Campbell”,”7866 Christopher Trace Suite 629 North Tiffanyport, CA 91255″ “Eric Allen”,”94927 Lisa Knoll Apt. 346 West Christopherberg, NV 93152″ |
fake.currency | (‘USD’, ‘United States dollar’) |
fake.currency_code | SCR |
fake.currency_name | Jordanian dinar |
fake.currency_symbol | $ |
fake.current_country | United States |
fake.current_country_code | US |
fake.date | 2011-05-11 |
fake.date_between | 2013-09-23 |
fake.date_between_dates | 2021-08-31 |
fake.date_object | 2008-10-27 |
fake.date_of_birth | 1936-09-02 |
fake.date_this_century | 2004-10-08 |
fake.date_this_decade | 2021-01-06 |
fake.date_this_month | 2021-08-25 |
fake.date_this_year | 2021-05-17 |
fake.date_time | 2020-02-28 00:21:01 |
fake.date_time_ad | 1785-05-08 19:44:16 |
fake.date_time_between | 1999-08-12 07:04:19 |
fake.date_time_between_dates | 2021-08-31 14:18:23 |
fake.date_time_this_century | 2010-07-05 08:40:01 |
fake.date_time_this_decade | 2021-01-04 19:55:52 |
fake.date_time_this_month | 2021-08-27 11:34:48 |
fake.date_time_this_year | 2021-04-10 09:48:15 |
fake.day_of_month | 07 |
fake.day_of_week | Wednesday |
fake.dga | erlwjrtlnkidlymxgysbpdyldlaaeqr.com |
fake.domain_name | allen.com |
fake.domain_word | moore |
fake.dsv | “Jeremy Gordon”,”267 Crystal River Apt. 657 North Shaneborough, FL 36124″ “Charles Campbell”,”35681 Keith Road Lake Dustinchester, WI 72084″ “Jennifer Robinson”,”153 Jean Court New Jessica, ID 88924″ “Mrs. Alison Black DVM”,”USS Parker FPO AA 81626″ “Robert Thomas”,”501 Charles Parkways Martinland, TX 36101″ “Megan Lopez”,”7203 Williams Mill Suite 707 Kaylahaven, NV 86377″ “Karen Shaw”,”873 David Mountains Suite 355 Scottville, MI 03858″ “Lisa Mitchell”,”033 Andrew Mountains Angelicaberg, NJ 46464″ “Jennifer Bailey”,”9698 Lynn Overpass Suite 225 Williamsland, NH 86156″ “Tiffany Powers”,”308 Huerta Crescent Kirbymouth, CO 74505″ |
fake.ean | 6888039620628 |
fake.ean13 | 3507382888358 |
fake.ean8 | 16591516 |
fake.ein | 39-0323987 |
fake.email | hdavis@gates-oneill.com |
fake.file_extension | mov |
fake.file_name | the.png |
fake.file_path | /cost/impact.tiff |
fake.firefox | Mozilla/5.0 (Windows NT 4.0; sa-IN; rv:1.9.1.20) Gecko/2013-09-02 18:58:42 Firefox/15.0 |
fake.first_name | Brittany |
fake.first_name_female | Carrie |
fake.first_name_male | Vincent |
fake.first_name_nonbinary | Gregory |
fake.fixed_width | Walter Gomez 1 Heather Larson 0 Michael Cabrera 17 Marc Benitez 0 Kelly Novak 8 Tyler Scott 9 Daniel Walker Jr. 14 Lisa Gonzalez 5 Kerry Clark 14 Alan King 12 |
fake.free_email | tallison@yahoo.com |
fake.free_email_domain | hotmail.com |
fake.future_date | 2021-09-12 |
fake.future_datetime | 2021-09-10 12:53:08 |
fake.hex_color | #de5fee |
fake.hexify | c557 |
fake.hostname | db-31.walker.info |
fake.http_method | PATCH |
fake.iana_id | 4100134 |
fake.iban | GB19TCHN98296480355376 |
fake.image_url | https://placeimg.com/554/722/any |
fake.internet_explorer | Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.2; Trident/4.1) |
fake.invalid_ssn | 018-00-8384 |
fake.ios_platform_token | iPhone; CPU iPhone OS 10_3_3 like Mac OS X |
fake.ipv4 | 54.145.129.32 |
fake.ipv4_network_class | a |
fake.ipv4_private | 192.168.49.103 |
fake.ipv4_public | 147.151.70.102 |
fake.ipv6 | 926b:67b3:8db1:ed20:c309:72db:cc03:8dba |
fake.isbn10 | 0-686-28575-1 |
fake.isbn13 | 978-0-89646-269-4 |
fake.iso8601 | 1991-10-14T02:54:22 |
fake.items | odict_items([(‘en_US’, |
fake.itin | 907-77-4407 |
fake.job | Surveyor, minerals |
fake.json | [{“name”: “Mario Gonzalez PhD”, “residency”: “29582 Alan Plain Suite 496\nEast Peggy, FL 10548”}, {“name”: “Ashley Koch”, “residency”: “637 Smith Spur Suite 465\nLake Anthony, WI 24939”}, {“name”: “Matthew Lopez”, “residency”: “5407 Jacqueline Underpass Apt. 076\nWest Katie, MO 83289”}, {“name”: “Kaylee Stone PhD”, “residency”: “970 Cortez Rest\nSheltonville, NC 55621”}, {“name”: “James Smith”, “residency”: “131 Mullen Vista Suite 147\nJordanshire, KY 62332”}, {“name”: “Hannah Nichols”, “residency”: “USCGC Nguyen\nFPO AA 29320”}, {“name”: “Crystal Snyder”, “residency”: “97306 Shawn Causeway\nWallacetown, IA 12768”}, {“name”: “Kimberly Potter”, “residency”: “0590 Taylor Trail\nZacharyburgh, MS 33137”}, {“name”: “Bonnie Byrd”, “residency”: “33542 April Union\nJuliahaven, AR 98354”}, {“name”: “Judith Jenkins”, “residency”: “15746 Davis Trafficway Suite 166\nLake John, NJ 51448”}] |
fake.language_code | or |
fake.language_name | Tatar |
fake.last_name | Wright |
fake.last_name_female | Hoffman |
fake.last_name_male | Hernandez |
fake.last_name_nonbinary | Gomez |
fake.latitude | 21.7625585 |
fake.latlng | (Decimal(‘63.615652’), Decimal(‘-98.149124’)) |
fake.lexify | Enyd |
fake.license_plate | PVZ-9007 |
fake.linux_platform_token | X11; Linux i686 |
fake.linux_processor | i686 |
fake.local_latlng | (‘39.72943’, ‘-104.83192’, ‘Aurora’, ‘US’, ‘America/Denver’) |
fake.locale | is_IS |
fake.localized_ean | 0016388652144 |
fake.localized_ean13 | 0029053440380 |
fake.localized_ean8 | 11941910 |
fake.location_on_land | (‘35.95664’, ‘36.7138’, ‘Binnish’, ‘SY’, ‘Asia/Damascus’) |
fake.longitude | -169.728120 |
fake.mac_address | 0f:0d:c0:15:79:32 |
fake.mac_platform_token | Macintosh; U; PPC Mac OS X 10 12_2 |
fake.mac_processor | PPC |
fake.md5 | e37e6d022a48d7e0f802d027032b04aa |
fake.military_apo | PSC 5595, Box 6692 |
fake.military_dpo | Unit 6288 Box 3051 |
fake.military_ship | USCGC |
fake.military_state | AA |
fake.mime_type | image/gif |
fake.month | 03 |
fake.month_name | March |
fake.msisdn | 5331986894301 |
fake.name | Trevor Rich |
fake.name_female | Ann Fuentes |
fake.name_male | Bryce Griffith |
fake.name_nonbinary | Sara Scott |
fake.nic_handle | RLQ8-FAKE |
fake.nic_handles | [‘KS25-OJUC’] |
fake.null_boolean | True |
fake.numerify | 652 |
fake.opera | Opera/8.44.(Windows NT 10.0; unm-US) spansto/2.9.164 Version/10.00 |
fake.paragraph | Clearly require father manage own role. Choose friend fish season city provide rate. Treat go raise clear quickly. |
fake.paragraphs | [‘Beyond ready step begin region. Development our after throw professor against short.’, ‘Let eye they again. Early next personal happen generation forget fly. Group any future message someone easy.’, ‘Season Mrs star study easy write. Their chance standard yeah hotel firm why. Ask any chance week agree.’] |
fake.password | LVTj1IziD+ |
fake.past_date | 2021-08-11 |
fake.past_datetime | 2021-08-16 15:06:19 |
fake.phone_number | 734.060.8523 |
fake.port_number | 22223 |
fake.postalcode | 55402 |
fake.postalcode_in_state | 97715 |
fake.postalcode_plus4 | 47166-8270 |
fake.postcode | 42307 |
fake.postcode_in_state | 23207 |
fake.spanfix | Mrs. |
fake.spanfix_female | Mrs. |
fake.spanfix_male | Mr. |
fake.spanfix_nonbinary | Mx. |
fake.pricetag | $4,813.75 |
fake.profile | {‘job’: ‘Dentist’, ‘company’: ‘Francis Group’, ‘ssn’: ‘179-03-3184’, ‘residence’: ‘73675 Mccormick Vista\nPort Amybury, WA 24899’, ‘current_location’: (Decimal(‘-7.4860615’), Decimal(‘-106.095259’)), ‘blood_group’: ‘A+’, ‘website’: [‘http://www.johnson-smith.com/’, ‘http://www.bates.biz/’, ‘https://www.gomez-moses.org/’, ‘http://yates.biz/’], ‘username’: ‘melissabailey’, ‘name’: ‘Jennifer Williams’, ‘sex’: ‘F’, ‘address’: ‘PSC 5931, Box 4914\nAPO AE 42669’, ‘mail’: ‘cynthiaadams@yahoo.com’, ‘birthdate’: datetime.date(1981, 8, 27)} |
fake.psv | “Michael Wells”|”7347 Frank Village New Jose, AZ 12787” “Alex Johnson”|”508 Cole Tunnel Suite 639 Williamburgh, NE 33390” “Joseph Meadows”|”USS Blanchard FPO AA 66097” “Laurie Burke”|”9272 Carrie Flats West Anthonyville, TX 27912” “Traci Powell”|”488 Jennifer Mountains Davidfurt, KS 50099” “Sharon Cross”|”25871 Caroline Trafficway Apt. 966 South Kennethshire, IA 59844” “Eric Leblanc”|”587 Amy Tunnel Suite 573 Elizabethland, SD 06744” “Scott Campbell”|”PSC 0434, Box 1184 APO AE 08365” “John King”|”756 Shirley Neck Suite 864 New Rebecca, KY 62527” “Dale Young”|”2676 Wagner Mount Feliciaside, DE 66301” |
fake.pybool | False |
fake.pydecimal | 283459433.55292 |
fake.pydict | {‘hand’: 8833, ‘current’: 7827, ‘special’: 7770, ‘right’: ‘ejJjehnAuwvdlyTjwhZA’, ‘company’: Decimal(‘-3.37239102590394’), ‘wife’: ‘https://www.meyer.biz/search/blog/homepage.php’, ‘read’: -210.856158532971, ‘people’: ‘cVfoGVuarhFNShZuKLXr’, ‘himself’: ‘XKOGonEBVzjrHVKFfJHY’, ‘anything’: -32071535121256.6} |
fake.pyfloat | 950227457009.336 |
fake.pyint | 8293 |
fake.pyiterable | {Decimal(‘-8806.53365815814’), Decimal(‘8705691525.92929’), 1409, ‘yjvITyupRZKQdrvgRmoL’, Decimal(‘-10619041.6630978’), ‘cDcYRiTROjcCJlHbINJx’, ‘BLWhqHBTNERMqXFtAkat’, 2326, ‘DaQNFvIZlqVJoniJwOPk’, datetime.datetime(1973, 8, 27, 4, 36, 6), 8445, 702, ‘wlang@anderson.info’} |
fake.pylist | [‘ejpxcIdfbzllsvZHPLId’, ‘QndTRjppgdrZOdhfnYnO’, ‘KfdeVzpvzuputwFUgqMx’, ‘QQsnxIJQkijDnsKxrJpz’, ‘hKGItjIIdGHUCBclStjC’, 7302, ‘uFeYreqpWPSsmOoPBEDb’] |
fake.pyset | {datetime.datetime(1974, 2, 19, 7, 4, 13), ‘nnZkVSwOWUMVqePHxCxA’, datetime.datetime(1981, 12, 19, 13, 20, 27), ‘BZMdQMjsTeghLPjaHomR’, ‘rosalessteven@yahoo.com’, ‘MNYAGpgBszBagkYpGtJt’, 4176, datetime.datetime(1985, 4, 1, 19, 51, 9), datetime.datetime(1976, 6, 18, 23, 30, 49)} |
fake.pystr | wcCPmxijLVvyojRYBPJE |
fake.pystr_format | f1-4015059C |
fake.pystruct | ([datetime.datetime(1980, 4, 1, 13, 0, 16), ‘david84@melendez.com’, Decimal(‘-3822.5902447118’), 505, ‘http://thomas.com/app/wp-content/main/category.html’, ‘qrmqLjkCfEvQkovBJqWB’, ‘XFSVfdpSThWPwRYEgChR’, ‘rZXTPcTlBhXFpUPtjYKg’, 6427, 256], {‘plan’: 6043, ‘arm’: datetime.datetime(1989, 10, 18, 0, 33, 35), ‘instead’: 8979, ‘investment’: ‘ypatterson@yahoo.com’, ‘way’: ‘JmxFREbhurEezTaOPPaQ’, ‘course’: 3666, ‘together’: -25037940576938.5, ‘out’: ‘RWvtbaDPDhbRlpTfNwCi’, ‘which’: ‘eQDuYYNszgRkECCnuNLR’, ‘debate’: ‘RYoqomPMrMAxXSuknxib’}, {‘agent’: {0: ‘fxurbxyfmmaWqWeNdvkY’, 1: [Decimal(‘-597725131.721244’), 2022, Decimal(‘17500917128720.6’)], 2: {0: Decimal(‘-50625135849541.7’), 1: ‘https://ingram.com/explore/register.htm’, 2: [‘hJcdcViZsKFddoWuOobw’, ‘eSYNTMqwgfQDXxzcFKoR’]}}, ‘even’: {1: 5101, 2: [‘PYSDbeVzoDmyQSyoBGzV’, ‘NnsCoaXfXixyFAuXajkS’, ‘http://brown.info/about/’], 3: {1: -72034.2200775236, 2: ‘AFGpAZHRcIwzZFIQUict’, 3: [‘DrxNENknLuoHfeXNJBBN’, 3567]}}, ‘night’: {2: datetime.datetime(1981, 6, 13, 19, 52, 7), 3: [1613, 3830, 3397], 4: {2: ‘gvYhtpPlzGKymlHEAPXi’, 3: ‘crystal87@hotmail.com’, 4: [‘sherri57@gmail.com’, ‘PgTLrcujpLRpfSRrjeIr’]}}, ‘style’: {3: -4829471750612.41, 4: [datetime.datetime(2017, 12, 5, 22, 23, 37), ‘PNuOnabhqgoTLEYOElKe’, 5705], 5: {3: 5.87284654416101, 4: ‘fuDEUjYmACKVITbkfuKp’, 5: [‘https://roman-jones.info/’, ‘xVJiaRgXUzdtTQiBDAnU’]}}, ‘third’: {4: Decimal(‘97529477.921929’), 5: [‘LpDHPEMhMuJWDdbWQpnv’, ‘ipnbaCxOSxxzxepMDBLF’, 7342], 6: {4: ‘TQgTYawMgBKLuoXHzakD’, 5: 448.838835096874, 6: [datetime.datetime(2014, 7, 16, 13, 41, 36), 4799]}}, ‘stop’: {5: 2501, 6: [datetime.datetime(1982, 4, 6, 13, 19, 37), ‘udiWbsSpMAkJyapJrhDe’, datetime.datetime(1993, 4, 30, 0, 22, 33)], 7: {5: 2691, 6: ‘http://wilson.com/category/index/’, 7: [‘iuWtgIJYQQqRGydMxxyo’, datetime.datetime(2016, 12, 22, 17, 21, 1)]}}, ‘wide’: {6: ‘AbPxUgvKlsMJTkZjLfim’, 7: [‘https://miller-le.com/categories/posts/main/’, ‘QVyTszErARaoNdqBLphN’, ‘IOzCAeUVnGfFPJjKnQri’], 8: {6: ‘umartinez@yahoo.com’, 7: ‘sandra35@anderson.com’, 8: [‘http://petty-adams.com/posts/home.html’, 93]}}, ‘now’: {7: 2207, 8: [1826, ‘QzYWRrpbSpGfPlkEXovR’, ‘KBAJDPCyioQOnazONyTf’], 9: {7: Decimal(‘-30579.780610314’), 8: Decimal(‘-4.6545327801111’), 9: [‘XJduICTRIpshqOrZeLBA’, ‘barrettlisa@stewart.com’]}}, ‘suffer’: {8: datetime.datetime(2020, 8, 24, 12, 35, 36), 9: [‘http://www.smith.info/terms/’, 9654, ‘EIWqCoPFCCstjGPCMpuR’], 10: {8: ‘melissa83@yahoo.com’, 9: ‘http://www.collins-peterson.net/post.html’, 10: [‘morrismichael@gmail.com’, -5.79789665945564]}}, ‘particularly’: {9: ‘MJnLmgcHHTsZxAbYuojp’, 10: [datetime.datetime(1972, 1, 9, 3, 19, 45), ‘LhuhEofDLxujPHhdjCpw’, Decimal(‘1.87685014697517’)], 11: {9: Decimal(‘683384467.700707’), 10: ‘WdAMRIqSNHCYBbBjnxKv’, 11: [-8457.45804024019, ‘dhsSWHdDtCgfeBHfjOML’]}}}) |
fake.pytimezone | tzfile(‘/usr/share/zoneinfo/Asia/Samarkand’) |
fake.pytuple | (3709, ‘aguilarkatherine@gmail.com’, ‘YbpImntiaTkUrRdSJhWX’, ‘CyUtlRZYMRreaIVezaeK’, datetime.datetime(2012, 12, 28, 13, 29, 28), Decimal(‘18938402.3875171’), ‘kvIYZZIETCbHrOinOmmo’, 8732, ‘lgUAAtTDfCJbMJmiqUSU’, ‘cXoPnrcnMvSbWFyrdIVL’) |
fake.random_choices | [‘c’, ‘c’] |
fake.random_digit | 0 |
fake.random_digit_not_null | 4 |
fake.random_digit_not_null_or_empty | 7 |
fake.random_digit_or_empty | |
fake.random_element | a |
fake.random_elements | [‘c’, ‘b’] |
fake.random_int | 6496 |
fake.random_letter | r |
fake.random_letters | [‘x’, ‘J’, ‘b’, ‘i’, ‘T’, ‘L’, ‘Z’, ‘T’, ‘Q’, ‘X’, ‘a’, ‘n’, ‘L’, ‘T’, ‘Q’, ‘Y’] |
fake.random_lowercase_letter | e |
fake.random_number | 78977 |
fake.random_sample | [‘c’, ‘b’, ‘a’] |
fake.random_uppercase_letter | D |
fake.randomize_nb_elements | 11 |
fake.rgb_color | 220,13,24 |
fake.rgb_css_color | rgb(236,165,162) |
fake.ripe_id | ORG-OBH71582-RIPE |
fake.safari | Mozilla/5.0 (Macintosh; Intel Mac OS X 10 10_4 rv:2.0; sq-AL) AppleWebKit/531.9.3 (KHTML, like Gecko) Version/4.0 Safari/531.9.3 |
fake.safe_color_name | fuchsia |
fake.safe_domain_name | example.net |
fake.safe_email | matthewholland@example.net |
fake.safe_hex_color | #449900 |
fake.secondary_address | Suite 650 |
fake.seed_instance | None |
fake.sentence | Rise kid cell involve suggest support. |
fake.sentences | [‘Stock our bar.’, ‘spanssure capital know such Congress particularly fly.’, ‘Eye charge few their five.’] |
fake.sha1 | 952a4535af8c83e2fa92ab889686a3ca1f1f9115 |
fake.sha256 | 1694a7d23051b104393e10d31ff30a5f1e46b23b19b589e1dd834b577bb81e33 |
fake.simple_profile | {‘username’: ‘burtonnancy’, ‘name’: ‘Joseph Thompson’, ‘sex’: ‘M’, ‘address’: ‘94354 Perez Cliffs Apt. 299\nMartintown, NY 76630’, ‘mail’: ‘wmeyer@yahoo.com’, ‘birthdate’: datetime.date(1908, 6, 18)} |
fake.slug | instead-ever |
fake.ssn | 629-76-6588 |
fake.state | California |
fake.state_abbr | CA |
fake.street_address | 1784 Wells Passage Suite 054 |
fake.street_name | Keith Island |
fake.street_suffix | Fords |
fake.suffix | DDS |
fake.suffix_female | MD |
fake.suffix_male | DDS |
fake.suffix_nonbinary | II |
fake.swift | TCXZGBR3SLR |
fake.swift11 | ZQAVGBM0VGJ |
fake.swift8 | KAFGGB02 |
fake.time | 03:05:43 |
fake.time_delta | 0:00:00 |
fake.time_object | 09:20:55 |
fake.time_series | |
fake.timezone | America/Nassau |
fake.tld | org |
fake.tsv | “Charles Chung” “7239 George Tunnel Suite 851 Watkinsfurt, KY 21713” “Jessica Curtis” “130 James Mill Suite 888 Michaelchester, PA 87290” “Diane Smith MD” “4551 John Drive Suite 511 Jasonmouth, MD 40664” “Courtney Cunningham” “73075 Jarvis Inlet Roseside, OR 61500” “Karen Hernandez DVM” “05867 Davis Corners Suite 154 Williammouth, OK 75823” “Brian Morris” “89547 Abigail Locks Kevinstad, MT 04155” “Jennifer Hart” “9977 Tran Extensions Apt. 058 West Brenda, NH 57053” “Jacqueline Moore” “44492 Mary Village Apt. 995 Lake Lonnie, OH 69299” “Gregory Brady” “83333 Davis Common Port Calvin, RI 70021” “Tiffany Wiggins” “9373 Holloway Causeway Oconnorton, CT 62855” |
fake.unix_device | /dev/vde |
fake.unix_partition | /dev/vdw0 |
fake.unix_time | 20580974 |
fake.upc_a | 970061018989 |
fake.upc_e | 14802928 |
fake.uri | https://barnes.com/faq/ |
fake.uri_extension | .jsp |
fake.uri_page | privacy |
fake.uri_path | app |
fake.url | http://www.soto-davenport.com/ |
fake.user_agent | Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 5.1; Trident/4.1) |
fake.user_name | erin21 |
fake.uuid4 | 38fbd9a9-0b05-49c3-937e-5856a803548b |
fake.windows_platform_token | Windows 95 |
fake.word | stand |
fake.words | [‘chance’, ‘especially’, ‘center’] |
fake.year | 1994 |
fake.zipcode | 47750 |
fake.zipcode_in_state | 86077 |
fake.zipcode_plus4 | 44500-9458 |
When using the behave framework for functional testing it’s often necessary to set some data at the start of the testing and be able to make use of it throughout the test run.
The context
object (api of the object) is there to help you however I don’t think the current documentation makes it as it clear as it should be how you do this.
Within the environment.py
(placed in your features
directory) you can define an event handler to run before any testing is done, that event handler is called before_all
below is an example of using before_all
to set an arbitrary value which is then available through out the test run.
#This event runs before any of your tests
def before_all(context):
#Choose whatever property name you like and assign
#a value to it. In this case I have chosen 'colour'
#and assigned "RED" to it.
context.colour = "RED"
#You can assign any python object to one of these
#properties, here's an example of assigning a dictionary
#to one
context.weather = {'temp-centigrade': '21', 'wind-speed-kmh': 5}
The context
object is used by behave for other purposes so whatever property you set you need to check that it’s not one that is used by behave internally.
There’s a list of the internally used properties here so you can avoid them.
To ensure you don’t accidentally stomp on one of the predefined properties it might be best to use only one top level property (eg context.my_project_name
) and assign an empty dictionary to that. You can then store everything you want within the dictionary at context.my_project_name
).
I’ve taken to using pipenv (“Python Development Workflow for Humans”) recently and so I frequently come across things I haven’t done previously and need to figure out how to. Todays’s is using pipenv to install a package from a github repository.
So, short and sweet, here’s how. In my case I have forked the repos ‘behave-web-api‘ and I want to install my forked version into my current project.
$ pipenv install -e git+ssh://git@github.com/shearichard/behave-web-api.git#egg=behave-web-api
Notice the git+ssh is used as the scheme of the url. Also notice that the egg=behave-web-api
(with the value after the equals sign changed to whatever package you’re dealing with) is necessary .
References
The pipenv doco for this is comprehensive but because it’s so comprehensive is a little more than you might need in a lot of cases. I also found the note written to himself by Koen Woortman a useful pointer.
As a reminder to me, and I hope, a help to others here are the various ways in which JavaScript arrow functions can be used to reduce the amount of code you write.
Here I start with an old fashioned JavaScript function being used as an argument to the map function and then step by step reduce the amount of the code to take full advantage of the possibilities of JavaScript arrow functions. Not all of these steps would be possible in all circumstances.
//Test data is an array of integers
const nums = [1,2,3,4,5,6,7,8,9,10]
//We start by using a 'traditional'
//function definition as our argument
//to 'map'
const first_approach = nums.map(
function(n){
return num * 2
}
)
//Convert the 'traditional' function
//definition to an arrow function
const second_approach = nums.map((n) => {
return n * 2
})
//When there's only one argument to the
//function we can remove the brackets
//around the argument, so 'n' is no
//longer bracketed
const third_approach = nums.map(n => {
return n * 2
})
//Because only one thing is being
//returned the processing can all be
//placed on one line ...
const fourth_approach = nums.map(n => { return n * 2 })
//Take advantage of the implicit return
//within an arrow function so we no longer
//need to use 'return' and, in the process,
//do away with the curly brackets.
const fifth_approach = nums.map(n => n * 2 )

So just to summarise, in the right circumstances it’s possible to go from this …
//Longest version
const first_approach = nums.map(
function(n){
return num * 2
}
)
… to this .
//Shortest version
const fifth_approach = nums.map(n => n * 2 )
Fuller details about when all of these optimisations are possible are available on the excellent MDN Arrow Function page.
I just had a VirtualBox client machine start but the window it was running in was blank. I fiddled around for a while and then waited. Still nothing in the client machine window but blackness.
I looked at the logs held by VirtualBox and there was nothing that looked unusual, although there’s a lot in those logs and I never normally read them so plenty of scope for overlooking something significant.
Then I tried to ssh into the client machine, fully expecting this to fail. It worked!
Then I found this web page and it mentioned Display Memory. Well I knew the display memory had been good the last time I used the VM so I couldn’t see how that was a problem ? But in fact when I went into settings I discovered the Display Memory had been changed to 1MB. My sticky fingers at work I guess ? Regardless I gave it 128MB and closed down the machine through the SSH session, then restarted and, bang !, the machine’s display was back working as it should have been.
Long story short if your Virtualbox machine is blank go and check the Display Memory settings.
Today I’ve started my first django-sockpuppet project ( https://pypi.org/project/django-sockpuppet/ ).
If you’re using pipenv the first thing you need to do is
pipenv install django-sockpuppet
but I found that command failed when it came to installing the dependency on Twisted https://pypi.org/project/Twisted/ .
The problem was that I had started using a new virtual machine for development and it was lacking libraries which Twisted depends on. To be clear this is an Ubuntu 20.x machine and this problem may be specific to that environment.
So if you’re using django-sockpuppet and you have problems installing it try executing the following.
sudo apt-get install python3-dev sudo apt-get install libevent-dev
This is pretty standard stuff for a new machine but easy to forget if you don’t change very often.
This is going to be of interest if you’re using the ember-cli-jstree addon and you want to programmatically open a node in the tree. It’s niche, but if you want it … here it is.
If you want a tree widget as part of your interface then the jsTree jquery plugin is a good option. I’ve used it on a number of projects and while it’s not perfect it’s really very good.
If you’re working with Ember.js then an ember addon, ember-cli-jstree, exists to allow you to use the jsTree plugin in a more “emberish” manner.
So for our current purposes I’m going to assume you’ve
Looking at the documentation, here and here , it seems that all that’s needed is to specify the node you want to open but I’ve found that’s not so.
In fact if you want to open a node other than the topmost node it’s necessary to make a series of calls to open_node
starting at the topmost node and ‘walking’ down to the node you wish to open.
So imagine you have a tree which shows areas of the United States and that you wish to open a node that corresponds to the street in New York City called Broadway.
On first reading it would seem that all that was necessary was to execute the following, but that’s not so.
this.myActionReceiver.send('openNode', 'Broadway');
In fact to do that it would be necessary to execute the following processing
this.myActionReceiver.send('openNode', 'NY');
this.myActionReceiver.send('openNode', 'NewYorkCity');
this.myActionReceiver.send('openNode', 'Manhattan');
this.myActionReceiver.send('openNode', 'Broadway');
If you find yourself having do this then it’s worth remembering that the parameters passed to a number of events include a action
object and within the action
object there is an array of parents
which in the above example would look like this.
# action.node.parents
["Manhattan", "NewYorkCity", "NY", "#"]
Hope it was helpful.