Last active
May 5, 2020 20:40
-
-
Save ramene/bdab47ba65d895156c40757ebfa259c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
try: | |
from urllib.request import urlopen | |
except ImportError: | |
from urllib2 import urlopen | |
import json | |
import sys | |
# Modify COMPONENT_NAME to name your component differently. | |
COMPONENT_NAME = 'Gist' | |
gist_url = 'https://gist.github.com/{:s}.json'.format(sys.argv[1]) | |
gist = json.loads(urlopen(gist_url).read()) | |
html = gist['div'] | |
# stylesheet = urlopen(gist['stylesheet']).read() | |
with open('{:s}.vue'.format(COMPONENT_NAME), 'w') as f: | |
f.write('<template>{:s}</template>'.format(html)) | |
f.write("<script>export default {{ name: '{:s}' }}</script>".format(COMPONENT_NAME)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
import json | |
import datetime | |
import time | |
token = "YOUR_TOKEN" | |
access_url = "https://api.github.com/gists" | |
filename = "file.txt" | |
description = "the description for this gist" | |
public = "true" | |
information = "some info" | |
date = datetime.date.today() | |
current_time = time.strftime("%H:%M:%S") | |
data = """{ | |
"description": "%s", | |
"public": %s, | |
"files": { | |
"%s": { | |
"content": "info : %s,date: %s, current_time: %s" | |
} | |
} | |
}""" | |
json_data = data % (description, public, filename, information, date, current_time) | |
req = urllib2.Request(access_url) | |
req.add_header("Authorization", "token {}".format(token)) | |
req.add_header("Content-Type", "application/json") | |
urllib2.urlopen(req, data=json_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/nickwu241/vue-static-gist-example
python <(curl https://raw.githubusercontent.com/nickwu241/vue-static-gist-example/master/to_gist_comp.py) <user>/<gist_id>