Skip to content

Instantly share code, notes, and snippets.

@nguyenhoaibao
Last active September 28, 2020 04:38
Show Gist options
  • Save nguyenhoaibao/d9ee22f3e1a6e6c22c8b01f514ccafb2 to your computer and use it in GitHub Desktop.
Save nguyenhoaibao/d9ee22f3e1a6e6c22c8b01f514ccafb2 to your computer and use it in GitHub Desktop.
Convert currencies object to Go switch case

Currencies from this: https://gist.github.com/Fluidbyte/2973986

Vim regex:

  • %s/"\([A-Z]\+\)":\s{\n\s*"symbol":\s\(.\+\),/case \2:\r\treturn \1/g
  • g/name\|symbol\|decimal\|rounding\|code\|}/d

  • Regex:
  1. vim: %s/.*=\s\([0-9]\+\);/\1,/g
  2. sed: sed -i 's/.\+\s=\s\([0-9]\+\);/\1,/g' <file>
  • Input:
UPDATE schools SET point = POINT(10.806061,106.7293748) WHERE school_id = 1;
UPDATE schools SET point = POINT(10.7896527,106.699409) WHERE school_id = 2;
...
  • Output:
1,
2,
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment