Skip to content

Instantly share code, notes, and snippets.

@judy2k
Created March 26, 2013 15:55
Show Gist options
  • Select an option

  • Save judy2k/5246544 to your computer and use it in GitHub Desktop.

Select an option

Save judy2k/5246544 to your computer and use it in GitHub Desktop.
The hackiest script in the world - anything that looks like an int in the input, replace with double its value and output to stdout. Use as follows (on OSX): 1. Copy the json data you want to double from your IDE 2. pbcopy | ./double.py | pbpaste 3. Paste the new json with all the numbers doubled back into your IDE
#!/usr/bin/env python
import re
import sys
def rep(sval):
return str(int(sval.group()) * 2)
if __name__ == '__main__':
print re.sub(r'\d+', rep, sys.stdin.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment