问:
subsetting data frame columns in a particular order by partial string matching
I'm stuck with an attempt to subset columns in order from a very wide formatted dataframe. 1 row, couple thousand columns. column names are repetitive so they are all tagged with "...1/2/3/4/5" when retrieved and readin by R

sample data:

```dput(mydata)

structure(list(general_issue_code...1 = "MMM", general_issue_code_display...2 = "Medicare/Medicaid",
    description...3 = "340B Drug Pricing Program; Medicare Shared Savings Program; Medicare Advantage; Alternative Payment Models; Graduate Medical Education;Centers for Medicare and Medicaid Innovation; Stark Law Reform/Modernization; Value-Based Purchasing Payments; Post-Acute and Home HealthCare Payments; Drug Pricing and Medicare Parts B and D; Medicare Regulatory Reform; Medicaid Funding; Health Care Innovation; Telehealth/Digital Health; Surprise\nBilling; Anti-Kickback Statute Reform; CREATES Act; COVID-19; Value in Health Care Act",
    foreign_entity_issues...4 = "", id...5 = 71171L, first_name...6 = "JOYCE",
    last_name...7 = "ROGERS", new...8 = FALSE, id...9 = 79365L,
    first_name...10 = "THOMAS", last_name...11 = "MCDANIELS",
    suffix...12 = "jr", suffix_display...13 = "JR", new...14 = FALSE,
    id...15 = 58395L, first_name...16 = "MEGHAN", last_name...17 = "CLUNE WOLTMAN",
    new...18 = TRUE, id...19 = 89715L, first_name...20 = "JILL",
    last_name...21 = "DOWELL", new...22 = FALSE, id...23 = 93159L,
    first_name...24 = "JOYCE", middle_name...25 = "A", last_name...26 = "ROGERS",
    new...27 = FALSE, id...28 = 93160L, first_name...29 = "THOMAS",
    last_name...30 = "MCDANIELS", new...31 = FALSE, id...32 = 93161L,
    first_name...33 = "MEGHAN", last_name...34 = "WOLTMAN", new...35 = TRUE,
    id...36 = 69176L, first_name...37 = "ANTHONY", last_name...38 = "CURRY",
    new...39 = FALSE, id...40 = 93163L, first_name...41 = "JILL",
    last_name...42 = "DOWELL - EFFECTIVE 2/9/21", new...43 = FALSE,
    id...44 = 34L, name...45 = "Health & Human Services, Dept of (HHS)",
    id...46 = 2L, name...47 = "HOUSE OF REPRESENTATIVES", id...48 = 1L,
    name...49 = "SENATE", general_issue_code...50 = "HCR", general_issue_code_display...51 = "Health Issues",
    description...52 = "340B Drug Pricing Program; Medicare Shared Savings Program; Medicare Advantage; Alternative Payment Models; Graduate Medical Education;Centers for Medicare and Medicaid Innovation; Stark Law Reform/Modernization; Value-Based Purchasing Payments; Post-Acute and Home HealthCare Payments; Drug Pricing and Medicare Parts B and D; Medicare Regulatory Reform; Medicaid Funding; Health Care Innovation; Telehealth/Digital Health; Surprise\nBilling; Anti-Kickback Statute Reform; CREATES Act; COVID-19; Value in Health Care Act",
    foreign_entity_issues...53 = "", id...54 = 71171L, first_name...55 = "JOYCE",
    last_name...56 = "ROGERS", new...57 = FALSE, id...58 = 79365L,
    first_name...59 = "THOMAS", last_name...60 = "MCDANIELS",
    suffix...61 = "jr", suffix_display...62 = "JR", new...63 = FALSE,
    id...64 = 58395L, first_name...65 = "MEGHAN", last_name...66 = "CLUNE WOLTMAN",
    new...67 = TRUE, id...68 = 89715L, first_name...69 = "JILL",
    last_name...70 = "DOWELL", new...71 = FALSE, id...72 = 69176L,
    first_name...73 = "ANTHONY", last_name...74 = "CURRY", new...75 = FALSE,
    id...76 = 93159L, first_name...77 = "JOYCE", middle_name...78 = "A",
    last_name...79 = "ROGERS", new...80 = FALSE, id...81 = 93160L,
    first_name...82 = "THOMAS", last_name...83 = "MCDANIELS",
    new...84 = FALSE, id...85 = 93161L, first_name...86 = "MEGHAN",
    last_name...87 = "WOLTMAN", new...88 = TRUE, id...89 = 93163L,
    first_name...90 = "JILL", last_name...91 = "DOWELL - EFFECTIVE 2/9/21",
    new...92 = FALSE, id...93 = 34L, name...94 = "Health & Human Services, Dept of (HHS)",
    id...95 = 2L, name...96 = "HOUSE OF REPRESENTATIVES", id...97 = 1L,
    name...98 = "SENATE", general_issue_code...1.1 = "VET", general_issue_code_display...2.1 = "Veterans",
    description...3.1 = "Implementation of MISSION Act (PL 115-182) and the problems with same as experienced by podiatric physicians and surgeons.",
    foreign_entity_issues...4.1 = "", id...5.1 = 93368L, first_name...6.1 = "BENJAMIN",
    last_name...7.1 = "WALLNER", new...8.1 = FALSE, id...9.1 = 53293L,
    prefix...10 = "mr", prefix_display...11 = "MR.", first_name...12 = "BENJAMIN",
    middle_name...13 = "J", last_name...14 = "WALLNER", new...15 = FALSE,
    id...16 = 136L, name...17 = "Centers For Medicare and Medicaid Services (CMS)",
    id...18 = 2L, name...19 = "HOUSE OF REPRESENTATIVES", id...20 = 1L,
    name...21 = "SENATE", general_issue_code...22 = "EDU", general_issue_code_display...23 = "Education",
    description...24 = "Medical student loan assistance; graduate medical education; higher education act reauthorization; student loan reform; student loan forgiveness for providers during public health emergency.",
    foreign_entity_issues...25 = "", id...26 = 93368L, first_name...27 = "BENJAMIN",
    last_name...28 = "WALLNER", new...29 = FALSE, id...30 = 53293L,
    prefix...31 = "mr", prefix_display...32 = "MR.", first_name...33.1 = "BENJAMIN",
    middle_name...34 = "J", last_name...35 = "WALLNER", new...36 = FALSE,
    id...37 = 136L, name...38 = "Centers For Medicare and Medicaid Services (CMS)",
    id...39 = 2L, name...40 = "HOUSE OF REPRESENTATIVES", id...41 = 1L,
    name...42 = "SENATE", general_issue_code...43 = "HCR", general_issue_code_display...44 = "Health Issues",
    description...45 = "Medicaid access to podiatry and program integrity; Medicare therapeutic shoe program for patients with diabetes; MACRA/MIPS implementation and Physician Fee Schedule proposed updates as pertains to physicians and providers. Seeking pandemic relief for providers.",
    foreign_entity_issues...46 = "", id...47 = 93368L, first_name...48 = "BENJAMIN",
    last_name...49 = "WALLNER", new...50 = FALSE, id...51 = 53293L,
    prefix...52 = "mr", prefix_display...53 = "MR.", first_name...54 = "BENJAMIN",
    middle_name...55 = "J", last_name...56.1 = "WALLNER", new...57.1 = FALSE,
    id...58.1 = 136L, name...59 = "Centers For Medicare and Medicaid Services (CMS)",
    id...60 = 2L, name...61 = "HOUSE OF REPRESENTATIVES", id...62 = 1L,
    name...63 = "SENATE", general_issue_code...1.2 = "DEF", general_issue_code_display...2.2 = "Defense",
    description...3.2 = "telemedicine", foreign_entity_issues...4.2 = "",
    id...5.2 = 45748L, first_name...6.2 = "OLIVER", last_name...7.2 = "MEISSNER",
    new...8.2 = FALSE, id...9.2 = 75684L, first_name...10.1 = "CHARLES",
    last_name...11.1 = "PROSCH", new...12 = FALSE, id...13 = 93367L,
    first_name...14 = "MICHAEL", last_name...15 = "TOROUNIAN",
    new...16 = FALSE, id...17 = 80766L, first_name...18 = "BRANDON",
    last_name...19 = "KIRBY", new...20 = TRUE, id...21 = 75303L,
    first_name...22 = "MICHAEL", middle_name...23 = "WILLIAM",
    last_name...24 = "TOROUNIAN", new...25 = FALSE, id...26.1 = 134L,
    name...27 = "Centers For Disease Control & Prevention (CDC)",
    id...28.1 = 25L, name...29 = "Defense, Dept of (DOD)", id...30.1 = 34L,
    name...31 = "Health & Human Services, Dept of (HHS)", id...32.1 = 2L,
    name...33 = "HOUSE OF REPRESENTATIVES", id...34 = 1L, name...35 = "SENATE",
    id...36.1 = 39L, name...37 = "State, Dept of (DOS)", id...38 = 12L,
    name...39 = "White House Office", general_issue_code...40 = "MMM",
    general_issue_code_display...41 = "Medicare/Medicaid", description...42 = "telemedcine",
    foreign_entity_issues...43 = "", id...44.1 = 93367L, first_name...45 = "MICHAEL",
    last_name...46 = "TOROUNIAN", new...47 = FALSE, id...48.1 = 45748L,
    first_name...49 = "OLIVER", last_name...50 = "MEISSNER",
    new...51 = FALSE, id...52 = 75303L, first_name...53 = "MICHAEL",
    middle_name...54 = "WILLIAM", last_name...55 = "TOROUNIAN",
    new...56 = FALSE, id...57 = 75684L, first_name...58 = "CHARLES",
    last_name...59 = "PROSCH", new...60 = FALSE, id...61 = 80766L,
    first_name...62 = "BRANDON", last_name...63 = "KIRBY", new...64 = TRUE,
    id...65 = 134L, name...66 = "Centers For Disease Control & Prevention (CDC)",
    id...67 = 25L, name...68 = "Defense, Dept of (DOD)", id...69 = 34L,
    name...70 = "Health & Human Services, Dept of (HHS)", id...71 = 2L,
    name...72 = "HOUSE OF REPRESENTATIVES", id...73 = 1L, name...74 = "SENATE",
    id...75 = 39L, name...76 = "State, Dept of (DOS)", id...77 = 12L,
    name...78 = "White House Office", general_issue_code...1.3 = "HCR",
    general_issue_code_display...2.3 = "Health Issues", description...3.3 = "H.R. 1439 The Expanded Genetic Screening Act of 2021: \"To amend title XIX of the Social Security Act to provide for coverage under the Medicaid program of non-invasive prenatal genetic screening\"",
    foreign_entity_issues...4.3 = "", id...5.3 = 45748L, first_name...6.3 = "OLIVER",
    last_name...7.3 = "MEISSNER", new...8.3 = FALSE, id...9.3 = 75684L,
    first_name...10.2 = "CHARLES", last_name...11.2 = "PROSCH",
    new...12.1 = FALSE, id...13.1 = 80766L, first_name...14.1 = "BRANDON",
    last_name...15.1 = "KIRBY", new...16.1 = TRUE, id...17.1 = 93404L,
    first_name...18.1 = "MICHAEL", last_name...19.1 = "TOROUNIAN",
    new...20.1 = FALSE, id...21.1 = 75303L, first_name...22.1 = "MICHAEL",
    middle_name...23.1 = "WILLIAM", last_name...24.1 = "TOROUNIAN",
    new...25.1 = FALSE, id...26.2 = 34L, name...27.1 = "Health & Human Services, Dept of (HHS)",
    id...28.2 = 2L, name...29.1 = "HOUSE OF REPRESENTATIVES",
    id...30.2 = 1L, name...31.1 = "SENATE", general_issue_code...32 = "MMM",
    general_issue_code_display...33 = "Medicare/Medicaid", description...34 = "H.R. 1439 The Expanded Genetic Screening Act of 2021: \"To amend title XIX of the Social Security Act to provide for coverage under the Medicaid program of non-invasive prenatal genetic screening\"",
    foreign_entity_issues...35 = "", id...36.2 = 45748L, first_name...37.1 = "OLIVER",
    last_name...38.1 = "MEISSNER", new...39.1 = FALSE, id...40.1 = 75684L,
    first_name...41.1 = "CHARLES", last_name...42.1 = "PROSCH",
    new...43.1 = FALSE, id...44.2 = 80766L, first_name...45.1 = "BRANDON",
    last_name...46.1 = "KIRBY", new...47.1 = FALSE, id...48.2 = 93404L,
    first_name...49.1 = "MICHAEL", last_name...50.1 = "TOROUNIAN",
    new...51.1 = FALSE, id...52.1 = 75303L, first_name...53.1 = "MICHAEL",
    middle_name...54.1 = "WILLIAM", last_name...55.1 = "TOROUNIAN",
    new...56.1 = FALSE, id...57.1 = 34L, name...58 = "Health & Human Services, Dept of (HHS)",
    id...59 = 2L, name...60 = "HOUSE OF REPRESENTATIVES", id...61.1 = 1L,
    name...62 = "SENATE", general_issue_code = "VET", general_issue_code_display = "Veterans",
    description = "Veteran Healthcare, Veteran Benefits, Military Quality of Life Programs.",
    foreign_entity_issues = "", id...5.4 = 73532L, first_name...6.4 = "PAT",
    last_name...7.4 = "MURRAY", new...8.4 = FALSE, id...9.4 = 87133L,
    first_name...10.3 = "PATRICK", last_name...11.3 = "MURRAY",
    new...12.2 = FALSE, id...13.2 = 25L, name...14 = "Defense, Dept of (DOD)",
    id...15.1 = 2L, name...16 = "HOUSE OF REPRESENTATIVES", id...17.2 = 38L,
    name...18 = "Labor, Dept of (DOL)", id...19.1 = 1L, name...20 = "SENATE",
    id...21.2 = 90L, name...22 = "Small Business Administration (SBA)",
    id...23.1 = 42L, name...24 = "Veterans Affairs, Dept of (VA)",
    id...25 = 170L, name...26 = "Veterans Employment & Training Service",
    general_issue_code.1 = "TEC", general_issue_code_display.1 = "Telecommunications",
    description.1 = "Issues include the USA Telecommunications Act and overall spectrum and technology policy, with a focus on 5G.",
    foreign_entity_issues.1 = "", id...5.5 = 93561L, first_name...6.5 = "DAVID",
    last_name...7.5 = "MURRAY", new...8.5 = FALSE, id...9.5 = 79245L,
    first_name...10.4 = "DAVID", middle_name = "THOMAS", last_name...12 = "MURRAY",
    new...13 = FALSE, id...14 = 2L, name...15 = "HOUSE OF REPRESENTATIVES",
    id...16.1 = 1L, name...17.1 = "SENATE", general_issue_code.2 = "TRA",
    general_issue_code_display.2 = "Transportation", description.2 = "Agricultural and transportation issues",
    foreign_entity_issues.2 = "", id...5.6 = 64951L, first_name = "BRITTON",
    last_name = "CLARKE", covered_position = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new = FALSE, id...10 = 23L, name...11 = "Agriculture, Dept of (USDA)",
    id...12 = 2L, name...13 = "HOUSE OF REPRESENTATIVES", id...14.1 = 1L,
    name...15.1 = "SENATE", general_issue_code.3 = "TRA", general_issue_code_display.3 = "Transportation",
    description.3 = "Transportation issues", foreign_entity_issues.3 = "",
    id...5.7 = 64951L, first_name.1 = "BRITTON", last_name.1 = "CLARKE",
    covered_position.1 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new.1 = FALSE, id...10.1 = 201L, name...11.1 = "Homeland Security, Dept of (DHS)",
    id...12.1 = 2L, name...13.1 = "HOUSE OF REPRESENTATIVES",
    id...14.2 = 1L, name...15.2 = "SENATE", general_issue_code.4 = "TRA",
    general_issue_code_display.4 = "Transportation", description.4 = "Transportation issues",
    foreign_entity_issues.4 = "", id...5.8 = 64951L, first_name.2 = "BRITTON",
    last_name.2 = "CLARKE", covered_position.2 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new.2 = FALSE, id...10.2 = 2L, name...11.2 = "HOUSE OF REPRESENTATIVES",
    id...12.2 = 1L, name...13.2 = "SENATE", general_issue_code...1.4 = "TRD",
    general_issue_code_display...2.4 = "Trade (domestic/foreign)",
    description...3.4 = "Trade, border relations, port operations",
    foreign_entity_issues...4.4 = "", id...5.9 = 64951L, first_name...6.6 = "BRITTON",
    last_name...7.6 = "CLARKE", covered_position.3 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new...9 = FALSE, id...10.3 = 24L, name...11.3 = "Commerce, Dept of (DOC)",
    id...12.3 = 2L, name...13.3 = "HOUSE OF REPRESENTATIVES",
    id...14.3 = 1L, name...15.3 = "SENATE", id...16.2 = 39L,
    name...17.2 = "State, Dept of (DOS)", general_issue_code...18 = "TRA",
    general_issue_code_display...19 = "Transportation", description...20 = "Trade, border travel, ports of entry",
    foreign_entity_issues...21 = "", id...22 = 64951L, first_name...23 = "BRITTON",
    last_name...24.2 = "CLARKE", new...25.2 = TRUE, id...26.3 = 24L,
    name...27.2 = "Commerce, Dept of (DOC)", id...28.3 = 2L,
    name...29.2 = "HOUSE OF REPRESENTATIVES", id...30.3 = 1L,
    name...31.2 = "SENATE", id...32.2 = 39L, name...33.1 = "State, Dept of (DOS)",
    general_issue_code...1.5 = "TRD", general_issue_code_display...2.5 = "Trade (domestic/foreign)",
    description...3.5 = "International trade", foreign_entity_issues...4.5 = "",
    id...5.10 = 64951L, first_name...6.7 = "BRITTON", last_name...7.7 = "CLARKE",
    covered_position...8 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new...9.1 = FALSE, id...10.4 = 2L, name...11.4 = "HOUSE OF REPRESENTATIVES",
    id...12.4 = 1L, name...13.4 = "SENATE", general_issue_code...14 = "TRA",
    general_issue_code_display...15 = "Transportation", description...16 = "Transportation issues; border travel",
    foreign_entity_issues...17 = "", id...18.1 = 64951L, first_name...19 = "BRITTON",
    last_name...20 = "CLARKE", covered_position...21 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new...22.1 = FALSE, id...23.2 = 2L, name...24.1 = "HOUSE OF REPRESENTATIVES",
    id...25.1 = 1L, name...26.1 = "SENATE", general_issue_code.5 = "TRA",
    general_issue_code_display.5 = "Transportation", description.5 = "Speed limiters",
    foreign_entity_issues.5 = "", id...5.11 = 64951L, first_name.3 = "BRITTON",
    last_name.3 = "CLARKE", covered_position.4 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new.3 = FALSE, id...10.5 = 2L, name...11.5 = "HOUSE OF REPRESENTATIVES",
    id...12.5 = 1L, name...13.5 = "SENATE", general_issue_code.6 = "TRA",
    general_issue_code_display.6 = "Transportation", description.6 = "Transportation issues",
    foreign_entity_issues.6 = "", id...5.12 = 64951L, first_name.4 = "BRITTON",
    last_name.4 = "CLARKE", covered_position.5 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new.4 = FALSE, id...10.6 = 2L, name...11.6 = "HOUSE OF REPRESENTATIVES",
    id...12.6 = 1L, name...13.6 = "SENATE", general_issue_code.7 = "TRA",
    general_issue_code_display.7 = "Transportation", description.7 = "Transportation issues",
    foreign_entity_issues.7 = "", id...5.13 = 64951L, first_name.5 = "BRITTON",
    last_name.5 = "CLARKE", covered_position.6 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new.5 = FALSE, id...10.7 = 2L, name...11.7 = "HOUSE OF REPRESENTATIVES",
    id...12.7 = 1L, name...13.7 = "SENATE", id...14.4 = 40L,
    name...15.4 = "Transportation, Dept of (DOT)", general_issue_code.8 = "TRA",
    general_issue_code_display.8 = "Transportation", description.8 = "Transportation technologies",
    foreign_entity_issues.8 = "", id...5.14 = 64951L, first_name.6 = "BRITTON",
    last_name.6 = "CLARKE", covered_position.7 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new.6 = FALSE, id...10.8 = 2L, name...11.8 = "HOUSE OF REPRESENTATIVES",
    id...12.8 = 1L, name...13.8 = "SENATE"), row.names = 1L, class = "data.frame")
> dput(q<-q[1,1:200])
structure(list(general_issue_code...1 = "MMM", general_issue_code_display...2 = "Medicare/Medicaid",
    description...3 = "340B Drug Pricing Program; Medicare Shared Savings Program; Medicare Advantage; Alternative Payment Models; Graduate Medical Education;Centers for Medicare and Medicaid Innovation; Stark Law Reform/Modernization; Value-Based Purchasing Payments; Post-Acute and Home HealthCare Payments; Drug Pricing and Medicare Parts B and D; Medicare Regulatory Reform; Medicaid Funding; Health Care Innovation; Telehealth/Digital Health; Surprise\nBilling; Anti-Kickback Statute Reform; CREATES Act; COVID-19; Value in Health Care Act",
    foreign_entity_issues...4 = "", id...5 = 71171L, first_name...6 = "JOYCE",
    last_name...7 = "ROGERS", new...8 = FALSE, id...9 = 79365L,
    first_name...10 = "THOMAS", last_name...11 = "MCDANIELS",
    suffix...12 = "jr", suffix_display...13 = "JR", new...14 = FALSE,
    id...15 = 58395L, first_name...16 = "MEGHAN", last_name...17 = "CLUNE WOLTMAN",
    new...18 = TRUE, id...19 = 89715L, first_name...20 = "JILL",
    last_name...21 = "DOWELL", new...22 = FALSE, id...23 = 93159L,
    first_name...24 = "JOYCE", middle_name...25 = "A", last_name...26 = "ROGERS",
    new...27 = FALSE, id...28 = 93160L, first_name...29 = "THOMAS",
    last_name...30 = "MCDANIELS", new...31 = FALSE, id...32 = 93161L,
    first_name...33 = "MEGHAN", last_name...34 = "WOLTMAN", new...35 = TRUE,
    id...36 = 69176L, first_name...37 = "ANTHONY", last_name...38 = "CURRY",
    new...39 = FALSE, id...40 = 93163L, first_name...41 = "JILL",
    last_name...42 = "DOWELL - EFFECTIVE 2/9/21", new...43 = FALSE,
    id...44 = 34L, name...45 = "Health & Human Services, Dept of (HHS)",
    id...46 = 2L, name...47 = "HOUSE OF REPRESENTATIVES", id...48 = 1L,
    name...49 = "SENATE", general_issue_code...50 = "HCR", general_issue_code_display...51 = "Health Issues",
    description...52 = "340B Drug Pricing Program; Medicare Shared Savings Program; Medicare Advantage; Alternative Payment Models; Graduate Medical Education;Centers for Medicare and Medicaid Innovation; Stark Law Reform/Modernization; Value-Based Purchasing Payments; Post-Acute and Home HealthCare Payments; Drug Pricing and Medicare Parts B and D; Medicare Regulatory Reform; Medicaid Funding; Health Care Innovation; Telehealth/Digital Health; Surprise\nBilling; Anti-Kickback Statute Reform; CREATES Act; COVID-19; Value in Health Care Act",
    foreign_entity_issues...53 = "", id...54 = 71171L, first_name...55 = "JOYCE",
    last_name...56 = "ROGERS", new...57 = FALSE, id...58 = 79365L,
    first_name...59 = "THOMAS", last_name...60 = "MCDANIELS",
    suffix...61 = "jr", suffix_display...62 = "JR", new...63 = FALSE,
    id...64 = 58395L, first_name...65 = "MEGHAN", last_name...66 = "CLUNE WOLTMAN",
    new...67 = TRUE, id...68 = 89715L, first_name...69 = "JILL",
    last_name...70 = "DOWELL", new...71 = FALSE, id...72 = 69176L,
    first_name...73 = "ANTHONY", last_name...74 = "CURRY", new...75 = FALSE,
    id...76 = 93159L, first_name...77 = "JOYCE", middle_name...78 = "A",
    last_name...79 = "ROGERS", new...80 = FALSE, id...81 = 93160L,
    first_name...82 = "THOMAS", last_name...83 = "MCDANIELS",
    new...84 = FALSE, id...85 = 93161L, first_name...86 = "MEGHAN",
    last_name...87 = "WOLTMAN", new...88 = TRUE, id...89 = 93163L,
    first_name...90 = "JILL", last_name...91 = "DOWELL - EFFECTIVE 2/9/21",
    new...92 = FALSE, id...93 = 34L, name...94 = "Health & Human Services, Dept of (HHS)",
    id...95 = 2L, name...96 = "HOUSE OF REPRESENTATIVES", id...97 = 1L,
    name...98 = "SENATE", general_issue_code...1.1 = "VET", general_issue_code_display...2.1 = "Veterans",
    description...3.1 = "Implementation of MISSION Act (PL 115-182) and the problems with same as experienced by podiatric physicians and surgeons.",
    foreign_entity_issues...4.1 = "", id...5.1 = 93368L, first_name...6.1 = "BENJAMIN",
    last_name...7.1 = "WALLNER", new...8.1 = FALSE, id...9.1 = 53293L,
    prefix...10 = "mr", prefix_display...11 = "MR.", first_name...12 = "BENJAMIN",
    middle_name...13 = "J", last_name...14 = "WALLNER", new...15 = FALSE,
    id...16 = 136L, name...17 = "Centers For Medicare and Medicaid Services (CMS)",
    id...18 = 2L, name...19 = "HOUSE OF REPRESENTATIVES", id...20 = 1L,
    name...21 = "SENATE", general_issue_code...22 = "EDU", general_issue_code_display...23 = "Education",
    description...24 = "Medical student loan assistance; graduate medical education; higher education act reauthorization; student loan reform; student loan forgiveness for providers during public health emergency.",
    foreign_entity_issues...25 = "", id...26 = 93368L, first_name...27 = "BENJAMIN",
    last_name...28 = "WALLNER", new...29 = FALSE, id...30 = 53293L,
    prefix...31 = "mr", prefix_display...32 = "MR.", first_name...33.1 = "BENJAMIN",
    middle_name...34 = "J", last_name...35 = "WALLNER", new...36 = FALSE,
    id...37 = 136L, name...38 = "Centers For Medicare and Medicaid Services (CMS)",
    id...39 = 2L, name...40 = "HOUSE OF REPRESENTATIVES", id...41 = 1L,
    name...42 = "SENATE", general_issue_code...43 = "HCR", general_issue_code_display...44 = "Health Issues",
    description...45 = "Medicaid access to podiatry and program integrity; Medicare therapeutic shoe program for patients with diabetes; MACRA/MIPS implementation and Physician Fee Schedule proposed updates as pertains to physicians and providers. Seeking pandemic relief for providers.",
    foreign_entity_issues...46 = "", id...47 = 93368L, first_name...48 = "BENJAMIN",
    last_name...49 = "WALLNER", new...50 = FALSE, id...51 = 53293L,
    prefix...52 = "mr", prefix_display...53 = "MR.", first_name...54 = "BENJAMIN",
    middle_name...55 = "J", last_name...56.1 = "WALLNER", new...57.1 = FALSE,
    id...58.1 = 136L, name...59 = "Centers For Medicare and Medicaid Services (CMS)",
    id...60 = 2L, name...61 = "HOUSE OF REPRESENTATIVES", id...62 = 1L,
    name...63 = "SENATE", general_issue_code...1.2 = "DEF", general_issue_code_display...2.2 = "Defense",
    description...3.2 = "telemedicine", foreign_entity_issues...4.2 = "",
    id...5.2 = 45748L, first_name...6.2 = "OLIVER", last_name...7.2 = "MEISSNER",
    new...8.2 = FALSE, id...9.2 = 75684L, first_name...10.1 = "CHARLES",
    last_name...11.1 = "PROSCH", new...12 = FALSE, id...13 = 93367L,
    first_name...14 = "MICHAEL", last_name...15 = "TOROUNIAN",
    new...16 = FALSE, id...17 = 80766L, first_name...18 = "BRANDON",
    last_name...19 = "KIRBY", new...20 = TRUE, id...21 = 75303L,
    first_name...22 = "MICHAEL", middle_name...23 = "WILLIAM",
    last_name...24 = "TOROUNIAN", new...25 = FALSE, id...26.1 = 134L,
    name...27 = "Centers For Disease Control & Prevention (CDC)",
    id...28.1 = 25L, name...29 = "Defense, Dept of (DOD)", id...30.1 = 34L,
    name...31 = "Health & Human Services, Dept of (HHS)", id...32.1 = 2L,
    name...33 = "HOUSE OF REPRESENTATIVES", id...34 = 1L, name...35 = "SENATE",
    id...36.1 = 39L, name...37 = "State, Dept of (DOS)", id...38 = 12L,
    name...39 = "White House Office"), row.names = 1L, class = "data.frame")
```
<p>Now you see the columns are repetitive in segments, each segment is basically a person, his first and last name, and his possible title. Then it goes to next person</p>
<p>What I want is to subset them based on such segmentation, so I can then pivot the table and clean this mess up.</p>
```mydata %>%
select(
     starts_with("first_name"),
     starts_with("last_name"),
     starts_with("covered_position"))->cv
```
<p>This was my original attempt, it pulled all the columns matching the first name, and last name, then covered_position. The problem is that it lumps all the first name together, then goes for the last name, then covered_position.</p>
<p>So in this way, I lost the segment, I want to get the 3 columns out in their original order:</p>
```for example:

"first_name...5""lastname...5""covered_position...1",
"first_name...9""lastname...8""covered_position...2"
...
```

Then join the 3 columns together, so I have a string then I can pivot it to long form and clean this up.

Thank you

答:
This is my attempt. However, first it should be noticed that the number of column names matching "^first_name", "^last_name" and "^covered_position" is not equal, possibly due to limitation of sample data:

library(purrr)

list(grep("^first_name",       colnames(mydata)),
     grep("^last_name",        colnames(mydata)),
     grep("^covered_position", colnames(mydata))) |>
purrr::map_dbl(length)

[1] 59 59 10
```
<p>Therefore, by considering only the first 10 matches:</p>
<pre class="lang-r prettyprint-override"><code>purrr::pmap(list(grep("^first_name",       colnames(mydata))[1:10],
                 grep("^last_name",        colnames(mydata))[1:10],
                 grep("^covered_position", colnames(mydata))[1:10]),
            c) |>
    purrr::map(~mydata[,.x]) |>
    purrr::map_dfr(~rename_with(.x, ~gsub("\\..*$", "", .x)))

+    first_name                 last_name
1       JOYCE                    ROGERS
2      THOMAS                 MCDANIELS
3      MEGHAN             CLUNE WOLTMAN
4        JILL                    DOWELL
5       JOYCE                    ROGERS
6      THOMAS                 MCDANIELS
7      MEGHAN                   WOLTMAN
8     ANTHONY                     CURRY
9        JILL DOWELL - EFFECTIVE 2/9/21
10      JOYCE                    ROGERS
                                                                               covered_position
1  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
2  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
3  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
4  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
5  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
6  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
7  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
8  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
9  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
10 Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002

</code>```

Body:
I'm stuck with an attempt to subset columns in order from a very wide formatted dataframe. 1 row, couple thousand columns. column names are repetitive so they are all tagged with "...1/2/3/4/5" when retrieved and readin by R

sample data:

dput(mydata)

structure(list(general_issue_code...1 = "MMM", general_issue_code_display...2 = "Medicare/Medicaid",
    description...3 = "340B Drug Pricing Program; Medicare Shared Savings Program; Medicare Advantage; Alternative Payment Models; Graduate Medical Education;Centers for Medicare and Medicaid Innovation; Stark Law Reform/Modernization; Value-Based Purchasing Payments; Post-Acute and Home HealthCare Payments; Drug Pricing and Medicare Parts B and D; Medicare Regulatory Reform; Medicaid Funding; Health Care Innovation; Telehealth/Digital Health; Surprise\nBilling; Anti-Kickback Statute Reform; CREATES Act; COVID-19; Value in Health Care Act",
    foreign_entity_issues...4 = "", id...5 = 71171L, first_name...6 = "JOYCE",
    last_name...7 = "ROGERS", new...8 = FALSE, id...9 = 79365L,
    first_name...10 = "THOMAS", last_name...11 = "MCDANIELS",
    suffix...12 = "jr", suffix_display...13 = "JR", new...14 = FALSE,
    id...15 = 58395L, first_name...16 = "MEGHAN", last_name...17 = "CLUNE WOLTMAN",
    new...18 = TRUE, id...19 = 89715L, first_name...20 = "JILL",
    last_name...21 = "DOWELL", new...22 = FALSE, id...23 = 93159L,
    first_name...24 = "JOYCE", middle_name...25 = "A", last_name...26 = "ROGERS",
    new...27 = FALSE, id...28 = 93160L, first_name...29 = "THOMAS",
    last_name...30 = "MCDANIELS", new...31 = FALSE, id...32 = 93161L,
    first_name...33 = "MEGHAN", last_name...34 = "WOLTMAN", new...35 = TRUE,
    id...36 = 69176L, first_name...37 = "ANTHONY", last_name...38 = "CURRY",
    new...39 = FALSE, id...40 = 93163L, first_name...41 = "JILL",
    last_name...42 = "DOWELL - EFFECTIVE 2/9/21", new...43 = FALSE,
    id...44 = 34L, name...45 = "Health & Human Services, Dept of (HHS)",
    id...46 = 2L, name...47 = "HOUSE OF REPRESENTATIVES", id...48 = 1L,
    name...49 = "SENATE", general_issue_code...50 = "HCR", general_issue_code_display...51 = "Health Issues",
    description...52 = "340B Drug Pricing Program; Medicare Shared Savings Program; Medicare Advantage; Alternative Payment Models; Graduate Medical Education;Centers for Medicare and Medicaid Innovation; Stark Law Reform/Modernization; Value-Based Purchasing Payments; Post-Acute and Home HealthCare Payments; Drug Pricing and Medicare Parts B and D; Medicare Regulatory Reform; Medicaid Funding; Health Care Innovation; Telehealth/Digital Health; Surprise\nBilling; Anti-Kickback Statute Reform; CREATES Act; COVID-19; Value in Health Care Act",
    foreign_entity_issues...53 = "", id...54 = 71171L, first_name...55 = "JOYCE",
    last_name...56 = "ROGERS", new...57 = FALSE, id...58 = 79365L,
    first_name...59 = "THOMAS", last_name...60 = "MCDANIELS",
    suffix...61 = "jr", suffix_display...62 = "JR", new...63 = FALSE,
    id...64 = 58395L, first_name...65 = "MEGHAN", last_name...66 = "CLUNE WOLTMAN",
    new...67 = TRUE, id...68 = 89715L, first_name...69 = "JILL",
    last_name...70 = "DOWELL", new...71 = FALSE, id...72 = 69176L,
    first_name...73 = "ANTHONY", last_name...74 = "CURRY", new...75 = FALSE,
    id...76 = 93159L, first_name...77 = "JOYCE", middle_name...78 = "A",
    last_name...79 = "ROGERS", new...80 = FALSE, id...81 = 93160L,
    first_name...82 = "THOMAS", last_name...83 = "MCDANIELS",
    new...84 = FALSE, id...85 = 93161L, first_name...86 = "MEGHAN",
    last_name...87 = "WOLTMAN", new...88 = TRUE, id...89 = 93163L,
    first_name...90 = "JILL", last_name...91 = "DOWELL - EFFECTIVE 2/9/21",
    new...92 = FALSE, id...93 = 34L, name...94 = "Health & Human Services, Dept of (HHS)",
    id...95 = 2L, name...96 = "HOUSE OF REPRESENTATIVES", id...97 = 1L,
    name...98 = "SENATE", general_issue_code...1.1 = "VET", general_issue_code_display...2.1 = "Veterans",
    description...3.1 = "Implementation of MISSION Act (PL 115-182) and the problems with same as experienced by podiatric physicians and surgeons.",
    foreign_entity_issues...4.1 = "", id...5.1 = 93368L, first_name...6.1 = "BENJAMIN",
    last_name...7.1 = "WALLNER", new...8.1 = FALSE, id...9.1 = 53293L,
    prefix...10 = "mr", prefix_display...11 = "MR.", first_name...12 = "BENJAMIN",
    middle_name...13 = "J", last_name...14 = "WALLNER", new...15 = FALSE,
    id...16 = 136L, name...17 = "Centers For Medicare and Medicaid Services (CMS)",
    id...18 = 2L, name...19 = "HOUSE OF REPRESENTATIVES", id...20 = 1L,
    name...21 = "SENATE", general_issue_code...22 = "EDU", general_issue_code_display...23 = "Education",
    description...24 = "Medical student loan assistance; graduate medical education; higher education act reauthorization; student loan reform; student loan forgiveness for providers during public health emergency.",
    foreign_entity_issues...25 = "", id...26 = 93368L, first_name...27 = "BENJAMIN",
    last_name...28 = "WALLNER", new...29 = FALSE, id...30 = 53293L,
    prefix...31 = "mr", prefix_display...32 = "MR.", first_name...33.1 = "BENJAMIN",
    middle_name...34 = "J", last_name...35 = "WALLNER", new...36 = FALSE,
    id...37 = 136L, name...38 = "Centers For Medicare and Medicaid Services (CMS)",
    id...39 = 2L, name...40 = "HOUSE OF REPRESENTATIVES", id...41 = 1L,
    name...42 = "SENATE", general_issue_code...43 = "HCR", general_issue_code_display...44 = "Health Issues",
    description...45 = "Medicaid access to podiatry and program integrity; Medicare therapeutic shoe program for patients with diabetes; MACRA/MIPS implementation and Physician Fee Schedule proposed updates as pertains to physicians and providers. Seeking pandemic relief for providers.",
    foreign_entity_issues...46 = "", id...47 = 93368L, first_name...48 = "BENJAMIN",
    last_name...49 = "WALLNER", new...50 = FALSE, id...51 = 53293L,
    prefix...52 = "mr", prefix_display...53 = "MR.", first_name...54 = "BENJAMIN",
    middle_name...55 = "J", last_name...56.1 = "WALLNER", new...57.1 = FALSE,
    id...58.1 = 136L, name...59 = "Centers For Medicare and Medicaid Services (CMS)",
    id...60 = 2L, name...61 = "HOUSE OF REPRESENTATIVES", id...62 = 1L,
    name...63 = "SENATE", general_issue_code...1.2 = "DEF", general_issue_code_display...2.2 = "Defense",
    description...3.2 = "telemedicine", foreign_entity_issues...4.2 = "",
    id...5.2 = 45748L, first_name...6.2 = "OLIVER", last_name...7.2 = "MEISSNER",
    new...8.2 = FALSE, id...9.2 = 75684L, first_name...10.1 = "CHARLES",
    last_name...11.1 = "PROSCH", new...12 = FALSE, id...13 = 93367L,
    first_name...14 = "MICHAEL", last_name...15 = "TOROUNIAN",
    new...16 = FALSE, id...17 = 80766L, first_name...18 = "BRANDON",
    last_name...19 = "KIRBY", new...20 = TRUE, id...21 = 75303L,
    first_name...22 = "MICHAEL", middle_name...23 = "WILLIAM",
    last_name...24 = "TOROUNIAN", new...25 = FALSE, id...26.1 = 134L,
    name...27 = "Centers For Disease Control & Prevention (CDC)",
    id...28.1 = 25L, name...29 = "Defense, Dept of (DOD)", id...30.1 = 34L,
    name...31 = "Health & Human Services, Dept of (HHS)", id...32.1 = 2L,
    name...33 = "HOUSE OF REPRESENTATIVES", id...34 = 1L, name...35 = "SENATE",
    id...36.1 = 39L, name...37 = "State, Dept of (DOS)", id...38 = 12L,
    name...39 = "White House Office", general_issue_code...40 = "MMM",
    general_issue_code_display...41 = "Medicare/Medicaid", description...42 = "telemedcine",
    foreign_entity_issues...43 = "", id...44.1 = 93367L, first_name...45 = "MICHAEL",
    last_name...46 = "TOROUNIAN", new...47 = FALSE, id...48.1 = 45748L,
    first_name...49 = "OLIVER", last_name...50 = "MEISSNER",
    new...51 = FALSE, id...52 = 75303L, first_name...53 = "MICHAEL",
    middle_name...54 = "WILLIAM", last_name...55 = "TOROUNIAN",
    new...56 = FALSE, id...57 = 75684L, first_name...58 = "CHARLES",
    last_name...59 = "PROSCH", new...60 = FALSE, id...61 = 80766L,
    first_name...62 = "BRANDON", last_name...63 = "KIRBY", new...64 = TRUE,
    id...65 = 134L, name...66 = "Centers For Disease Control & Prevention (CDC)",
    id...67 = 25L, name...68 = "Defense, Dept of (DOD)", id...69 = 34L,
    name...70 = "Health & Human Services, Dept of (HHS)", id...71 = 2L,
    name...72 = "HOUSE OF REPRESENTATIVES", id...73 = 1L, name...74 = "SENATE",
    id...75 = 39L, name...76 = "State, Dept of (DOS)", id...77 = 12L,
    name...78 = "White House Office", general_issue_code...1.3 = "HCR",
    general_issue_code_display...2.3 = "Health Issues", description...3.3 = "H.R. 1439 The Expanded Genetic Screening Act of 2021: \"To amend title XIX of the Social Security Act to provide for coverage under the Medicaid program of non-invasive prenatal genetic screening\"",
    foreign_entity_issues...4.3 = "", id...5.3 = 45748L, first_name...6.3 = "OLIVER",
    last_name...7.3 = "MEISSNER", new...8.3 = FALSE, id...9.3 = 75684L,
    first_name...10.2 = "CHARLES", last_name...11.2 = "PROSCH",
    new...12.1 = FALSE, id...13.1 = 80766L, first_name...14.1 = "BRANDON",
    last_name...15.1 = "KIRBY", new...16.1 = TRUE, id...17.1 = 93404L,
    first_name...18.1 = "MICHAEL", last_name...19.1 = "TOROUNIAN",
    new...20.1 = FALSE, id...21.1 = 75303L, first_name...22.1 = "MICHAEL",
    middle_name...23.1 = "WILLIAM", last_name...24.1 = "TOROUNIAN",
    new...25.1 = FALSE, id...26.2 = 34L, name...27.1 = "Health & Human Services, Dept of (HHS)",
    id...28.2 = 2L, name...29.1 = "HOUSE OF REPRESENTATIVES",
    id...30.2 = 1L, name...31.1 = "SENATE", general_issue_code...32 = "MMM",
    general_issue_code_display...33 = "Medicare/Medicaid", description...34 = "H.R. 1439 The Expanded Genetic Screening Act of 2021: \"To amend title XIX of the Social Security Act to provide for coverage under the Medicaid program of non-invasive prenatal genetic screening\"",
    foreign_entity_issues...35 = "", id...36.2 = 45748L, first_name...37.1 = "OLIVER",
    last_name...38.1 = "MEISSNER", new...39.1 = FALSE, id...40.1 = 75684L,
    first_name...41.1 = "CHARLES", last_name...42.1 = "PROSCH",
    new...43.1 = FALSE, id...44.2 = 80766L, first_name...45.1 = "BRANDON",
    last_name...46.1 = "KIRBY", new...47.1 = FALSE, id...48.2 = 93404L,
    first_name...49.1 = "MICHAEL", last_name...50.1 = "TOROUNIAN",
    new...51.1 = FALSE, id...52.1 = 75303L, first_name...53.1 = "MICHAEL",
    middle_name...54.1 = "WILLIAM", last_name...55.1 = "TOROUNIAN",
    new...56.1 = FALSE, id...57.1 = 34L, name...58 = "Health & Human Services, Dept of (HHS)",
    id...59 = 2L, name...60 = "HOUSE OF REPRESENTATIVES", id...61.1 = 1L,
    name...62 = "SENATE", general_issue_code = "VET", general_issue_code_display = "Veterans",
    description = "Veteran Healthcare, Veteran Benefits, Military Quality of Life Programs.",
    foreign_entity_issues = "", id...5.4 = 73532L, first_name...6.4 = "PAT",
    last_name...7.4 = "MURRAY", new...8.4 = FALSE, id...9.4 = 87133L,
    first_name...10.3 = "PATRICK", last_name...11.3 = "MURRAY",
    new...12.2 = FALSE, id...13.2 = 25L, name...14 = "Defense, Dept of (DOD)",
    id...15.1 = 2L, name...16 = "HOUSE OF REPRESENTATIVES", id...17.2 = 38L,
    name...18 = "Labor, Dept of (DOL)", id...19.1 = 1L, name...20 = "SENATE",
    id...21.2 = 90L, name...22 = "Small Business Administration (SBA)",
    id...23.1 = 42L, name...24 = "Veterans Affairs, Dept of (VA)",
    id...25 = 170L, name...26 = "Veterans Employment & Training Service",
    general_issue_code.1 = "TEC", general_issue_code_display.1 = "Telecommunications",
    description.1 = "Issues include the USA Telecommunications Act and overall spectrum and technology policy, with a focus on 5G.",
    foreign_entity_issues.1 = "", id...5.5 = 93561L, first_name...6.5 = "DAVID",
    last_name...7.5 = "MURRAY", new...8.5 = FALSE, id...9.5 = 79245L,
    first_name...10.4 = "DAVID", middle_name = "THOMAS", last_name...12 = "MURRAY",
    new...13 = FALSE, id...14 = 2L, name...15 = "HOUSE OF REPRESENTATIVES",
    id...16.1 = 1L, name...17.1 = "SENATE", general_issue_code.2 = "TRA",
    general_issue_code_display.2 = "Transportation", description.2 = "Agricultural and transportation issues",
    foreign_entity_issues.2 = "", id...5.6 = 64951L, first_name = "BRITTON",
    last_name = "CLARKE", covered_position = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new = FALSE, id...10 = 23L, name...11 = "Agriculture, Dept of (USDA)",
    id...12 = 2L, name...13 = "HOUSE OF REPRESENTATIVES", id...14.1 = 1L,
    name...15.1 = "SENATE", general_issue_code.3 = "TRA", general_issue_code_display.3 = "Transportation",
    description.3 = "Transportation issues", foreign_entity_issues.3 = "",
    id...5.7 = 64951L, first_name.1 = "BRITTON", last_name.1 = "CLARKE",
    covered_position.1 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new.1 = FALSE, id...10.1 = 201L, name...11.1 = "Homeland Security, Dept of (DHS)",
    id...12.1 = 2L, name...13.1 = "HOUSE OF REPRESENTATIVES",
    id...14.2 = 1L, name...15.2 = "SENATE", general_issue_code.4 = "TRA",
    general_issue_code_display.4 = "Transportation", description.4 = "Transportation issues",
    foreign_entity_issues.4 = "", id...5.8 = 64951L, first_name.2 = "BRITTON",
    last_name.2 = "CLARKE", covered_position.2 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new.2 = FALSE, id...10.2 = 2L, name...11.2 = "HOUSE OF REPRESENTATIVES",
    id...12.2 = 1L, name...13.2 = "SENATE", general_issue_code...1.4 = "TRD",
    general_issue_code_display...2.4 = "Trade (domestic/foreign)",
    description...3.4 = "Trade, border relations, port operations",
    foreign_entity_issues...4.4 = "", id...5.9 = 64951L, first_name...6.6 = "BRITTON",
    last_name...7.6 = "CLARKE", covered_position.3 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new...9 = FALSE, id...10.3 = 24L, name...11.3 = "Commerce, Dept of (DOC)",
    id...12.3 = 2L, name...13.3 = "HOUSE OF REPRESENTATIVES",
    id...14.3 = 1L, name...15.3 = "SENATE", id...16.2 = 39L,
    name...17.2 = "State, Dept of (DOS)", general_issue_code...18 = "TRA",
    general_issue_code_display...19 = "Transportation", description...20 = "Trade, border travel, ports of entry",
    foreign_entity_issues...21 = "", id...22 = 64951L, first_name...23 = "BRITTON",
    last_name...24.2 = "CLARKE", new...25.2 = TRUE, id...26.3 = 24L,
    name...27.2 = "Commerce, Dept of (DOC)", id...28.3 = 2L,
    name...29.2 = "HOUSE OF REPRESENTATIVES", id...30.3 = 1L,
    name...31.2 = "SENATE", id...32.2 = 39L, name...33.1 = "State, Dept of (DOS)",
    general_issue_code...1.5 = "TRD", general_issue_code_display...2.5 = "Trade (domestic/foreign)",
    description...3.5 = "International trade", foreign_entity_issues...4.5 = "",
    id...5.10 = 64951L, first_name...6.7 = "BRITTON", last_name...7.7 = "CLARKE",
    covered_position...8 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new...9.1 = FALSE, id...10.4 = 2L, name...11.4 = "HOUSE OF REPRESENTATIVES",
    id...12.4 = 1L, name...13.4 = "SENATE", general_issue_code...14 = "TRA",
    general_issue_code_display...15 = "Transportation", description...16 = "Transportation issues; border travel",
    foreign_entity_issues...17 = "", id...18.1 = 64951L, first_name...19 = "BRITTON",
    last_name...20 = "CLARKE", covered_position...21 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new...22.1 = FALSE, id...23.2 = 2L, name...24.1 = "HOUSE OF REPRESENTATIVES",
    id...25.1 = 1L, name...26.1 = "SENATE", general_issue_code.5 = "TRA",
    general_issue_code_display.5 = "Transportation", description.5 = "Speed limiters",
    foreign_entity_issues.5 = "", id...5.11 = 64951L, first_name.3 = "BRITTON",
    last_name.3 = "CLARKE", covered_position.4 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new.3 = FALSE, id...10.5 = 2L, name...11.5 = "HOUSE OF REPRESENTATIVES",
    id...12.5 = 1L, name...13.5 = "SENATE", general_issue_code.6 = "TRA",
    general_issue_code_display.6 = "Transportation", description.6 = "Transportation issues",
    foreign_entity_issues.6 = "", id...5.12 = 64951L, first_name.4 = "BRITTON",
    last_name.4 = "CLARKE", covered_position.5 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new.4 = FALSE, id...10.6 = 2L, name...11.6 = "HOUSE OF REPRESENTATIVES",
    id...12.6 = 1L, name...13.6 = "SENATE", general_issue_code.7 = "TRA",
    general_issue_code_display.7 = "Transportation", description.7 = "Transportation issues",
    foreign_entity_issues.7 = "", id...5.13 = 64951L, first_name.5 = "BRITTON",
    last_name.5 = "CLARKE", covered_position.6 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new.5 = FALSE, id...10.7 = 2L, name...11.7 = "HOUSE OF REPRESENTATIVES",
    id...12.7 = 1L, name...13.7 = "SENATE", id...14.4 = 40L,
    name...15.4 = "Transportation, Dept of (DOT)", general_issue_code.8 = "TRA",
    general_issue_code_display.8 = "Transportation", description.8 = "Transportation technologies",
    foreign_entity_issues.8 = "", id...5.14 = 64951L, first_name.6 = "BRITTON",
    last_name.6 = "CLARKE", covered_position.7 = "Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002",
    new.6 = FALSE, id...10.8 = 2L, name...11.8 = "HOUSE OF REPRESENTATIVES",
    id...12.8 = 1L, name...13.8 = "SENATE"), row.names = 1L, class = "data.frame")
> dput(q<-q[1,1:200])
structure(list(general_issue_code...1 = "MMM", general_issue_code_display...2 = "Medicare/Medicaid",
    description...3 = "340B Drug Pricing Program; Medicare Shared Savings Program; Medicare Advantage; Alternative Payment Models; Graduate Medical Education;Centers for Medicare and Medicaid Innovation; Stark Law Reform/Modernization; Value-Based Purchasing Payments; Post-Acute and Home HealthCare Payments; Drug Pricing and Medicare Parts B and D; Medicare Regulatory Reform; Medicaid Funding; Health Care Innovation; Telehealth/Digital Health; Surprise\nBilling; Anti-Kickback Statute Reform; CREATES Act; COVID-19; Value in Health Care Act",
    foreign_entity_issues...4 = "", id...5 = 71171L, first_name...6 = "JOYCE",
    last_name...7 = "ROGERS", new...8 = FALSE, id...9 = 79365L,
    first_name...10 = "THOMAS", last_name...11 = "MCDANIELS",
    suffix...12 = "jr", suffix_display...13 = "JR", new...14 = FALSE,
    id...15 = 58395L, first_name...16 = "MEGHAN", last_name...17 = "CLUNE WOLTMAN",
    new...18 = TRUE, id...19 = 89715L, first_name...20 = "JILL",
    last_name...21 = "DOWELL", new...22 = FALSE, id...23 = 93159L,
    first_name...24 = "JOYCE", middle_name...25 = "A", last_name...26 = "ROGERS",
    new...27 = FALSE, id...28 = 93160L, first_name...29 = "THOMAS",
    last_name...30 = "MCDANIELS", new...31 = FALSE, id...32 = 93161L,
    first_name...33 = "MEGHAN", last_name...34 = "WOLTMAN", new...35 = TRUE,
    id...36 = 69176L, first_name...37 = "ANTHONY", last_name...38 = "CURRY",
    new...39 = FALSE, id...40 = 93163L, first_name...41 = "JILL",
    last_name...42 = "DOWELL - EFFECTIVE 2/9/21", new...43 = FALSE,
    id...44 = 34L, name...45 = "Health & Human Services, Dept of (HHS)",
    id...46 = 2L, name...47 = "HOUSE OF REPRESENTATIVES", id...48 = 1L,
    name...49 = "SENATE", general_issue_code...50 = "HCR", general_issue_code_display...51 = "Health Issues",
    description...52 = "340B Drug Pricing Program; Medicare Shared Savings Program; Medicare Advantage; Alternative Payment Models; Graduate Medical Education;Centers for Medicare and Medicaid Innovation; Stark Law Reform/Modernization; Value-Based Purchasing Payments; Post-Acute and Home HealthCare Payments; Drug Pricing and Medicare Parts B and D; Medicare Regulatory Reform; Medicaid Funding; Health Care Innovation; Telehealth/Digital Health; Surprise\nBilling; Anti-Kickback Statute Reform; CREATES Act; COVID-19; Value in Health Care Act",
    foreign_entity_issues...53 = "", id...54 = 71171L, first_name...55 = "JOYCE",
    last_name...56 = "ROGERS", new...57 = FALSE, id...58 = 79365L,
    first_name...59 = "THOMAS", last_name...60 = "MCDANIELS",
    suffix...61 = "jr", suffix_display...62 = "JR", new...63 = FALSE,
    id...64 = 58395L, first_name...65 = "MEGHAN", last_name...66 = "CLUNE WOLTMAN",
    new...67 = TRUE, id...68 = 89715L, first_name...69 = "JILL",
    last_name...70 = "DOWELL", new...71 = FALSE, id...72 = 69176L,
    first_name...73 = "ANTHONY", last_name...74 = "CURRY", new...75 = FALSE,
    id...76 = 93159L, first_name...77 = "JOYCE", middle_name...78 = "A",
    last_name...79 = "ROGERS", new...80 = FALSE, id...81 = 93160L,
    first_name...82 = "THOMAS", last_name...83 = "MCDANIELS",
    new...84 = FALSE, id...85 = 93161L, first_name...86 = "MEGHAN",
    last_name...87 = "WOLTMAN", new...88 = TRUE, id...89 = 93163L,
    first_name...90 = "JILL", last_name...91 = "DOWELL - EFFECTIVE 2/9/21",
    new...92 = FALSE, id...93 = 34L, name...94 = "Health & Human Services, Dept of (HHS)",
    id...95 = 2L, name...96 = "HOUSE OF REPRESENTATIVES", id...97 = 1L,
    name...98 = "SENATE", general_issue_code...1.1 = "VET", general_issue_code_display...2.1 = "Veterans",
    description...3.1 = "Implementation of MISSION Act (PL 115-182) and the problems with same as experienced by podiatric physicians and surgeons.",
    foreign_entity_issues...4.1 = "", id...5.1 = 93368L, first_name...6.1 = "BENJAMIN",
    last_name...7.1 = "WALLNER", new...8.1 = FALSE, id...9.1 = 53293L,
    prefix...10 = "mr", prefix_display...11 = "MR.", first_name...12 = "BENJAMIN",
    middle_name...13 = "J", last_name...14 = "WALLNER", new...15 = FALSE,
    id...16 = 136L, name...17 = "Centers For Medicare and Medicaid Services (CMS)",
    id...18 = 2L, name...19 = "HOUSE OF REPRESENTATIVES", id...20 = 1L,
    name...21 = "SENATE", general_issue_code...22 = "EDU", general_issue_code_display...23 = "Education",
    description...24 = "Medical student loan assistance; graduate medical education; higher education act reauthorization; student loan reform; student loan forgiveness for providers during public health emergency.",
    foreign_entity_issues...25 = "", id...26 = 93368L, first_name...27 = "BENJAMIN",
    last_name...28 = "WALLNER", new...29 = FALSE, id...30 = 53293L,
    prefix...31 = "mr", prefix_display...32 = "MR.", first_name...33.1 = "BENJAMIN",
    middle_name...34 = "J", last_name...35 = "WALLNER", new...36 = FALSE,
    id...37 = 136L, name...38 = "Centers For Medicare and Medicaid Services (CMS)",
    id...39 = 2L, name...40 = "HOUSE OF REPRESENTATIVES", id...41 = 1L,
    name...42 = "SENATE", general_issue_code...43 = "HCR", general_issue_code_display...44 = "Health Issues",
    description...45 = "Medicaid access to podiatry and program integrity; Medicare therapeutic shoe program for patients with diabetes; MACRA/MIPS implementation and Physician Fee Schedule proposed updates as pertains to physicians and providers. Seeking pandemic relief for providers.",
    foreign_entity_issues...46 = "", id...47 = 93368L, first_name...48 = "BENJAMIN",
    last_name...49 = "WALLNER", new...50 = FALSE, id...51 = 53293L,
    prefix...52 = "mr", prefix_display...53 = "MR.", first_name...54 = "BENJAMIN",
    middle_name...55 = "J", last_name...56.1 = "WALLNER", new...57.1 = FALSE,
    id...58.1 = 136L, name...59 = "Centers For Medicare and Medicaid Services (CMS)",
    id...60 = 2L, name...61 = "HOUSE OF REPRESENTATIVES", id...62 = 1L,
    name...63 = "SENATE", general_issue_code...1.2 = "DEF", general_issue_code_display...2.2 = "Defense",
    description...3.2 = "telemedicine", foreign_entity_issues...4.2 = "",
    id...5.2 = 45748L, first_name...6.2 = "OLIVER", last_name...7.2 = "MEISSNER",
    new...8.2 = FALSE, id...9.2 = 75684L, first_name...10.1 = "CHARLES",
    last_name...11.1 = "PROSCH", new...12 = FALSE, id...13 = 93367L,
    first_name...14 = "MICHAEL", last_name...15 = "TOROUNIAN",
    new...16 = FALSE, id...17 = 80766L, first_name...18 = "BRANDON",
    last_name...19 = "KIRBY", new...20 = TRUE, id...21 = 75303L,
    first_name...22 = "MICHAEL", middle_name...23 = "WILLIAM",
    last_name...24 = "TOROUNIAN", new...25 = FALSE, id...26.1 = 134L,
    name...27 = "Centers For Disease Control & Prevention (CDC)",
    id...28.1 = 25L, name...29 = "Defense, Dept of (DOD)", id...30.1 = 34L,
    name...31 = "Health & Human Services, Dept of (HHS)", id...32.1 = 2L,
    name...33 = "HOUSE OF REPRESENTATIVES", id...34 = 1L, name...35 = "SENATE",
    id...36.1 = 39L, name...37 = "State, Dept of (DOS)", id...38 = 12L,
    name...39 = "White House Office"), row.names = 1L, class = "data.frame")

Now you see the columns are repetitive in segments, each segment is basically a person, his first and last name, and his possible title. Then it goes to next person

What I want is to subset them based on such segmentation, so I can then pivot the table and clean this mess up.

mydata %>%
select(
     starts_with("first_name"),
     starts_with("last_name"),
     starts_with("covered_position"))->cv

This was my original attempt, it pulled all the columns matching the first name, and last name, then covered_position. The problem is that it lumps all the first name together, then goes for the last name, then covered_position.

So in this way, I lost the segment, I want to get the 3 columns out in their original order:

for example:

"first_name...5""lastname...5""covered_position...1",
"first_name...9""lastname...8""covered_position...2"
...

Then join the 3 columns together, so I have a string then I can pivot it to long form and clean this up.

Thank you

Body:
This is my attempt. However, first it should be noticed that the number of column names matching "^first_name", "^last_name" and "^covered_position" is not equal, possibly due to limitation of sample data:

library(purrr)

list(grep("^first_name",       colnames(mydata)),
     grep("^last_name",        colnames(mydata)),
     grep("^covered_position", colnames(mydata))) |>
purrr::map_dbl(length)

[1] 59 59 10

Therefore, by considering only the first 10 matches:

purrr::pmap(list(grep("^first_name",       colnames(mydata))[1:10],
                 grep("^last_name",        colnames(mydata))[1:10],
                 grep("^covered_position", colnames(mydata))[1:10]),
            c) |>
    purrr::map(~mydata[,.x]) |>
    purrr::map_dfr(~rename_with(.x, ~gsub("\\..*$", "", .x)))

+    first_name                 last_name
1       JOYCE                    ROGERS
2      THOMAS                 MCDANIELS
3      MEGHAN             CLUNE WOLTMAN
4        JILL                    DOWELL
5       JOYCE                    ROGERS
6      THOMAS                 MCDANIELS
7      MEGHAN                   WOLTMAN
8     ANTHONY                     CURRY
9        JILL DOWELL - EFFECTIVE 2/9/21
10      JOYCE                    ROGERS
                                                                               covered_position
1  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
2  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
3  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
4  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
5  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
6  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
7  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
8  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
9  Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002
10 Deputy Chief of Staff and press secretary for Congressman Henry Brown (SC-1) from 2001- 2002


来源: stackexchange

问:
golang: HTTPS request yields "crypto/rsa: verification error"
I'm having trouble accessing https urls with the net/http package.

Here's a working example of the error:

```<code>package main

import (
  "fmt"
  "net/http"
)

func main() {
  _, err := http.Get("https://api.bitfinex.com/v1/book/ltcbtc")
  if err != nil {
    fmt.Println(err)
  }
}
</code>```

This program yields the error,

```<code>Get https://api.bitfinex.com/v1/book/ltcbtc: crypto/rsa: verification error
</code>```

The docs for net/http clearly state,

Get, Head, Post, and PostForm make HTTP (or HTTPS) requests

but I can't find any documentation on this error.

The source for crypto/rsa only has this to say about the error:

```<code>// ErrVerification represents a failure to verify a signature.
// It is deliberately vague to avoid adaptive attacks.
var ErrVerification = errors.New("crypto/rsa: verification error")
</code>```

So I'm not sure where to go from here. I'm pretty sure it's not their fault because Chrome is happy with their https certificate.

I've also tried using a Client with a tls.Config that has InsecureSkipVerify set to true, but that didn't seem to shut this error up.

答: In my case, it happened because I set the wrong public key for verifying the token. When I changed it to the correct one, it worked like a charm.</p>

ContentLicense: CC BY-SA 3.0

Body:
I'm having trouble accessing https urls with the net/http package.

Here's a working example of the error:

package main

import (
  "fmt"
  "net/http"
)

func main() {
  _, err := http.Get("https://api.bitfinex.com/v1/book/ltcbtc")
  if err != nil {
    fmt.Println(err)
  }
}

This program yields the error,

Get https://api.bitfinex.com/v1/book/ltcbtc: crypto/rsa: verification error

The docs for net/http clearly state,

Get, Head, Post, and PostForm make HTTP (or HTTPS) requests

but I can't find any documentation on this error.

The source for crypto/rsa only has this to say about the error:

// ErrVerification represents a failure to verify a signature.
// It is deliberately vague to avoid adaptive attacks.
var ErrVerification = errors.New("crypto/rsa: verification error")

So I'm not sure where to go from here. I'm pretty sure it's not their fault because Chrome is happy with their https certificate.

I've also tried using a Client with a tls.Config that has InsecureSkipVerify set to true, but that didn't seem to shut this error up.

ContentLicense: CC BY-SA 4.0


问:
google cloud function Compute engine python api not shutting down instance on call to stop as expected
I am using a google cloud function with python 3.9
My intention is to trigger this cloud function from an http trigger to stop a compute engine instance.  The code for my cloud function is as below (entry point stop_server )

```<code># python 3.9 code for cloud function body
from googleapiclient import discovery
def stop_server (request):
"""
Responds to HTTP Get request stops server specified inget param instancename=<name>
Returns status
"""
service = discovery.build('compute', 'v1')
# Project ID for this request.
project = 'my-gcp-project'
# The name of the zone for this request.
zone = 'us-east1-b'
# determine instance to stop from http params
if request.args and 'instancename' in request.args:
   instance = request.args.get('instancename')
   status = service.instances().stop(project=project, zone=zone, instance=instance)
   return f'instance: {instance} - stopped  --> status = {status}'
else: # no instance specified
   return f'specify instance in get param ?instancename="name"'
</code>```

The "requirements.txt" is as follows

```<code># Function dependencies
# package>=version
google-api-core
google-api-python-client
</code>```

This code deploys fine in gcp and I can generate a "trigger url" as follows

https://us-east1-myproject.cloudfunctions.net/stop-specified-vm?instancename=name_of_instance

When I run the code through trigger URL - the code executes fine and returns the status message in http response as follows

```<code>instance: my-gcp-instance - stopped --> status =
</code>```

However the specified instance does not stop as expected

So in order to debug I need to find the documentation for the stop instances.stop api -                                            I examined type of "service object" in runtime by printing its type as follows

```<code>enter code here
 service = discovery.build('compute', 'v1')
 stype=(type(service))
 print(f'type of service = {stype}')
</code>```

that shows in logs that service object is of type "googleapiclient.discovery.Resource'
I suppose this is a base class object that holds an object of  appropriate specific type based on what service argument you passed to build.
So in my case case since  the service is  compute engine - what is this bound to when I call
service = discovery.build('compute', 'v1')

Where can I find documentation for that api

Any other debugging tips ?

See response from John Hanley below - As he rightly pointed out I had missed calling execute() on the (request) object returned by call to service.instances().stop

So basically - I needed to understand the paradigm used here. The service.instances().stop returns an object that is a client for requested restful service (stop in this case) . And then I have to call "execute" to actually invoke that service :-)

posting full working code below again

```<code># python 3.9 code for cloud function body
from googleapiclient import discovery
def stop_server (request):
"""
Responds to HTTP Get request stops server specified inget param instancename=<name>
Returns status
"""
service = discovery.build('compute', 'v1')
# Project ID for this request.
project = 'my-gcp-project'
# The name of the zone for this request.
zone = 'us-east1-b'
# determine instance to stop from http params
if request.args and 'instancename' in request.args:
   instance = request.args.get('instancename')
   request= service.instances().stop(project=project, zone=zone, instance=instance)
   response = request.execute() # returning full dictionary object for caller to examine
   rstr=str(response)
   return f'instance: {instance} - stop requested  --> response = {rstr}'
else: # no instance specified
   return f'specify instance in get param ?instancename="name"'
</code>```

答:
The API stop() returns an Operation resource and not a string. You must poll the operation resource to get the status of the stop operation. This includes success and failure.

Note: Your code is not calling execute() after setting up the request.

```<code>request = service.instances().stop(project=project, zone=zone, instance=instance)
response = request.execute()
</code>```

Since you are writing new code, I recommend that you do not use your current Python library.

Client libraries explained

Instead switch to the current library that is still being developed.

Python Client for Compute Engine

Example for starting and stopping an instance

Body:
I am using a google cloud function with python 3.9
My intention is to trigger this cloud function from an http trigger to stop a compute engine instance.  The code for my cloud function is as below (entry point stop_server )

# python 3.9 code for cloud function body
from googleapiclient import discovery
def stop_server (request):
"""
Responds to HTTP Get request stops server specified inget param instancename=<name>
Returns status
"""
service = discovery.build('compute', 'v1')
# Project ID for this request.
project = 'my-gcp-project'
# The name of the zone for this request.
zone = 'us-east1-b'
# determine instance to stop from http params
if request.args and 'instancename' in request.args:
   instance = request.args.get('instancename')
   status = service.instances().stop(project=project, zone=zone, instance=instance)
   return f'instance: {instance} - stopped  --> status = {status}'
else: # no instance specified
   return f'specify instance in get param ?instancename="name"'

The "requirements.txt" is as follows

# Function dependencies
# package>=version
google-api-core
google-api-python-client

This code deploys fine in gcp and I can generate a "trigger url" as follows

https://us-east1-myproject.cloudfunctions.net/stop-specified-vm?instancename=name_of_instance

When I run the code through trigger URL - the code executes fine and returns the status message in http response as follows

instance: my-gcp-instance - stopped --> status =

However the specified instance does not stop as expected

So in order to debug I need to find the documentation for the stop instances.stop api -                                            I examined type of "service object" in runtime by printing its type as follows

enter code here
 service = discovery.build('compute', 'v1')
 stype=(type(service))
 print(f'type of service = {stype}')

that shows in logs that service object is of type "googleapiclient.discovery.Resource'
I suppose this is a base class object that holds an object of  appropriate specific type based on what service argument you passed to build.
So in my case case since  the service is  compute engine - what is this bound to when I call
service = discovery.build('compute', 'v1')

Where can I find documentation for that api

Any other debugging tips ?

See response from John Hanley below - As he rightly pointed out I had missed calling execute() on the (request) object returned by call to service.instances().stop

So basically - I needed to understand the paradigm used here. The service.instances().stop returns an object that is a client for requested restful service (stop in this case) . And then I have to call "execute" to actually invoke that service :-)

posting full working code below again

# python 3.9 code for cloud function body
from googleapiclient import discovery
def stop_server (request):
"""
Responds to HTTP Get request stops server specified inget param instancename=<name>
Returns status
"""
service = discovery.build('compute', 'v1')
# Project ID for this request.
project = 'my-gcp-project'
# The name of the zone for this request.
zone = 'us-east1-b'
# determine instance to stop from http params
if request.args and 'instancename' in request.args:
   instance = request.args.get('instancename')
   request= service.instances().stop(project=project, zone=zone, instance=instance)
   response = request.execute() # returning full dictionary object for caller to examine
   rstr=str(response)
   return f'instance: {instance} - stop requested  --> response = {rstr}'
else: # no instance specified
   return f'specify instance in get param ?instancename="name"'

Body:
The API stop() returns an Operation resource and not a string. You must poll the operation resource to get the status of the stop operation. This includes success and failure.

Note: Your code is not calling execute() after setting up the request.

request = service.instances().stop(project=project, zone=zone, instance=instance)
response = request.execute()

Since you are writing new code, I recommend that you do not use your current Python library.

Client libraries explained

Instead switch to the current library that is still being developed.

Python Client for Compute Engine

Example for starting and stopping an instance


问:
IDbAsyncQueryProvider in EntityFrameworkCore
I'm using XUNIT to test in a dot net core application.

I need to test a service that is internally making an async query on a DbSet in my datacontext.

I've seen here that mocking that DbSet asynchronously is possible.

The problem I'm having is that the IDbAsyncQueryProvider does not seem to be available in EntityframeworkCore, which I'm using.

Am I incorrect here? Has anyone else got this working?

(Been a long day, hopefully I'm just missing something simple)

EDIT

After asking on GitHub, I got point to this class:
https://github.com/aspnet/EntityFramework/blob/dev/src/Microsoft.EntityFrameworkCore/Query/Internal/IAsyncQueryProvider.cs

This is what I've gotten to so far in trying to implement this:

```<code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Query.Internal;

namespace EFCoreTestQueryProvider
{
    internal class TestAsyncQueryProvider<TEntity>: IAsyncQueryProvider
    {
        private readonly IQueryProvider _inner;

        internal TestAsyncQueryProvider(IQueryProvider inner)
        {
            _inner = inner;
        }

        IQueryable CreateQuery(Expression expression)
        {
            return new TestDbAsyncEnumerable<TEntity>(expression);
        }

        IQueryable<TElement> CreateQuery<TElement>(Expression expression)
        {
             return new TestDbAsyncEnumerable<TElement>(expression);
        }

        object Execute(Expression expression)
        {
            return _inner.Execute(expression);
        }

        TResult Execute<TResult>(Expression expression)
        {
            return _inner.Execute<TResult>(expression);
        }

        IAsyncEnumerable<TResult> ExecuteAsync<TResult>(Expression expression)
        {
            return Task.FromResult(Execute<TResult>(expression)).ToAsyncEnumerable();
        }

        Task<TResult> IAsyncQueryProvider.ExecuteAsync<TResult>(Expression expression, CancellationToken cancellationToken)
        {
            return Task.FromResult(Execute<TResult>(expression));
        }
    }

    internal class TestDbAsyncEnumerable<T> : EnumerableQuery<T>, System.Collections.Generic.IAsyncEnumerable<T>, IQueryable<T>
    {
        public TestDbAsyncEnumerable(IEnumerable<T> enumerable)
            : base(enumerable)
        { }

        public TestDbAsyncEnumerable(Expression expression)
            : base(expression)
        { }

        public IAsyncEnumerator<T> GetAsyncEnumerator()
        {
            return new TestDbAsyncEnumerable<T>(this.AsEnumerable()).ToAsyncEnumerable();
        }

        IDbAsyncEnumerator IDbAsyncEnumerable.GetAsyncEnumerator()
        {
            return GetAsyncEnumerator();
        }

        IAsyncEnumerator<T> IAsyncEnumerable<T>.GetEnumerator()
        {
            throw new NotImplementedException();
        }

        IQueryProvider IQueryable.Provider
        {
            get { return new TestAsyncQueryProvider<T>(this); }
        }
    }
}
</code>```

I've now tried to implement this and have run into some more issues, specifically around these two methods:

```<code>public IAsyncEnumerator<T> GetAsyncEnumerator()
{
    return new TestDbAsyncEnumerable<T>(this.AsEnumerable()).ToAsyncEnumerable();
}

IDbAsyncEnumerator IDbAsyncEnumerable.GetAsyncEnumerator()
{
    return GetAsyncEnumerator();
}
</code>```

I'm hoping that somebody could point me in the right direction as to what I'm doing wrong.

答:
See here to mock DbContext with async queryable support: https://stackoverflow.com/a/71076807/4905704

Like this:

    [Fact]
    public void Test()
    {
        var testData = new List<MyEntity>
        {
            new MyEntity() { Id = Guid.NewGuid() },
            new MyEntity() { Id = Guid.NewGuid() },
            new MyEntity() { Id = Guid.NewGuid() },
        };

        var mockDbContext = new MockDbContextAsynced<MyDbContext>();
        mockDbContext.AddDbSetData<MyEntity>(testData.AsQueryable());

        mockDbContext.MyEntities.ToArrayAsync();
        // or
        mockDbContext.MyEntities.SingleAsync();
        // or etc.

        // To inject MyDbContext as type parameter with mocked data
        var mockService = new SomeService(mockDbContext.Object);
    }
```

Body:
I'm using XUNIT to test in a dot net core application.

I need to test a service that is internally making an async query on a DbSet in my datacontext.

I've seen here that mocking that DbSet asynchronously is possible.

The problem I'm having is that the IDbAsyncQueryProvider does not seem to be available in EntityframeworkCore, which I'm using.

Am I incorrect here? Has anyone else got this working?

(Been a long day, hopefully I'm just missing something simple)

EDIT

After asking on GitHub, I got point to this class:
https://github.com/aspnet/EntityFramework/blob/dev/src/Microsoft.EntityFrameworkCore/Query/Internal/IAsyncQueryProvider.cs

This is what I've gotten to so far in trying to implement this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Query.Internal;

namespace EFCoreTestQueryProvider
{
    internal class TestAsyncQueryProvider<TEntity>: IAsyncQueryProvider
    {
        private readonly IQueryProvider _inner;

        internal TestAsyncQueryProvider(IQueryProvider inner)
        {
            _inner = inner;
        }

        IQueryable CreateQuery(Expression expression)
        {
            return new TestDbAsyncEnumerable<TEntity>(expression);
        }

        IQueryable<TElement> CreateQuery<TElement>(Expression expression)
        {
             return new TestDbAsyncEnumerable<TElement>(expression);
        }

        object Execute(Expression expression)
        {
            return _inner.Execute(expression);
        }

        TResult Execute<TResult>(Expression expression)
        {
            return _inner.Execute<TResult>(expression);
        }

        IAsyncEnumerable<TResult> ExecuteAsync<TResult>(Expression expression)
        {
            return Task.FromResult(Execute<TResult>(expression)).ToAsyncEnumerable();
        }

        Task<TResult> IAsyncQueryProvider.ExecuteAsync<TResult>(Expression expression, CancellationToken cancellationToken)
        {
            return Task.FromResult(Execute<TResult>(expression));
        }
    }

    internal class TestDbAsyncEnumerable<T> : EnumerableQuery<T>, System.Collections.Generic.IAsyncEnumerable<T>, IQueryable<T>
    {
        public TestDbAsyncEnumerable(IEnumerable<T> enumerable)
            : base(enumerable)
        { }

        public TestDbAsyncEnumerable(Expression expression)
            : base(expression)
        { }

        public IAsyncEnumerator<T> GetAsyncEnumerator()
        {
            return new TestDbAsyncEnumerable<T>(this.AsEnumerable()).ToAsyncEnumerable();
        }

        IDbAsyncEnumerator IDbAsyncEnumerable.GetAsyncEnumerator()
        {
            return GetAsyncEnumerator();
        }

        IAsyncEnumerator<T> IAsyncEnumerable<T>.GetEnumerator()
        {
            throw new NotImplementedException();
        }

        IQueryProvider IQueryable.Provider
        {
            get { return new TestAsyncQueryProvider<T>(this); }
        }
    }
}

I've now tried to implement this and have run into some more issues, specifically around these two methods:

public IAsyncEnumerator<T> GetAsyncEnumerator()
{
    return new TestDbAsyncEnumerable<T>(this.AsEnumerable()).ToAsyncEnumerable();
}

IDbAsyncEnumerator IDbAsyncEnumerable.GetAsyncEnumerator()
{
    return GetAsyncEnumerator();
}

I'm hoping that somebody could point me in the right direction as to what I'm doing wrong.


问:
bcrypt Error: data and hash arguments required
I am getting a bcrypt error stating that data and hash arguments are required, referencing line #44 in my routes.js file. From what I can tell, I am passing that information: the first parameter to bcrypt.compare is the user entered password, and the second is the hashed password retrieved from the db. What am I doing wrong?

```<code>bcrypt.compare(req.params.password, user.password, function...
</code>```

routes.js

```<code>'use strict'

var express = require('express');
var router = express.Router();
var User = require('../app/models/user');
//password hashing
var bcrypt = require('bcrypt');

var count = 0;

router.use(function(req, res, next) {
    count++;
    console.log('API hit count = %s', count);
    next();
});

// /users post(create new user) get(specific user)
router.route('/users')
    .post(function(req,res) {
        var user = new User();
        user.username = req.body.username;
        user.password = bcrypt.hashSync(req.body.password, 10);

        //save the user and checkfor errors
        user.save(function(err) {
            if (err) {
                res.send(err);
            } else {
                res.json({message: "User created!"});
            }
        });

    })

router.route('/users/:username')
    .get(function(req, res) {
        var query = {
            username: req.params.username,
        };
        User.findOne(query, function(err, user) {
            if (err) {
                res.send(err);
            } else {
                bcrypt.compare(req.params.password, user.password, function(err, res) {
                    if(err) {
                        console.log('Comparison error: ', err);
                    }
                })
                res.json(user);
            }
        });
    })
</code>```

答:
I was having the same error when I was working with node js and mongoose. It was caused by attribute added to password called select: false in user model.

After remove it, it works.

Body:
I am getting a bcrypt error stating that data and hash arguments are required, referencing line #44 in my routes.js file. From what I can tell, I am passing that information: the first parameter to bcrypt.compare is the user entered password, and the second is the hashed password retrieved from the db. What am I doing wrong?

bcrypt.compare(req.params.password, user.password, function...

routes.js

'use strict'

var express = require('express');
var router = express.Router();
var User = require('../app/models/user');
//password hashing
var bcrypt = require('bcrypt');

var count = 0;

router.use(function(req, res, next) {
    count++;
    console.log('API hit count = %s', count);
    next();
});

// /users post(create new user) get(specific user)
router.route('/users')
    .post(function(req,res) {
        var user = new User();
        user.username = req.body.username;
        user.password = bcrypt.hashSync(req.body.password, 10);

        //save the user and checkfor errors
        user.save(function(err) {
            if (err) {
                res.send(err);
            } else {
                res.json({message: "User created!"});
            }
        });

    })

router.route('/users/:username')
    .get(function(req, res) {
        var query = {
            username: req.params.username,
        };
        User.findOne(query, function(err, user) {
            if (err) {
                res.send(err);
            } else {
                bcrypt.compare(req.params.password, user.password, function(err, res) {
                    if(err) {
                        console.log('Comparison error: ', err);
                    }
                })
                res.json(user);
            }
        });
    })


问:
Why is the orientationchange event never getting fired in my JQM app?
I am alerting a message on orientationchange.

```<code>$(window).bind("orientationchange", function(e){

    alert('orientation change');
});
</code>```

Also, if you notice the class names on the body tag, the portrait/landscape class name never changes like it does in the JQM demos -- it just stays at whatever it was when you loaded the page.  Any help debugging this unusual problem is greatly appreciated.

EDIT Sorry i forgot to leave a link to my project :/

http://www.foodtrucksmap.com/m/la

答:
// Get the current page orientation. This method is exposed publicly,
  should it

// be needed, as
  jQuery.event.special.orientationchange.orientation()

http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.js

Try:

```<code>$(window).bind( 'orientationchange', function(e){
    alert(jQuery.event.special.orientationchange.orientation());
});
</code>```

Body:
I am alerting a message on orientationchange.

$(window).bind("orientationchange", function(e){

    alert('orientation change');
});

Also, if you notice the class names on the body tag, the portrait/landscape class name never changes like it does in the JQM demos -- it just stays at whatever it was when you loaded the page.  Any help debugging this unusual problem is greatly appreciated.

EDIT Sorry i forgot to leave a link to my project :/

http://www.foodtrucksmap.com/m/la

Body:
// Get the current page orientation. This method is exposed publicly,
  should it

// be needed, as
  jQuery.event.special.orientationchange.orientation()

http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.js

Try:

$(window).bind( 'orientationchange', function(e){
    alert(jQuery.event.special.orientationchange.orientation());
});


问:
java.sql.SQLSyntaxErrorException for seemingly alright script
I am trying to make a simple login page that uses a MySQL database. I receive the following exception:
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? and password = md5(?)' at line 1

When trying to execute the following script:

```<code>    private static final String FIND_BY_LOGIN_AND_PASSWORD = "select * from user where login = ? and password = md5(?);";
</code>```

This is where the PreparedStatement is created:

```<code>    PreparedStatement preparedStatement = connection.prepareStatement(FIND_BY_LOGIN_AND_PASSWORD);
    for (int i = 1; i <= parameters.length; i++) {
        preparedStatement.setObject(i, parameters[i - 1]);
    }
    return preparedStatement;
</code>```

This is where it's used:

```<code>   ResultSet resultSet = preparedStatement.executeQuery(query);
</code>```

Any help would be appreciated

答:
As commented, you should call PreparedStatement#executeQuery without any argument. No need for you to pass a query to the execute command, as the prepared statement already contains your query.

```<code>ResultSet resultSet = preparedStatement.executeQuery();  // No argument.
</code>```

Body:
I am trying to make a simple login page that uses a MySQL database. I receive the following exception:
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? and password = md5(?)' at line 1

When trying to execute the following script:

    private static final String FIND_BY_LOGIN_AND_PASSWORD = "select * from user where login = ? and password = md5(?);";

This is where the PreparedStatement is created:

    PreparedStatement preparedStatement = connection.prepareStatement(FIND_BY_LOGIN_AND_PASSWORD);
    for (int i = 1; i <= parameters.length; i++) {
        preparedStatement.setObject(i, parameters[i - 1]);
    }
    return preparedStatement;

This is where it's used:

   ResultSet resultSet = preparedStatement.executeQuery(query);

Any help would be appreciated

Body:
As commented, you should call PreparedStatement#executeQuery without any argument. No need for you to pass a query to the execute command, as the prepared statement already contains your query.

ResultSet resultSet = preparedStatement.executeQuery();  // No argument.


问:
Install Poetry with Github Actions, poetry command not found. Cannot add Poetry into Path
I'm learning the basics of Github Actions for CICD. I use Poetry for Dependencies Managements. But I keep throwing poetry: command not found. If I run source $HOME/.poetry/env in every step (which opens new shell with my limited knowledge), It works. I tried to modify the .bashrc with cat $HOME/.poetry/env >> ~/.bashrc, but It doesn't work.

Here is my Yaml file, thanks ^^

```<code>name: Django CI
on:
  push:
    branches:
      - master
      - develop
  pull_request:
    branches:
      # - develop
      - master

jobs:
  Unit tests:
    runs-on: ubuntu-latest
    strategy: # Strategy
      max-parallel: 4
      matrix:
        python-version: [3.8]
    services:
      postgres:
        image: postgres:latest
        env:
          POSTGRES_DB: postgres
          POSTGRES_PASSWORD: postgres
          POSTGRES_USER: postgres
        ports:
          - 5432:5432
    steps:
      - name: Checkout Github repo
        uses: actions/checkout@v2
      - name: Set up Python 3.8
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install Dependencies
        run: |
          curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
          source $HOME/.poetry/env
          cat $HOME/.poetry/env >> ~/.bashrc
          poetry install
          echo "OK"
      - name: Run unit tests
        run: |
          # If I run "source $HOME/.poetry/env", It works
          poetry run python manage.py test

</code>```

答:
Note that, from this thread:

Github Actions invoke bash scripts in non-interactive mode, it will not load .bashrc by default.

Only /etc/bashrc or /etc/bash.bashrc would be sourced (you have some other alternatives).

Or you need to source it explicitly:

```<code>source $HOME/.poetry/env
</code>```

Body:
I'm learning the basics of Github Actions for CICD. I use Poetry for Dependencies Managements. But I keep throwing poetry: command not found. If I run source $HOME/.poetry/env in every step (which opens new shell with my limited knowledge), It works. I tried to modify the .bashrc with cat $HOME/.poetry/env >> ~/.bashrc, but It doesn't work.

Here is my Yaml file, thanks ^^

name: Django CI
on:
  push:
    branches:
      - master
      - develop
  pull_request:
    branches:
      # - develop
      - master

jobs:
  Unit tests:
    runs-on: ubuntu-latest
    strategy: # Strategy
      max-parallel: 4
      matrix:
        python-version: [3.8]
    services:
      postgres:
        image: postgres:latest
        env:
          POSTGRES_DB: postgres
          POSTGRES_PASSWORD: postgres
          POSTGRES_USER: postgres
        ports:
          - 5432:5432
    steps:
      - name: Checkout Github repo
        uses: actions/checkout@v2
      - name: Set up Python 3.8
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install Dependencies
        run: |
          curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
          source $HOME/.poetry/env
          cat $HOME/.poetry/env >> ~/.bashrc
          poetry install
          echo "OK"
      - name: Run unit tests
        run: |
          # If I run "source $HOME/.poetry/env", It works
          poetry run python manage.py test

Body:
Note that, from this thread:

Github Actions invoke bash scripts in non-interactive mode, it will not load .bashrc by default.

Only /etc/bashrc or /etc/bash.bashrc would be sourced (you have some other alternatives).

Or you need to source it explicitly:

source $HOME/.poetry/env


问:
Stored procedure only runs once
I have a SQL Server stored procedure:

```<code>CREATE PROCEDURE dbo.GetNextNumber
    @NextNumber int OUT
AS
    UPDATE SystemSettings
    SET REGISTRY_NUMBER = REGISTRY_NUMBER + 1
    WHERE ID = 1;

    SELECT @NextRegistryNumber = REGISTRY_NUMBER
    FROM SystemSettings
    WHERE ID = 1;

    SELECT 'NextNumber' = @NextRegistryNumber;
</code>```

I call this from a C# API method:

```<code>public int GetNextRegistryNumberFC()
{
    string procedure = "GetNextNumber";

    // Create ADO.NET objects.
    // SqlConnection con = new SqlConnection(connectionString);
    // SqlCommand cmd = new SqlCommand(procedure, con);

    using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings[<ConnectionString>].ConnectionString))
    using (var cmd = new SqlCommand(procedure, con))

    try
    {
        // Configure command and add input parameters.
        cmd.CommandType = CommandType.StoredProcedure;

        // Add the output parameter.
        cmd.Parameters.Add("@NextNumber", SqlDbType.Int).Direction = ParameterDirection.Output;

        // Execute the command.
        con.Open();
        cmd.ExecuteNonQuery();

        NextRegistryNumber = Convert.ToInt32(cmd.Parameters["@NextNumber"].Value);
    }
    catch (Exception ex)
    {
        throw;
    }
    finally
    {
        cmd.Dispose();
        con.Close();
        con.Dispose();
    }

    return NextRegistryNumber;
}
</code>```

This works the first time I run it. After that it just return the same number each time instead of incrementing it. I am not sure what I happening. If I run the stored procedure by it self it works each time. Does anyone know what is going wrong here?

答:
This stored procedure will produce unexpected results if it's called by two or more connections at the same time. Both executions will increment the field then both return the same value. Even if this was fixed, the update query creates a hotspot in a single row, with concurrent requests blocking while they wait for each other to update that row.

To avoid this, SQL Server (and other databases) have SEQUENCE objects that can be incremented atomically with minimal locking :

```<code>CREATE SEQUENCE Registration_Numbers START WITH 1;
</code>```

The NEXT VALUE FOR function will increment a sequence and return the new value :

```<code>SELECT NEXT VALUE FOR Registration_Numbers;
</code>```

This query is so short it doesn't need a stored procedure :

```<code>var sql="SELECT NEXT VALUE FOR Registration_Numbers;";
using(var con=new SqlConnection(connectionString))
using(var cmd=new SqlCommand(sql,con))
{
    var new_id=(long)cmd.ExecuteScalar();
    return new_id;
}
</code>```

There's no need for try/catch here. A using block ensures the connection and command objects will be disposed even if an exception occurs. using works even in cases where finally wouldn't be called.

Rethrowing isn't needed either. The following catch block is no different than no catch at all.

```<code>catch (Exception ex)
{
    throw;
}
</code>```

Such a block would make sense if the exception was processed, eg logged.

Atomic update and read

If using a table is absolutely necessary (why?), the OUTPUT clause can be used to return the new value right from the UPDATE command:

```<code>CREATE PROCEDURE dbo.GetNextNumber
AS
    UPDATE SystemSettings
    SET REGISTRY_NUMBER = REGISTRY_NUMBER + 1
    OUTPUT inserted.REGISTRY_NUMBER
    WHERE ID = 1;
</code>```

The same code can be used to call the stored procedure. Only the the CommandType needs to change

```<code>var proc_name=" dbo.GetNextNumber";
using(var con=new SqlConnection(connectionString))
using(var cmd=new SqlCommand(proc_name,con))
{
    cmd.CommandType = CommandType.StoredProcedure;

    var new_id=(long)cmd.ExecuteScalar();
    return new_id;
}
</code>```

Title: Stored procedure only runs once

Body:
I have a SQL Server stored procedure:

CREATE PROCEDURE dbo.GetNextNumber
    @NextNumber int OUT
AS
    UPDATE SystemSettings
    SET REGISTRY_NUMBER = REGISTRY_NUMBER + 1
    WHERE ID = 1;

    SELECT @NextRegistryNumber = REGISTRY_NUMBER
    FROM SystemSettings
    WHERE ID = 1;

    SELECT 'NextNumber' = @NextRegistryNumber;

I call this from a C# API method:

public int GetNextRegistryNumberFC()
{
    string procedure = "GetNextNumber";

    // Create ADO.NET objects.
    // SqlConnection con = new SqlConnection(connectionString);
    // SqlCommand cmd = new SqlCommand(procedure, con);

    using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings[<ConnectionString>].ConnectionString))
    using (var cmd = new SqlCommand(procedure, con))

    try
    {
        // Configure command and add input parameters.
        cmd.CommandType = CommandType.StoredProcedure;

        // Add the output parameter.
        cmd.Parameters.Add("@NextNumber", SqlDbType.Int).Direction = ParameterDirection.Output;

        // Execute the command.
        con.Open();
        cmd.ExecuteNonQuery();

        NextRegistryNumber = Convert.ToInt32(cmd.Parameters["@NextNumber"].Value);
    }
    catch (Exception ex)
    {
        throw;
    }
    finally
    {
        cmd.Dispose();
        con.Close();
        con.Dispose();
    }

    return NextRegistryNumber;
}

This works the first time I run it. After that it just return the same number each time instead of incrementing it. I am not sure what I happening. If I run the stored procedure by it self it works each time. Does anyone know what is going wrong here?

Body:
This stored procedure will produce unexpected results if it's called by two or more connections at the same time. Both executions will increment the field then both return the same value. Even if this was fixed, the update query creates a hotspot in a single row, with concurrent requests blocking while they wait for each other to update that row.

To avoid this, SQL Server (and other databases) have SEQUENCE objects that can be incremented atomically with minimal locking :

CREATE SEQUENCE Registration_Numbers START WITH 1;

The NEXT VALUE FOR function will increment a sequence and return the new value :

SELECT NEXT VALUE FOR Registration_Numbers;

This query is so short it doesn't need a stored procedure :

var sql="SELECT NEXT VALUE FOR Registration_Numbers;";
using(var con=new SqlConnection(connectionString))
using(var cmd=new SqlCommand(sql,con))
{
    var new_id=(long)cmd.ExecuteScalar();
    return new_id;
}

There's no need for try/catch here. A using block ensures the connection and command objects will be disposed even if an exception occurs. using works even in cases where finally wouldn't be called.

Rethrowing isn't needed either. The following catch block is no different than no catch at all.

catch (Exception ex)
{
    throw;
}

Such a block would make sense if the exception was processed, eg logged.

Atomic update and read

If using a table is absolutely necessary (why?), the OUTPUT clause can be used to return the new value right from the UPDATE command:

CREATE PROCEDURE dbo.GetNextNumber
AS
    UPDATE SystemSettings
    SET REGISTRY_NUMBER = REGISTRY_NUMBER + 1
    OUTPUT inserted.REGISTRY_NUMBER
    WHERE ID = 1;

The same code can be used to call the stored procedure. Only the the CommandType needs to change

var proc_name=" dbo.GetNextNumber";
using(var con=new SqlConnection(connectionString))
using(var cmd=new SqlCommand(proc_name,con))
{
    cmd.CommandType = CommandType.StoredProcedure;

    var new_id=(long)cmd.ExecuteScalar();
    return new_id;
}