Skip to content

Instantly share code, notes, and snippets.

@maestrith
Created July 19, 2013 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maestrith/6039549 to your computer and use it in GitHub Desktop.
Save maestrith/6039549 to your computer and use it in GitHub Desktop.
my description
url:="https://api.github.com/gists"
info:="Code to post goes here" ;Change this to create the new text for the Gist
access_token:="" ;Your Github access token goes here if you want to publish it to your Gist list
filename:="mygit.txt" ;change this to whatever you want your file name to be
desc:="my description" ;This is where you would have a description for your Gist
info:=RegExReplace(info,"([" Chr(34) "\\])","\$1")
StringReplace,info,info,`r,,All
StringReplace,info,info,`n,\n,All
StringReplace,info,info,`t,\t,All
http:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
json=
(
{"description":"%desc%","public":true,"files":{"%filename%":{"content":"%info%"}}}
)
http.Open("POST",url)
if access_token
http.SetRequestHeader("Authorization","Bearer " access_token)
http.send(json)
codes:=http.ResponseText
RegExMatch(codes,"U)html_url" Chr(34) ":" Chr(34) "(.*)" chr(34),found)
clipboard:=RegExReplace(found1,"\\")
if found1
m("URL Coppied to clipboard")
else
m("Something went wrong. Here is what the server sent back","","",codes)
return
m(x*){
for a,b in x
list.=b "`n"
MsgBox,% list
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment