oauth-github

Posted by 夏泽民


github-openapi

Posted by 夏泽民

github openapi 学习



github-api

Posted by 夏泽民

curl -d “json_data={ owner: ‘xiazemin’, repo: ‘MyBlogComment’, oauth: { client_id: ‘981ba8c916c262631ea0’, client_secret: ‘a52260ef92de69011ccd1cf355b973ef11d6da0e’, }” https://github.com/xiazemin/MyBlogComment/issues/33 直接curl 授权成功 curl -u xiazemin:xxxxxxxxxxx https://api.github.com/repos/xiazemin/MyBlogComment/issues/33/comments curl -H “Authorization: token xxxxxxxxxxx” https://api.github.com/repos/xiazemin/MyBlogComment/issues/33/comments 自己请求不成功



Authorization-ajax

Posted by 夏泽民

Get Github Authorization Token with proper scope,print to console

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$.ajax({
url: 'https://api.github.com/authorizations',
type: 'POST',
beforeSend: function(xhr) {
 	xhr.setRequestHeader("Authorization",
 	"Basic" + btoa("USERNAME:PASSWORD"));
},
data: '{"scopes":["gist"],"note":"ajax gist test for a user"}'
}).done(function(response) {
 	console.log(response);
});
//Create a Gist with token from above
$.ajax({
url:'https://api.github.com/gists',
type:'POST',
beforeSend: function(xhr) {
 	xhr.setRequestHeader("Authorization",
 	"token TOKEN-FROM-AUTHORIZATION-CALL");
 	},
data: '{"description": "a gist for a user with token api call via ajax","public": true,"files": {"file1.txt": {"content": "String file contents via ajax"}}}'
}).done(function(response) {
 	console.log(response);
});


自动化替换网站引用资源到本地工具

Posted by 夏泽民
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
clear
function replace(){
urlT=${1//\//\\\/}
echo $urlT
}
function replaceDot(){
urlT=${1//\./\\\.}
echo $urlT
}
echo '' > temp.txt
grep  -nrEo  "\<a.*\>|\<script.*\>|\<link.*\>" ./ |grep -E "href=\"http|src=\"http|href=\'http|src=\'http" |grep -v github |grep -v disqus |grep -v 'wb.js' |awk -F ' ' '{for(i=1;i<=NF;i++){split($i,x,"\""); if(x[1]=="src="){print x[2];} }}' >> temp.txt
urls=` sort -u temp.txt |grep js `
for url in $urls
do 
fileCmd=` echo $url |awk -F '/' '{print "curl -o ./js/"$NF " " $0 "\n" }' `
echo $fileCmd
$fileCmd
done
for url in $urls
do
 newUrl=`  echo $url |awk -F '/' '{print "/MyBlog/js/"$NF }' `
echo $url
echo $newUrl
files=` grep $url .  -rl |grep -v "_site" |grep -v "temp" |sort -u `
for file in $files
do
echo $file
urlT=` replace $url `
urlT=` replaceDot $urlT `
newUrlT=` replace $newUrl `
cmd=` echo " sed -i 'temp.bak' 's/$urlT/$newUrlT/' $file" `
echo $cmd |bash
echo $cmd
$file `
done 
done


Search

Popular posts

Anything in here will be replaced on browsers that support the canvas element

Recent posts

This blog is maintained by 夏泽民

Get in touch with me at 465474307@qq.com

Subscribe to our mailing list

* indicates required