Comments (4)
Before the wall of text: I'll update the cards.js
file and push it to the CDN, but I wanted to document the fix (mostly for my own reference). This fix will be compatible will any/all new card updates to this file format.
Found a fix with:
awk '{gsub("\:[0-9999]*\,",":"NR",",$0);print}' < cards.js | sed -e "s/,$//g" | sed -e "s/$/,/g" | tac |awk '/a/ && !seen {sub(/,$/, ""); seen=1} 1' | tac > output.js
I boiled the file down a to one-line-per-card array, then ran it through this Mario-esque line of pipes. Here's the basic flow:
awk '{gsub("\:[0-9999]*\,",":"NR",",$0);print}' < cards.js
- This reads in the modified (and broken) cards.js
file, then substitutes any number 0-9999 with a colon, the line number, and a comma. Then the input is printed to stdout
.
| sed -e "s/,$//g" | sed -e "s/$/,/g"
- The output is then piped into sed
, then all commas at the end of each line are removed (or, rather, replaced with "", null). This output is then piped into another sed
command, this one, replacing each blank line-ending with a comma, then line ending.
| tac |awk '/a/ && !seen {sub(/,$/, ""); seen=1} 1' | tac > output.js
- The output from sed
is then piped into tac
(cat
backwards), the file is printed in reverse (by line number), and piped to awk
. awk
then removes the comma from the ending of the last line (again, replacing the comma-line-ending with line-ending), but only for the first item seen (which is the last line, because the file was fed into awk
in the reverse line order). The file is then run through tac
again to orient the line numbers correctly, and output to a file.
I'm sure there's a cleaner way to manage this, but it's a fast one liner for fixing these types of issues in the future.
from hangouts-against-humanity.
Not closed! Holy crap, this changed 'numAnswers' as well... Time to re-tool the script.
from hangouts-against-humanity.
Fixed the script:
awk '{gsub("\"id\"\:[0-9999]*\,","\"id\":"NR",",$0);print}' < cards.js | sed -e "s/,$//g" | sed -e "s/$/,/g" | tac |awk '/a/ && !seen {sub(/,$/, ""); seen=1} 1' | tac > output.js
It only matches the id
field now... Sorry about that. 😭
from hangouts-against-humanity.
Fixed here:
from hangouts-against-humanity.
Related Issues (20)
- HTML altcode in card HOT 2
- HTML altcode in card HOT 2
- Better 'Reset Game' button is needed HOT 3
- Card Czar after leaving HOT 1
- Shuffle Cards for Card Czar HOT 6
- Card Czar -> Your Cards
- Need Card Czar timeout HOT 2
- Card Loading HOT 9
- Card Czar Skipping
- Bad Card HOT 1
- Two "Two Girls" cards HOT 5
- "Rando Cardrissian" option HOT 1
- Infinite game length?
- UK Edition HOT 2
- Pack Selection Screen HOT 2
- Issues with new video hangouts
- Card Czar skipping HOT 2
- how does one use this code? it's unclear how to install it? HOT 1
- HTML altcode in card HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hangouts-against-humanity.