Skip to content

Commit

Permalink
黄哥Python培训
Browse files Browse the repository at this point in the history
  • Loading branch information
likepython committed Jan 11, 2017
1 parent a9ab759 commit afd1ecb
Show file tree
Hide file tree
Showing 285 changed files with 43,963 additions and 1 deletion.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions ._recent_files/how_to_learn_python.md
1 change: 1 addition & 0 deletions ._recent_files/main-4.png
1 change: 1 addition & 0 deletions .media/.marboo_config.json
23 changes: 23 additions & 0 deletions .media/README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#+TITLE: Marboo Main Config
#+AUTHOR: amoblin
#+EMAIL: [email protected]
#+DATE: 2014-01-15 22:42:20
#+OPTIONS: ^:{}

* Supported files with:

- markdown
- reStructuredText
- Org-mode
- Textile
- txt2tag
- HTML
- zip

* Syntax Highlight for Code

* Extend Packages
** DONE Phot Gallery
CLOSED: [2014-05-19 Mon 22:59]


6 changes: 6 additions & 0 deletions .media/converts/alert.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
# author: amoblin <[email protected]>
# file name: alert.sh
# create date: 2013-02-03 15:48:48

cat "$1"
15 changes: 15 additions & 0 deletions .media/converts/audio2html.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
# author: amoblin <[email protected]>
# file name: audio2html.sh
# create date: 2014-06-26 14:42:23
# This file is created from $MARBOO_HOME/media/starts/default.sh
# 本文件由 $MARBOO_HOME/media/starts/default.sh 复制而来

name=`basename "$1"`
#tmp_file=/tmp/$name
echo "<h1>$name</h1>\
<div class=\"player\" style=\"margin-top:100px; text-align:center\">\n\
<audio controls=\"\" name=\"media\">\n \
<source src=\"$name\" type=\"audio/mpeg\">\n \
</audio>\n \
</div>"
17 changes: 17 additions & 0 deletions .media/converts/flash2html.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
# author: amoblin <[email protected]>
# file name: flash2html.sh
# description: TODO
# create date: 2015-02-18 13:55:37
# This file is created from $MARBOO_HOME/.media/starts/default.sh
# 本文件由 $MARBOO_HOME/.media/starts/default.sh 复制而来

name=`basename "$1"`
name_without_extension=`echo ${name%.*}`
#tmp_file=/tmp/$name
echo "<div style=\"text-align:center\">\n \
<h1>$name_without_extension</h1>\n \
<div style=\"margin-top:100px\">\n \
<embed height=\"500px\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" quality=\"high\" src=\"$name\" title=\"\" type=\"application/x-shockwave-flash\" width=\"700px\" />\n \
</div>\n \
</div>\n"
69 changes: 69 additions & 0 deletions .media/converts/ghost-publish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# author: amoblin <[email protected]>
# file name: ghost-publish.py
# create date: 2014-08-30 16:14:13
# This file is created from $MARBOO_HOME/media/starts/default.py
# 本文件由 $MARBOO_HOME/media/starts/default.py 复制而来

import sys
import json
import requests

USERNAME = "INPUT YOUR USER NAME"
PASSWORD = "INPUT YOUR PASSWORD"
HOST = "http://localhost:2368"

GHOST_API_PRE = "/ghost/api/v0.1"
GHOST_API_AUTH = "/authentication/token"
GHOST_API_POSTS = "/posts"

class Ghost:
def __init__(self):
self.s = requests.session()
self.get_access_token()

def get_full_url(self, path):
return "%s%s%s" % (HOST, GHOST_API_PRE, path)

def get_access_token(self):
params = {
"grant_type": "password",
"username": USERNAME,
"password": PASSWORD,
"client_id": "ghost-admin"
}

r = self.s.post(self.get_full_url(GHOST_API_AUTH), data=params)
response_dict = r.json()
self.access_token = response_dict["access_token"]
self.token_type = response_dict["token_type"]

def get_posts(self):
headers = {"Authorization": "%s %s" % (self.token_type, self.access_token)}
payload = {"limit": 10}
content = self.s.get(self.get_full_url(GHOST_API_POSTS), headers=headers, params=payload).json()
return content

def post_one(self, title, content):
headers = {"Authorization": "%s %s" % (self.token_type, self.access_token)}
# payload = {"object":{"title": title, "markdon": content, "author": USERNAME}, "options": "TBD"}
payload = {}

content = self.s.post(self.get_full_url(GHOST_API_POSTS), headers=headers, params=payload).json()
return content

if __name__ == "__main__":
if len(sys.argv) > 2:
USERNAME = sys.argv[1]
PASSWORD = sys.argv[2]

if len(USERNAME) == 0 or len(PASSWORD) == 0:
print("Arguments Error")
sys.exit(1)

ghost = Ghost()
for post in ghost.get_posts()["posts"]:
print post["title"]
print ghost.post_one("测试", "# 本文通过%s发送" % __file__)

10 changes: 10 additions & 0 deletions .media/converts/tar-list.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
# author: amoblin <[email protected]>
# file name: tar-list.sh
# create date: 2013-03-07 15:13:36
# This file is created from $MARBOO_HOME/media/starts/default.sh
# 本文件由 $MARBOO_HOME/media/starts/default.sh 复制而来

name=`basename "$1"`
echo "# ${name}"
tar tvf "$1"|sed 's/^/ /'
17 changes: 17 additions & 0 deletions .media/converts/video2html.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
# author: amoblin <[email protected]>
# file name: video2html.sh
# create date: 2014-07-06 06:37:27
# This file is created from $MARBOO_HOME/media/starts/default.sh
# 本文件由 $MARBOO_HOME/media/starts/default.sh 复制而来

name=`basename "$1"`
name_without_extension=`echo ${name%.*}`
#tmp_file=/tmp/$name
echo "<div style=\"text-align:center\">\n \
<h1>$name_without_extension</h1>\n \
<div class=\"player\" style=\"margin-top:100px\">\n\
<video controls=\"\" name=\"media\" width=\"80%\">\n \
<source src=\"$name\" type=\"video/mp4\">\n \
</video>\n \
</div>"
10 changes: 10 additions & 0 deletions .media/converts/zip-list.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
# author: amoblin <[email protected]>
# file name: zip-list.sh
# create date: 2013-03-01 11:27:53
# This file is created from $MARBOO_HOME/media/starts/default.sh
# 本文件由 $MARBOO_HOME/media/starts/default.sh 复制而来

name=`basename "$1"`
echo "# ${name}"
unzip -l "$1"|sed 's/^/ /'
5 changes: 5 additions & 0 deletions .media/css/bootstrap.min.css

Large diffs are not rendered by default.

Loading

0 comments on commit afd1ecb

Please sign in to comment.