月度归档:2016年03月

阿里云ECS python pip安装组件失败解决办法

Published / by sickworm / Leave a Comment

最近使用阿里云写一些python服务,pip安装的时候经常出现下面情况:

Downloading/unpacking uwsgi
  Cannot fetch index base URL https://pypi.python.org/simple/
  Could not find any downloads that satisfy the requirement uwsgi
Cleaning up...
No distributions at all found for uwsgi
Storing debug log for failure in /home/sickworm/.pip/pip.log

解决办法是:

多试几次。

连续执行两次,第一次失败,第二次成功。或你可以试试删除个人目录下的.pip文件夹。

版权所有,转载请注明出处:

http://sickworm.com/?p=130

Worpress中使用JetPack的MarkDown功能测试

Published / by sickworm / Leave a Comment

内容为Mou软件示例,Mou是一款Mac的MarkDown软件,支持即时预览,Mou预览版免费。JetPack不支持即时预览,建议使用Mou编辑完成后再上传到WordPress。(注意Web版应在“文本”中编辑,而不是在“可视化”中编辑,否则会有格式转换的问题,如代码缩进)

MarkDown和Crayon协同工作参考此处

Mou

Mou icon

Overview

Mou, the missing Markdown editor for web developers.

Syntax

Strong and Emphasize

strong or strong ( Cmd + B )

emphasize or emphasize ( Cmd + I )

Sometimes I want a lot of text to be bold.
Like, seriously, a LOT of text

Blockquotes

Right angle brackets > are used for block quotes.

Links and Email

An email example@example.com link.

Simple inline link http://chenluois.com, another inline link Smaller, one more inline link with title Resize.

A reference style link. Input id, then anywhere in the doc, define the link with corresponding id:

Titles ( or called tool tips ) in the links are optional.

Images

An inline image Smaller icon, title is optional.

A Resize icon reference style image.

Inline code and Block code

Inline code are surround by backtick key. To create a block code:

Indent each line by at least 1 tab, or 4 spaces.
var Mou = exactlyTheAppIwant; 

Ordered Lists

Ordered lists are created using “1.” + Space:

  1. Ordered list item
  2. Ordered list item
  3. Ordered list item

Unordered Lists

Unordered list are created using “*” + Space:

  • Unordered list item
  • Unordered list item
  • Unordered list item

Or using “-” + Space:

  • Unordered list item
  • Unordered list item
  • Unordered list item

Hard Linebreak

End a line with two or more spaces will create a hard linebreak, called <br /> in HTML. ( Control + Return )
Above line ended with 2 spaces.

Horizontal Rules

Three or more asterisks or dashes:




Headers

Setext-style:

This is H1

This is H2

atx-style:

This is H1

This is H2

This is H3

This is H4

This is H5
This is H6

Extra Syntax

Footnotes

Footnotes work mostly like reference-style links. A footnote is made of two things: a marker in the text that will become a superscript number; a footnote definition that will be placed in a list of footnotes at the end of the document. A footnote looks like this:

That’s some text with a footnote.1

Strikethrough

Wrap with 2 tilde characters:

~~Strikethrough~~

Fenced Code Blocks

Start with a line containing 3 or more backticks, and ends with the first line with the same number of backticks:

Fenced code blocks are like Stardard Markdown’s regular code
blocks, except that they’re not indented and instead rely on
a start and end fence lines to delimit the code block.

Tables

A simple table looks like this:

First Header Second Header Third Header
Content Cell Content Cell Content Cell
Content Cell Content Cell Content Cell

If you wish, you can add a leading and tailing pipe to each line of the table:

First Header Second Header Third Header
Content Cell Content Cell Content Cell
Content Cell Content Cell Content Cell

Specify alignment for each column by adding colons to separator lines:

First Header Second Header Third Header
Left Center Right
Left Center Right

Shortcuts

View

  • Toggle live preview: Shift + Cmd + I
  • Toggle Words Counter: Shift + Cmd + W
  • Toggle Transparent: Shift + Cmd + T
  • Toggle Floating: Shift + Cmd + F
  • Left/Right = 1/1: Cmd + 0
  • Left/Right = 3/1: Cmd + +
  • Left/Right = 1/3: Cmd + –
  • Toggle Writing orientation: Cmd + L
  • Toggle fullscreen: Control + Cmd + F

Actions

  • Copy HTML: Option + Cmd + C
  • Strong: Select text, Cmd + B
  • Emphasize: Select text, Cmd + I
  • Inline Code: Select text, Cmd + K
  • Strikethrough: Select text, Cmd + U
  • Link: Select text, Control + Shift + L
  • Image: Select text, Control + Shift + I
  • Select Word: Control + Option + W
  • Select Line: Shift + Cmd + L
  • Select All: Cmd + A
  • Deselect All: Cmd + D
  • Convert to Uppercase: Select text, Control + U
  • Convert to Lowercase: Select text, Control + Shift + U
  • Convert to Titlecase: Select text, Control + Option + U
  • Convert to List: Select lines, Control + L
  • Convert to Blockquote: Select lines, Control + Q
  • Convert to H1: Cmd + 1
  • Convert to H2: Cmd + 2
  • Convert to H3: Cmd + 3
  • Convert to H4: Cmd + 4
  • Convert to H5: Cmd + 5
  • Convert to H6: Cmd + 6
  • Convert Spaces to Tabs: Control + [
  • Convert Tabs to Spaces: Control + ]
  • Insert Current Date: Control + Shift + 1
  • Insert Current Time: Control + Shift + 2
  • Insert entity <: Control + Shift + ,
  • Insert entity >: Control + Shift + .
  • Insert entity &: Control + Shift + 7
  • Insert entity Space: Control + Shift + Space
  • Insert Scriptogr.am Header: Control + Shift + G
  • Shift Line Left: Select lines, Cmd + [
  • Shift Line Right: Select lines, Cmd + ]
  • New Line: Cmd + Return
  • Comment: Cmd + /
  • Hard Linebreak: Control + Return

Edit

  • Auto complete current word: Esc
  • Find: Cmd + F
  • Close find bar: Esc

Post

  • Post on Scriptogr.am: Control + Shift + S
  • Post on Tumblr: Control + Shift + T

Export

  • Export HTML: Option + Cmd + E
  • Export PDF: Option + Cmd + P

And more?

Don’t forget to check Preferences, lots of useful options are there.

Follow @Mou on Twitter for the latest news.

For feedback, use the menu HelpSend Feedback

Crayon高亮测试:

Crayon内置插件

@app.route('/' + test_entry_key, methods = ['GET'])
def test_entry():
    cmd = request.args.get('cmd')
    if not cmd:
        abort(401)

    if cmd == '1':
        if funda.update_funda() != ERROR_OK:
            return make_response('error')
        prased_funda_list, update_time = funda.get_funda()
        return make_response(str(update_time) + '<br>' + str(prased_funda_list))
    elif cmd == '2':
        strategy.do_strategy_and_push()
        return make_response(strategy.details)
    elif cmd == '3':
        mysql.connect()
        ret, user_sql = mysql.select_user(user_id = 'C4737E88-DE87-4D90-9C34-1A6725187254')
        mysql.disconnect()
        server_sync_time = user_sql[0][6]
        return make_response(str(server_sync_time))
    else:
        abort(401)

Mardown

@app.route('/' + test_entry_key, methods = ['GET'])
def test_entry():
    cmd = request.args.get('cmd')
    if not cmd:
        abort(401)

    if cmd == '1':
        if funda.update_funda() != ERROR_OK:
            return make_response('error')
        prased_funda_list, update_time = funda.get_funda()
        return make_response(str(update_time) + '<br>' + str(prased_funda_list))
    elif cmd == '2':
        strategy.do_strategy_and_push()
        return make_response(strategy.details)
    elif cmd == '3':
        mysql.connect()
        ret, user_sql = mysql.select_user(user_id = 'C4737E88-DE87-4D90-9C34-1A6725187254')
        mysql.disconnect()
        server_sync_time = user_sql[0][6]
        return make_response(str(server_sync_time))
    else:
        abort(401)

此处如果把内容复制到“可视化”中,缩进会消失。Markdown文本应在“文本”中编辑。

版权所有,转载请注明出处:
http://sickworm.com/?p=93


  1. And that’s the footnote. 

在ToolBar上创建菜单

Published / by sickworm / Leave a Comment

好久没写过界面了,最近用最新的支援库,官方建议AppBar+ToolBar代替原ActionBar。然后翻了一下怎么往ToolBar上创建按钮,翻了半天没一个可以。。。最后发现把onCreateOptionsMenu丢了(网上的大爷们这么默契,全部都把这部分代码忽略掉真的好吗)。附上ToolBar上创建菜单的方法。

Activity中写入:

(XML方式)

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_check, menu);
    return true;
}

 

menu_check.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".CheckActivity">

    <item android:id="@+id/action_controller"
        android:title="@string/start"
        android:orderInCategory="90"
        app:showAsAction="always|withText" />
</menu>
或:
(代码方式)
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(Menu.NONE, Menu.FIRST + 1, 1, "设置")
        .setIcon( android.R.drawable.ic_menu_help)
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    return true;
}

菜单会显示在ToolBar右上角。setShowAsAction相当xml中的app:showAsAction。withText作用是把菜单的文字显示出来,如果想仅显示文字,不设置icon即可。

然后在onOptionsItemSelected中处理点击事件:

    @Override  
    public boolean onOptionsItemSelected(MenuItem item) {
        switch(item.getItemId()){  
           case R.id.action_controller: // XML方式
               Toast.makeText(MainActivity.this, "设置1", Toast.LENGTH_SHORT).show();  
               break;  
           case Menu.FIRST + 1: // Java代码方式,仅作示例,两种方法不应混用
               Toast.makeText(MainActivity.this, "设置2", Toast.LENGTH_SHORT).show();  
               break;  
           } 

        return super.onOptionsItemSelected(item);  
    }  

版权所有,转载请注明出处:

http://sickworm.com/?p=76