Skip to content

Instantly share code, notes, and snippets.

@maestrith
Created July 19, 2013 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save maestrith/6040555 to your computer and use it in GitHub Desktop.
Save maestrith/6040555 to your computer and use it in GitHub Desktop.
Posted using AHK Studio
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
post_gist(info,access_token,filename,desc)
return
post_gist(info,access_token,filename,desc){
info:=RegExReplace(info,"([" Chr(34) "\\])","\$1")
for a,b in {"`n":"\n","`t":"\t","`r":""}
StringReplace,info,info,%a%,%b%,All
http:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
json=
(
{"description":"%desc%","public":true,"files":{"%filename%":{"content":"%info%"}}}
)
http.Open("POST","https://api.github.com/gists")
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
MsgBox,URL Coppied to clipboard
else
MsgBox,Something went wrong. Here is what the server sent back`n`n%codes%
run, % url
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment