Skip to content

Instantly share code, notes, and snippets.

@ramene
Last active May 5, 2020 20:40
Show Gist options
  • Select an option

  • Save ramene/bdab47ba65d895156c40757ebfa259c1 to your computer and use it in GitHub Desktop.

Select an option

Save ramene/bdab47ba65d895156c40757ebfa259c1 to your computer and use it in GitHub Desktop.

Revisions

  1. ramene revised this gist May 5, 2020. No changes.
  2. ramene revised this gist May 4, 2020. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions to_gist_comp.py
    Original file line number Diff line number Diff line change
    @@ -12,9 +12,8 @@
    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()
    # 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))
    f.write('<style>{:s}</style>'.format(stylesheet))
  3. ramene revised this gist May 4, 2020. 1 changed file with 32 additions and 0 deletions.
    32 changes: 32 additions & 0 deletions to_gist_comp2.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    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)
  4. ramene revised this gist May 4, 2020. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions to_gist_comp.py
    Original file line number Diff line number Diff line change
    @@ -12,8 +12,7 @@
    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().decode()
    stylesheet = urlopen(gist['stylesheet']).read().encode('utf-8').decode()
    stylesheet = urlopen(gist['stylesheet']).read()

    with open('{:s}.vue'.format(COMPONENT_NAME), 'w') as f:
    f.write('<template>{:s}</template>'.format(html))
  5. ramene revised this gist May 4, 2020. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions to_gist_comp.py
    Original file line number Diff line number Diff line change
    @@ -13,8 +13,7 @@
    gist = json.loads(urlopen(gist_url).read())
    html = gist['div']
    # stylesheet = urlopen(gist['stylesheet']).read().decode()
    stylesheet = urlopen(gist['stylesheet']).read().encode().decode()

    stylesheet = urlopen(gist['stylesheet']).read().encode('utf-8').decode()

    with open('{:s}.vue'.format(COMPONENT_NAME), 'w') as f:
    f.write('<template>{:s}</template>'.format(html))
  6. ramene revised this gist May 4, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion to_gist_comp.py
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,9 @@
    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()
    # stylesheet = urlopen(gist['stylesheet']).read().decode()
    stylesheet = urlopen(gist['stylesheet']).read().encode().decode()


    with open('{:s}.vue'.format(COMPONENT_NAME), 'w') as f:
    f.write('<template>{:s}</template>'.format(html))
  7. ramene created this gist May 4, 2020.
    20 changes: 20 additions & 0 deletions to_gist_comp.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #!/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))
    f.write('<style>{:s}</style>'.format(stylesheet))