I'm trying to make a dataframe from a json file without success. I'm not exactly sure why, as is my first time dealing with json files, but from what I found while looking for a solution it seems the data is heavily nested.
Here's the json https://stats.nba.com/stats/leagueLeaders?ActiveFlag=No&LeagueID=00&PerMode=Totals&Scope=S&Season=All+Time&SeasonType=Regular+Season&StatCategory=AST.
I've tried to create the df using pandas .read_json() with different orients, with open, and also using request. The request method actually gave me a dataframe although highly unconfigured.
AST_LDR = pd.read_json('C:\\Users\\user\\Desktop\\python\\AssistLeaders.json')
#Error
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-20-55a99c3e3802> in <module>
----> 1 AST_LDR = pd.read_json('C:\\Users\\user\\Desktop\\python\\Kobe Bryant\\AssistLeaders.json')
2
3
~\Anaconda3\lib\site-packages\pandas\io\json\json.py in read_json(path_or_buf, orient, typ, dtype, convert_axes, convert_dates, keep_default_dates, numpy, precise_float, date_unit, encoding, lines, chunksize, compression)
425 return json_reader
426
--> 427 result = json_reader.read()
428 if should_close:
429 try:
~\Anaconda3\lib\site-packages\pandas\io\json\json.py in read(self)
535 )
536 else:
--> 537 obj = self._get_object_parser(self.data)
538 self.close()
539 return obj
~\Anaconda3\lib\site-packages\pandas\io\json\json.py in _get_object_parser(self, json)
554 obj = None
555 if typ == 'frame':
--> 556 obj = FrameParser(json, **kwargs).parse()
557
558 if typ == 'series' or obj is None:
~\Anaconda3\lib\site-packages\pandas\io\json\json.py in parse(self)
650
651 else:
--> 652 self._parse_no_numpy()
653
654 if self.obj is None:
~\Anaconda3\lib\site-packages\pandas\io\json\json.py in _parse_no_numpy(self)
869 if orient == "columns":
870 self.obj = DataFrame(
--> 871 loads(json, precise_float=self.precise_float),
dtype=None)
872 elif orient == "split":
873 decoded = {str(k): v for k, v in compat.iteritems(
ValueError: Expected object or value
#------------
import json
with open('C:\\Users\\user\\Desktop\\python\\Kobe Bryant\\AssistLeaders.json') as f:
data = json.load(f)
AST_LDR = pd.DataFrame(data)
#Error
---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
<ipython-input-19-f61dd4edbb9e> in <module>
1 import json
2 with open('C:\\Users\\user\\Desktop\\python\\Kobe Bryant\\AssistLeaders.json') as f:
----> 3 data = json.load(f)
4 AST_LDR = pd.DataFrame(data)
~\Anaconda3\lib\json\__init__.py in load(fp, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
294 cls=cls, object_hook=object_hook,
295 parse_float=parse_float, parse_int=parse_int,
--> 296 parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
297
298
~\Anaconda3\lib\json\__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
346 parse_int is None and parse_float is None and
347 parse_constant is None and object_pairs_hook is None and not kw):
--> 348 return _default_decoder.decode(s)
349 if cls is None:
350 cls = JSONDecoder
~\Anaconda3\lib\json\decoder.py in decode(self, s, _w)
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
339 if end != len(s):
~\Anaconda3\lib\json\decoder.py in raw_decode(self, s, idx)
353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
JSON is a very flexible format. pd.read_json accepts only a few formats and more often than not, the actual data does not fit any of those. You are better off treating it as a dictionary, extracting the needed data and construct your data frame accordingly:
url = 'https://stats.nba.com/stats/leagueLeaders?ActiveFlag=No&LeagueID=00&PerMode=Totals&Scope=S&Season=All+Time&SeasonType=Regular+Season&StatCategory=AST'
data = requests.get(url).json()
df = pd.DataFrame(data['resultSet']['rowSet'], columns=data['resultSet']['headers'])
Result:
PLAYER_ID PLAYER_NAME GP MIN FGM FGA FG_PCT FG3M FG3A FG3_PCT FTM FTA FT_PCT OREB DREB REB AST STL BLK TOV PF PTS AST_TOV STL_TOV EFG_PCT TS_PCT GP_RANK MIN_RANK FGM_RANK FGA_RANK FG_PCT_RANK FG3M_RANK FG3A_RANK FG3_PCT_RANK FTM_RANK FTA_RANK FT_PCT_RANK OREB_RANK DREB_RANK REB_RANK AST_RANK STL_RANK BLK_RANK TOV_RANK PF_RANK PTS_RANK AST_TOV_RANK STL_TOV_RANK EFG_PCT1 TS_PCT1
0 304 John Stockton 1504 47766 7039 13658 0.515 845.0 2202.0 0.384 4788 5796 0.826 966.0 3085.0 4051 15806 3265.0 315.0 4244.0 3942 19711 3.724 0.769 0.546 0.608 4 9 69 93 109 153 169 88 40 48 183 407 246 371 1 1 400 2 14 45 5 164 50 18
1 467 Jason Kidd 1391 50116 6219 15557 0.400 1988.0 5701.0 0.349 3103 3954 0.785 1768.0 6957.0 8725 12091 2684.0 450.0 4003.0 2572 17529 3.020 0.670 0.464 0.507 11 5 101 56 1190 10 7 293 149 152 447 138 27 56 2 2 284 5 171 85 30 275 881 888
2 959 Steve Nash 1217 38073 6321 12892 0.490 1685.0 3939.0 0.428 3060 3384 0.904 643.0 2999.0 3642 10335 899.0 102.0 3478.0 1982 17387 2.972 0.258 0.556 0.605 36 46 96 116 267 22 35 13 154 221 3 601 262 436 3 222 861 13 411 87 37 1030 32 22
3 349 Mark Jackson 1296 39117 4793 10731 0.447 734.0 2213.0 0.332 2169 2818 0.770 1281.0 3682.0 4963 10334 1608.0 117.0 3155.0 2230 12489 3.275 0.510 0.481 0.522 23 38 227 207 748 193 165 413 324 322 561 273 176 257 4 32 806 23 289 223 19 571 650 679
4 77142 Magic Johnson 906 33245 6211 11951 0.520 325.0 1074.0 0.303 4960 5850 0.848 1601.0 4958.0 6559 10141 1724.0 374.0 3506.0 2050 17707 2.892 0.492 0.533 0.610 227 98 102 145 91 392 369 520 37 45 91 180 80 138 5 21 345 11 368 80 46 625 98 16
Related
So I need some coordinates. I you open this page: https://www.inatur.no/jakt/5891ac4ee4b0f06b0de95636/blafjellet-jaktfelt-smaviltjakt-i-lierne there is a map option that shows a polygon over an area.
I want to get those paths as normal lat/long coordinates, but I can't find any solution to this.
In the HTML I find this code:
<path fill="url(#dojoxUnique1)" stroke="rgb(206, 80, 53)" stroke-opacity="1" stroke-width="2.6666666666666665" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="4" path="M 789,616 789,616 636,580 567,563 510,549 499,547 514,412 522,354 528,309 533,280 541,223 547,180 568,199 584,210 598,213 612,211 620,212 644,218 673,232 707,245 751,232 911,289 957,307 984,340 982,341 985,348 983,353 979,359 973,361 964,369 963,366 960,366 955,363 953,366 957,370 959,381 957,386 961,387 962,389 959,394 961,405 957,405 951,408 949,405 945,404 943,409 945,414 948,417 949,423 948,428 944,431 942,434 946,437 945,450 930,458 928,465 919,472 919,474 913,481 911,482 898,503 891,505 888,508 884,503 876,504 858,514 851,540 847,547 800,571 789,616 Z" d="M 789 616 789 616 636 580 567 563 510 549 499 547 514 412 522 354 528 309 533 280 541 223 547 180 568 199 584 210 598 213 612 211 620 212 644 218 673 232 707 245 751 232 911 289 957 307 984 340 982 341 985 348 983 353 979 359 973 361 964 369 963 366 960 366 955 363 953 366 957 370 959 381 957 386 961 387 962 389 959 394 961 405 957 405 951 408 949 405 945 404 943 409 945 414 948 417 949 423 948 428 944 431 942 434 946 437 945 450 930 458 928 465 919 472 919 474 913 481 911 482 898 503 891 505 888 508 884 503 876 504 858 514 851 540 847 547 800 571 789 616Z" stroke-dasharray="none" dojoGfxStrokeStyle="solid" fill-rule="evenodd"></path>
Does someone know how I can convert these to lat/long coordinates?
I have a tls file such as:
1224 926 1380 688 845 109 118 88 1275 1306 91 796 102 1361 27 995
1928 2097 138 1824 198 117 1532 2000 1478 539 1982 125 1856 139 475 1338
848 202 1116 791 1114 236 183 186 150 1016 1258 84 952 1202 988 866
946 155 210 980 896 875 925 613 209 746 147 170 577 942 475 850
1500 322 43 95 74 210 1817 1631 1762 128 181 716 171 1740 145 1123
3074 827 117 2509 161 206 2739 253 2884 248 3307 2760 2239 1676 1137 3055
183 85 143 197 243 72 291 279 99 189 30 101 211 209 77 198
175 149 259 372 140 250 168 142 146 284 273 74 162 112 78 29
169 578 97 589 473 317 123 102 445 217 144 398 510 464 247 109
3291 216 185 1214 167 495 1859 194 1030 3456 2021 1622 3511 222 3534 1580
2066 2418 2324 93 1073 82 102 538 1552 962 91 836 1628 2154 2144 1378
149 963 1242 849 726 1158 164 1134 658 161 1148 336 826 1303 811 178
3421 1404 2360 2643 3186 3352 1112 171 168 177 146 1945 319 185 2927 2289
543 462 111 459 107 353 2006 116 2528 56 2436 1539 1770 125 2697 2432
1356 208 5013 4231 193 169 3152 2543 4430 4070 4031 145 4433 4187 4394 1754
5278 113 4427 569 5167 175 192 3903 155 1051 4121 5140 2328 203 5653 3233
how can I read it in a list of list of int in haskell?
I have tried few options but I could not manage to do it. I am very new to haskell so please be patience.
First break your input into lines using lines:
let test = "1 2 3 4\n 5 6 7 \n 4 2 5"
let rows = lines test --literally "lines test"! Beautiful, eh?
Result:
["1 2 3 4"," 5 6 7 "," 4 2 5"] :: [[Char]]
Then, extract individual numbers as strings using words:
let nums_as_strings = map words rows
Result:
[["1","2","3","4"],["5","6","7"],["4","2","5"]] :: :: [[[Char]]]
The last thing to do is convert these strings to integers with read:
let numbers = map (map read) nums_as_strings :: [[Int]]
Result:
[[1,2,3,4],[5,6,7],[4,2,5]] :: [[Int]]
Or, squashed into one line:
let numbers = map (map read) (map words $ lines test) :: [[Int]]
Example with your data:
Prelude> let test = "1224 926 1380 688 845 109 118 88 1275 1306 91 796 102 1361 27 995\n1928 2097 138 1824 198 117 1532 2000 1478 539 1982 125 1856 139 475 1338"
Prelude> map (map read) (map words $ lines test) :: [[Int]]
[[1224,926,1380,688,845,109,118,88,1275,1306,91,796,102,1361,27,995],[1928,2097,138,1824,198,117,1532,2000,1478,539,1982,125,1856,139,475,1338]]
You may need to take care of empty lines, but that's really simple.
import System.IO
readListOfLists :: Handle -> IO [[Int]]
readListOfLists handle = do
contents <- hGetContents handle
let ls :: [String]
ls = lines contents
ws :: [[String]]
ws= map words ls
res :: [[Int]]
res = map (map read) ws
return res;
or you can write the same code in one line:
readListOfLists :: Handle -> IO [[Int]]
readListOfLists = fmap (map (map read . words) . lines) . hGetContents
To use it:
do
handle <- openFile fileName ReadMode
table <- readListOfLists handle
hClose handle
print table
I'm trying to run the below script to get a list of Orgs and the amount of users each Org has:
#!/bin/bash
array=(293 182 177 12 85 51 325 225 40 169 357 329 243 349 291 295 22 279 16 69 219 299 301 331 91 281 285 59 283 341 45 289 95 61 77 13 14 201 43 343 223 28 171 26 233 47 303 367 369 339 257 305 353 245 213 87 345 2 71 199 24 179 259 37 35 237)
for i in "${array[#]}"; do
query=$(export MYSQL_PWD=MYPASS; mysql -e "SELECT COUNT(*) FROM Org.Users WHERE HomeOrgID=$i;")
echo "Org_$i:$query"
done
I expect the result to be a simple "Org:Number" list:
Org_1:150
Org_25:250
Org_17:64
Org_64:12
But the output is not displayed correctly. It does show part of the MySQL statement:
Org_293:COUNT(*)
1
Org_182:COUNT(*)
0
Org_177:COUNT(*)
8
Org_12:COUNT(*)
0
Org_85:COUNT(*)
1
How can I get the output to NOT display that "COUNT(*)" and display just a simple list?
Thanks in advance!
One quick hack : use bash arrays to store your output.
#!/bin/bash
array=(293 182 177 12 85 51 325 225 40 169 357 329 243 349 291 295 22 279 16 69 219 299 301 331 91 281 285 59 283 341 45 289 95 61 77 13 14 201 43 343 223 28 171 26 233 47 303 367 369 339 257 305 353 245 213 87 345 2 71 199 24 179 259 37 35 237)
for i in "${array[#]}"; do
# we store the result of the request as an array
query=($(export MYSQL_PWD=MYPASS; mysql -e "SELECT COUNT(*) FROM Org.Users WHERE HomeOrgID=$i;"))
# we echo the 2nd member of the array. ${query[0]} should contain 'count(*)'
echo "Org_$i:${query[1]}"
done
I am working on verifying the access token on AWS Cognito. One thing I have to do is to convert the key from jwks.json (of the userpool) into a rsa Public Key structure (depending on the used JWT API).
So the values for 'n' and 'e' must be big int (long) and int.
What would be the proper value of those two variables, for example:
raw_n := "rdTmzrh7t0i_YN0MDLejnS0jXIFoSzRfFEbqf-bwGuRLnhLI4T3zGAk9HGZeAG6B5gg1D40Jsz1upo4E70VS0raGfSBPYPO7ZAJ2VCUUeblr9X_aWK4f294v4Cf3n8jZyFcGK9qhgcqy3DlHqqDANtjamWVtEhTRTFc-qoz1ScvHmPupsXlj1FsAEFEbVhP4705ez5gW3uQOoidrm38sPFwCN7g7xhA9CyzF04Zsjky55OfMCyWlIt7nljLx7ZRG3dVRD3vdEBI99qtxf43qMCWSPUk7Whn11Wf_u0xDrWhtGR9k599rKBBRWuqcujYYnFuOT0BeQIL25cePPK8lxw"
raw_e := "AQAB"
I suppose this is Base64 URL encoded.
I am using Go and when decoding them, I am having those values:
Value of N = 21944212446918148307583266513211511961176501179660110972882270757464120247554839864039423096862533136364974693915136668416630333929475539217929135693935014796040215031370110392351836608149288005498214604075814317642291632460369313969964278103135047317799644939426174469533574133378199425168189176269507635563270873057483981163804984573367938044175828995131343800369166239708527999544583873649523245709447765091038652758632917341001616695912404965678061555823269517387737693508193881028187912513285002546706797506255288735805912213209305939523528571103281920754204216834697552752238593850648051945624431639572960454087
Value of E = 65537
And the final values are:
TokenSignature= GYZQKv7o8_o9E4ktVKZngYD4BS5QluOMwE-MRcJB432CmNimQm6JbvT3H48ECThe4f3sZ1KyVbgDJbyUnlkaAwMEBjMnlV7AUaZb-ifveM7kHM30BS5LCV_SCiCk-PvmWjeIHu9bR3EwG8azJCceD5A7gDLmhAtPN94gRy-opXJPAnaCba00AwKBd_pN3UH7LYu4u4EQ29eIfn4k4RCLuR31jr7ad3dvvjhhy658dQSHzSuPZGcN1-CRVSlrd0nk0Ba2t8W33LtjxM6wzPThWgh0fpy2XEDosGU_9FiXdEjUKisE3VHxroygQ8ekVWKHssa2eujXCx8OthWzaGag0w1
Signing String= eyJhbGciOiJSUzI1NiIsImtpZCI6ImpBNlFvakp0RkI0TmNIR1BmcS85ZWgzSHI2YnVXWEI0VzkxRTd5bWNjSk09In0.eyJleHAiOjE0NzAyNzgzMTEsInRva2VuX3VzZSI6ImFjY2VzcyIsImlzcyI6Imh0dHBzOi8vY29nbml0by1pZHAudXMtZWFzdC0xLmFtYXpvbmF3cy5jb20vdXMtZWFzdC0xX0d1OFlhVGg3MiIsImNsaWVudF9pZCI6IjRwNzNuYjhra3NsbHJrbTlzMzdzYXZsNzEzIiwidXNlcm5hbWUiOiJtYXRlbyIsImtpZCI6IiIsImFsZyI6IiIsImp0aSI6IjhmNTBiZmU4LWVlNGUtNGFkZi04MDQxLWU5MGM4YWJkZDExZCIsImlhdCI6MTQ3MDI3NDcxMSwic3ViIjoiYjFjMDZhMTktYjE5Yy00NGMwLTgzZjctODY2NTZjYzRmMjMxIn0
rsa.PublicKey{N:21944212446918148307583266513211511961176501179660110972882270757464120247554839864039423096862533136364974693915136668416630333929475539217929135693935014796040215031370110392351836608149288005498214604075814317642291632460369313969964278103135047317799644939426174469533574133378199425168189176269507635563270873057483981163804984573367938044175828995131343800369166239708527999544583873649523245709447765091038652758632917341001616695912404965678061555823269517387737693508193881028187912513285002546706797506255288735805912213209305939523528571103281920754204216834697552752238593850648051945624431639572960454087, E:65537}
However, with those revisiter values, I am still getting crypto/rsa: verification error. How can I determine if the problem is coming from the JWT Library or the values?
Thank you very much
You should be able to verify the signature with the rsa.PublicKey generated by the program below or at https://play.golang.org/p/VZqD5m057b. It is based on code from https://github.com/mendsley/gojwk (please see the playground link or https://github.com/mendsley/gojwk/blob/master/LICENSE for the Copyright attribution) - I would recommend to clone that repository and use it as an example and model.
package main
import (
"crypto/rsa"
"encoding/base64"
"encoding/binary"
"fmt"
"math/big"
)
func main() {
rawN := "rdTmzrh7t0i_YN0MDLejnS0jXIFoSzRfFEbqf-bwGuRLnhLI4T3zGAk9HGZeAG6B5gg1D40Jsz1upo4E70VS0raGfSBPYPO7ZAJ2VCUUeblr9X_aWK4f294v4Cf3n8jZyFcGK9qhgcqy3DlHqqDANtjamWVtEhTRTFc-qoz1ScvHmPupsXlj1FsAEFEbVhP4705ez5gW3uQOoidrm38sPFwCN7g7xhA9CyzF04Zsjky55OfMCyWlIt7nljLx7ZRG3dVRD3vdEBI99qtxf43qMCWSPUk7Whn11Wf_u0xDrWhtGR9k599rKBBRWuqcujYYnFuOT0BeQIL25cePPK8lxw"
rawE := "AQAB"
decodedE, err := base64.RawURLEncoding.DecodeString(rawE)
if err != nil {
panic(err)
}
// make sure that the E field is at least 4 bytes, pad if necessary
if len(decodedE) < 4 {
ndata := make([]byte, 4)
copy(ndata[4-len(decodedE):], decodedE)
decodedE = ndata
}
pubKey := &rsa.PublicKey{
N: &big.Int{},
E: int(binary.BigEndian.Uint32(decodedE[:])),
}
decodedN, err := base64.RawURLEncoding.DecodeString(rawN)
if err != nil {
panic(err)
}
pubKey.N.SetBytes(decodedN)
fmt.Println(decodedN)
fmt.Println(decodedE)
fmt.Printf("%#v\n", *pubKey)
}
Output:
[173 212 230 206 184 123 183 72 191 96 221 12 12 183 163 157 45 35 92 129 104 75 52 95 20 70 234 127 230 240 26 228 75 158 18 200 225 61 243 24 9 61 28 102 94 0 110 129 230 8 53 15 141 9 179 61 110 166 142 4 239 69 82 210 182 134 125 32 79 96 243 187 100 2 118 84 37 20 121 185 107 245 127 218 88 174 31 219 222 47 224 39 247 159 200 217 200 87 6 43 218 161 129 202 178 220 57 71 170 160 192 54 216 218 153 101 109 18 20 209 76 87 62 170 140 245 73 203 199 152 251 169 177 121 99 212 91 0 16 81 27 86 19 248 239 78 94 207 152 22 222 228 14 162 39 107 155 127 44 60 92 2 55 184 59 198 16 61 11 44 197 211 134 108 142 76 185 228 231 204 11 37 165 34 222 231 150 50 241 237 148 70 221 213 81 15 123 221 16 18 61 246 171 113 127 141 234 48 37 146 61 73 59 90 25 245 213 103 255 187 76 67 173 104 109 25 31 100 231 223 107 40 16 81 90 234 156 186 54 24 156 91 142 79 64 94 64 130 246 229 199 143 60 175 37 199]
[0 1 0 1]
rsa.PublicKey{N:21944212446918148307583266513211511961176501179660110972882270757464120247554839864039423096862533136364974693915136668416630333929475539217929135693935014796040215031370110392351836608149288005498214604075814317642291632460369313969964278103135047317799644939426174469533574133378199425168189176269507635563270873057483981163804984573367938044175828995131343800369166239708527999544583873649523245709447765091038652758632917341001616695912404965678061555823269517387737693508193881028187912513285002546706797506255288735805912213209305939523528571103281920754204216834697552752238593850648051945624431639572960454087, E:65537}
I have used npm module jwk-to-pem in my nodeJS app. As seen in the documentation:
var jwkToPem = require('jwk-to-pem'),
jwt = require('jsonwebtoken');
var jwk = { kty: 'EC', crv: 'P-256', x: '...', y: '...' },
pem = jwkToPem(jwk);
jwt.verify(token, pem);
You can export pem to a file and use it in your code.
Decoding a JWK into a *rsa.PublicKey can be done by unmarshing the JSON into the following data structure and using the method below.
A link to this data structure:
// JSONKey represents a raw key inside a JWKs.
type JSONKey struct {
Curve string `json:"crv"`
Exponent string `json:"e"`
ID string `json:"kid"`
Modulus string `json:"n"`
X string `json:"x"`
Y string `json:"y"`
precomputed interface{}
}
A link to this method:
// RSA parses a JSONKey and turns it into an RSA public key.
func (j *JSONKey) RSA() (publicKey *rsa.PublicKey, err error) {
// Check if the key has already been computed.
if j.precomputed != nil {
var ok bool
if publicKey, ok = j.precomputed.(*rsa.PublicKey); ok {
return publicKey, nil
}
}
// Confirm everything needed is present.
if j.Exponent == "" || j.Modulus == "" {
return nil, fmt.Errorf("%w: rsa", ErrMissingAssets)
}
// Decode the exponent from Base64.
//
// According to RFC 7518, this is a Base64 URL unsigned integer.
// https://tools.ietf.org/html/rfc7518#section-6.3
var exponent []byte
if exponent, err = base64.RawURLEncoding.DecodeString(j.Exponent); err != nil {
return nil, err
}
// Decode the modulus from Base64.
var modulus []byte
if modulus, err = base64.RawURLEncoding.DecodeString(j.Modulus); err != nil {
return nil, err
}
// Create the RSA public key.
publicKey = &rsa.PublicKey{}
// Turn the exponent into an integer.
//
// According to RFC 7517, these numbers are in big-endian format.
// https://tools.ietf.org/html/rfc7517#appendix-A.1
publicKey.E = int(big.NewInt(0).SetBytes(exponent).Uint64())
// Turn the modulus into a *big.Int.
publicKey.N = big.NewInt(0).SetBytes(modulus)
// Keep the public key so it won't have to be computed every time.
j.precomputed = publicKey
return publicKey, nil
}
If you're looking to authenticate JWTs from a JWKs resource like AWS Cognito, I took these examples from a project that does just that: github.com/MicahParks/keyfunc
I'm a complete novice when it comes to SQL, just getting started.
I need help writing a query to update values in my SQL table:
Two tables: Members, Chapters
Concerned with three columns in Chapters table: CHAP_NO, FA, FA2
i.e.
CHAP_NO FA FA2
111 1234567 2345689
222 2234567 4567899
333 3225545
444
555 2358878 4566665
666 4568799
777 4566878 1233666
888 1119998
999 3555879 6544799
etc. . .
Each value is a unique identifier
Concerned with two columns in Members table: MEMB_NO, CURR_CHAP
i.e.
MEMB_NO CURR_CHAP
1234567 665
5468787 664
4577789 122
4578767 233
7775666 588
4114748 787
etc. . .
Is it possible to automate an update based on if FA or FA2 is in Chapters table, update their CURR_CHAP value in the Members table from the CHAP_NO value?
From the above example data, I need MEMB_NO '1234567' to have his CURR_CHAP updated to '111' because he is listed as FA for CHAP_NO '111'
I really need to do this for similar MS SQL and MySQL databases if possible. If this can't be automated, I need help writing a query to manually update the Members table as exampled above with a 2 column manual update row of data:
MEMB_NO CURR_CHAP
5470011 547
5030038 545
3880188 544
1140753 543
4130019 543
5420011 542
5410010 541
2590511 540
4190109 540
4180296 539
5380020 538
5370012 537
1050859 536
4390125 535
4860144 535
5330009 533
5330061 533
1080746 532
2060321 531
1750750 529
4250135 528
8070013 528
1080645 527
5270053 527
2580695 526
2440073 525
2440163 525
5240010 524
4980035 523
2120380 522
4000418 521
3270185 520
4350210 519
4610218 518
5160004 516
1610450 515
5150065 515
5130046 513
5130050 513
5120047 512
1940306 510
2500170 510
5090087 509
5080014 508
1270803 505
1381026 505
2260505 504
3900106 504
5030006 503
1770526 501
1780355 501
5000017 500
4980037 498
2380411 497
4970019 497
4960044 496
4960127 496
4950012 495
4950095 495
1720409 494
2260867 494
2300466 493
3990055 492
4920204 492
1311252 491
2100252 491
1750592 490
1760563 490
2520403 489
4890051 489
4870076 487
4870143 487
4860153 486
1670856 485
4840054 484
4840143 484
2920024 483
4830136 483
1751087 482
1790828 481
1970128 481
2050815 480
4800027 480
1870246 478
3210174 478
4770100 477
4760124 476
4760126 476
1350640 475
2280722 475
2200077 474
3410230 474
4730100 473
4250159 470
4250156 470
3790179 464
4630164 463
4630139 463
2210062 461
4610188 461
4210110 460
4870065 459
4500246 450
1110937 449
1110934 449
2280501 447
4450323 445
4440114 444
4410135 441
4410216 441
1600799 435
2280449 435
4080089 431
4310132 431
1780525 427
4270190 427
4260502 426
4260550 426
4250467 425
4250485 425
4210328 421
4190230 419
4180005 418
4180341 418
4250232 417
4130004 413
4110444 411
4090133 409
4080308 408
4430119 408
4070279 407
4070443 407
1650354 405
1670725 404
2240204 402
2870319 400
3990114 399
3980014 398
4050073 398
3170399 397
3970348 397
1760487 395
4180191 395
1800443 394
2580288 394
1280499 393
3930227 393
3780058 391
3900377 390
2590362 389
1720492 385
1720398 384
2840325 383
3710142 381
3800235 380
3780407 378
1760459 375
1730026 373
3710306 371
3710228 371
1051294 370
3700332 370
3670174 367
1780583 359
4640038 359
1280614 358
2580373 358
3570449 357
3530560 353
3500046 350
3490275 349
3490244 349
3320203 348
3480310 348
4210188 346
3440364 344
4490223 344
1750642 342
3990257 342
1790541 341
3370562 337
3370738 337
1870336 334
3340382 334
1950674 333
1460619 328
3280586 328
4250013 326
1340705 324
2590495 324
2870029 322
3030290 322
1880232 321
2280415 321
3200547 320
3200568 320
3180132 318
3180178 318
3930433 317
4850072 317
2870449 315
3150168 315
1390763 313
3120170 312
3110048 311
3110110 311
3070267 307
3500231 306
3980122 306
1160708 305
3050510 305
2280197 304
3040348 304
1060785 303
1340760 303
3020534 302
3980151 301
2990239 299
1770425 297
2950573 295
2280513 294
2320434 287
2870594 287
4110133 284
4260131 278
2770221 277
2770366 277
2760484 276
2750397 275
2580694 272
1751006 267
4010252 267
2660235 266
2780335 265
2640326 264
3840125 263
1270872 259
2590690 259
2580728 258
2030556 257
4600151 257
2550390 255
4440010 255
2520461 252
4130095 252
3910117 250
2490314 249
1361032 247
1900370 247
2440211 244
2440101 244
1730150 243
1440258 242
2420062 242
1350511 238
2380559 238
1800598 237
2350417 235
2340372 234
2320453 232
2590582 232
2120104 230
2280696 228
3480122 227
1111011 226
2260626 226
3230234 222
2270200 221
4470101 221
3010326 219
2180334 218
2170591 217
1620648 213
2120524 212
3010424 212
3130060 210
2070261 207
2070313 207
1640858 206
1620684 205
2030573 203
2030810 203
1270589 201
1111015 200
1990448 199
1950384 195
1920328 192
1920684 192
1750798 188
1880607 188
1870445 187
1850587 185
2960295 185
1800721 180
1791166 179
3990116 178
3130119 177
4170034 177
1051172 176
1380942 176
1751011 175
4500021 175
2840346 174
3460307 174
1730027 173
4070275 173
1110986 171
1670586 167
1111222 166
2060385 164
1560459 163
1740135 162
3130093 161
1600695 160
1600682 160
1350600 159
1590341 159
1580464 158
1570742 157
1570761 157
4440077 156
1520404 152
4700010 152
3390033 147
4170240 145
4730144 143
4250191 142
1400502 140
2170212 140
1360713 139
3040299 139
1800519 136
1270930 135
1720638 134
1800462 133
3930387 133
1111000 131
1311274 131
1360547 128
2260776 128
4830091 127
1800431 123
1280523 122
1750851 122
1291052 121
3850165 121
1180219 118
1180477 118
2240110 116
2870263 116
3900143 114
1111488 111
1490386 111
1060765 110
1780463 110
3200394 108
5050015 108
3870219 105
I think this should work on both...
UPDATE
IGNORE Chapters,
Members
SET Members.CURR_CHAP = Chapters.CHAP_NO
WHERE Chapters.FA = Members.MEMB_NO
AND Chapters.FA != ''
AND Chapters.FA2 != ''
UPDATE members m
INNER JOIN chapters c on (m.memb_no = c.fa or m.memb_no=c.fa2)
SET m.curr_chap=c.chap_no
This query worked for me in MySql
update Members m
INNER JOIN chapters c
ON (m.memb_no=c.FA or m.memb_no=c.FA2)
set CURR_CHAP = c.CHAP_NO