tweak: Found some bugs, added some convenience options

This commit is contained in:
NunoSempere 2021-12-05 13:30:06 +01:00
parent ee0ee3ca16
commit 62b0f8e210
5 changed files with 2626 additions and 5 deletions

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,8 @@
"scripts": {
"start": "node src/index.js",
"test": "echo \"Error: no test specified\" && exit 1",
"reload": "heroku run:detached node src/utils/doEverythingForScheduler.js"
"reload": "heroku run:detached node src/utils/doEverythingForScheduler.js",
"setCookies": "./src/utils/setCookies.sh"
},
"repository": {

View File

@ -91,9 +91,11 @@ export async function astralcodexten(){
results.push(result)
})
}
// let string = JSON.stringify(results, null, 2)
// fs.writeFileSync('./data/foretold-questions.json', string);
// console.log(JSON.stringify(results, null, 2))
/*
let string = JSON.stringify(results, null, 2)
console.log(JSON.stringify(results, null, 2))
fs.writeFileSync('./data/astralcodexten-questions.json', string);
*/
await upsert(results, "astralcodexten-questions")
// console.log(results)
console.log("Done")

View File

@ -147,7 +147,7 @@ export async function metaculus() {
}
// let string = JSON.stringify(all_questions, null, 2)
fs.writeFileSync('./metaculus-questions.json', string);
// fs.writeFileSync('./metaculus-questions.json', string);
await upsert(all_questions, "metaculus-questions")
console.log("Done")

63
src/utils/setCookies.sh Executable file
View File

@ -0,0 +1,63 @@
#!/usr/bin/bash
clear
echo "
Platforms:
[0]: CSET-Foretell
[1]: Good Judgment Open
"
read -p "Choose a platform [0/1]: " platform
echo ""
case $platform in
"0" )
echo "Platform: CSET-Foretell"
echo "Copy request headers from https://www.cset-foretell.com/questions"
firefox "https://www.cset-foretell.com/questions"
echo "Copy the request headers to clipboard"
read -p "Press any key when copied: " copied
cookie=$(xclip -selection c -o | {
while IFS= read -r line; do
if [[ "$line" == *"Cookie:"* ]]; then
#echo "Found cookie!"
# echo "$line"
cookie="$(echo $line |sed 's|Cookie: ||' )"
#echo "Cookie: $cookie"
fi
done
echo "$cookie"
}
)
## Has to deal with https://unix.stackexchange.com/questions/9954/why-is-my-variable-local-in-one-while-read-loop-but-not-in-another-seemingly
echo ""
echo "Cookie found:"
echo "$cookie"
echo "Running: heroku config:set CSETFORETELL_COOKIE='\$cookie'"
heroku config:set CSETFORETELL_COOKIE="$cookie"
;;
"1" )
echo "Platform: Good Judgment Open"
echo "Copy request headers from https://www.gjopen.com/questions/"
firefox "https://www.gjopen.com/questions/"
echo "Copy the request headers to clipboard"
read -p "Press any key when copied: " copied
cookie=$(xclip -selection c -o | {
while IFS= read -r line; do
if [[ "$line" == *"Cookie:"* ]]; then
#echo "Found cookie!"
# echo "$line"
cookie="$(echo $line |sed 's|Cookie: ||' )"
#echo "Cookie: $cookie"
fi
done
echo "$cookie"
}
)
echo ""
echo "Cookie found:"
echo "$cookie"
echo "Running: heroku config:set GOODJUDGMENTOPENCOOKIE='\$cookie'"
heroku config:set GOODJUDGMENTOPENCOOKIE="$cookie"
;;
* )
echo "Option not in {0,1}, exiting."
;;
esac