【社会万象】《莫泊桑 社会小说》

基本信息:

书名:莫泊桑 社会小说 

作者:莫泊桑(法国)

译者:郭宏安

出版社:上海文艺出版社 2012年4月第一版

ISBN 978-7-5321-4369-6/I·3384

丛书:新文艺 外国文学大师读本

    

<听说的关于莫泊桑的简评>所谓“迷人”,指的是阅读时的愉悦,思考时的痛苦,因为莫泊桑的小说世界是一个痛苦多,欢乐少,笼罩着一片悲观主义的凉雾世界。“其境过清,不可久居”,久居则有“凄神寒骨”之虞。

1.羊脂球

     羊脂球一直在哭,有时候在两节歌声之间,黑暗里送出一声呜咽,那是她没能忍住的一声悲啼。

2.菲菲小姐

3.两个朋友

     “只要世界上还有政府,这种情况就永远不会改变。”

     “有了国王,我们就要同外国打仗;有了共和国,我们就要打内仗。”

     人类永远不能得到自由。

4.索瓦热老婆婆

     简介:一位老婆婆和四位敌国兵的爱恨交织,结局是老婆婆在得知自己的儿子死在战场之后,决心烧死在自己家里居住的四位年轻的敌国的士兵。故事发生在老婆婆居住的村子被敌军占领之后。

     一种失之交臂的幸福感觉。

    因为乡下人米有什么爱国心激起的仇恨;那只有上层阶级的人才有。

    “为了报复,德国人才把我的那座城堡毁掉。”可是我这时候却在想那四个烧死在这座茅屋里的善良的小伙子的母亲,想另一位被杀在这堵墙边的母亲的残忍的英勇行为。我捡起来一块小石头,上面还留着被火燎过的黑颜色。

5.我的叔叔于勒

     ……这个可怜的人,这时候总做出一个手势,叫我看了心里十分难过。他总是张开了手摸一下额头,好像要抹去根本不存在的汗珠,并且总是一句话也不回答。

     行为的好坏,只有结果才能决定。

     在有钱人的家里,一个人吃喝玩乐,无非算是糊涂荒唐。大家笑嘻嘻地称呼他一声花花公子。在生活困难的家庭里,一个人要是逼得父母动老本,那他就是一个坏蛋,一个流氓,一个无赖了。<ps:这句话被一位朋友反驳:这句话有偷换概念之嫌,因为在有钱人的家里,一个人要是逼得父母动老本,那他就是败家子,不仅仅是糊涂荒唐这么简单了。>

6.项链

     <关于虚荣>她很虚荣,但是她很美丽;她快乐地忘乎所以,也彬彬有礼。可她为什么选择了他?害了自己,也害了他。>现实中有种生活叫“门当户对”,也有蒂凡尼的早餐。

7.图瓦

      “怎么样,图瓦老爹,红焖第一口鸡的时候可得请我啊,请不请?”   “当然得请你,我的姑爷。” (图瓦老爹喜欢见谁都叫姑爷,这鸡是图瓦老爹自己在被子里孵出来的,他就像这些小鸡的母亲)

8.港口

9.上校的意义

10.模特儿

     画家在妻子的车旁默默走着,一小时以来,他们之间连一句话也没有交谈过。<错误>

<完>

jboss-eap-6.2 JNDI配置数据源Oracle&sql server

jboss-eap-6.2 JNDI配置数据源Oracle&sql server

  • Oracle数据源
  1. 创建模块,jboss-eap-6.2\modules\system\layers\base目录下,创建目录com\oracle\main
  2. 拷贝ojdbc14-10.2.0.4.0.jar和module.xml

module.xml

<?xml version="1.0" encoding="UTF-8"?>  
<module xmlns="urn:jboss:module:1.1" name="com.oracle">  
    <properties>  
        <property name="jboss.api" value="public"/>  
    </properties>  
    <resources>  
        <resource-root path="ojdbc14-10.2.0.4.0.jar"/>  
        <!-- Insert resources here -->  
    </resources>  
    <dependencies>  
        <module name="javax.api"/>  
        <module name="javax.transaction.api"/>  
        <module name="javax.servlet.api" optional="true"/>  
    </dependencies>  
</module>  
  1. 修改jboss-eap-6.2\standalone\configuration\standalone.xml

standalone.xml

<datasource jta="true" jndi-name="java:jboss/datasources/OracleDS" pool-name="OracleDS" enabled="true" use-java-context="true">
    <connection-url>jdbc:oracle:thin:@127.0.0.1:1521:ORCL</connection-url>
    <driver>oracle</driver>
    <pool>
        <prefill>false</prefill>
        <use-strict-min>false</use-strict-min>
        <flush-strategy>FailingConnectionOnly</flush-strategy>
    </pool>
    <security>
        <user-name>rick</user-name>
        <password>jkxyx205</password>
    </security>
</datasource>
<driver name="oracle" module="com.oracle">
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
</driver>
  • sql server数据源同上,仅给出配置文件sql server

module.xml

<?xml version="1.0" encoding="UTF-8"?>  
<module xmlns="urn:jboss:module:1.1" name="com.microsoft.sqlserver.jdbc">  
    <properties>  
        <property name="jboss.api" value="public"/>  
    </properties>  
    <resources>  
        <resource-root path="sqljdbc4.jar"/>  
        <!-- Insert resources here -->  
    </resources>  
    <dependencies>  
        <module name="javax.api"/>  
        <module name="javax.transaction.api"/>  
        <module name="javax.servlet.api" optional="true"/>  
    </dependencies>  
</module>  
<driver name="sqlserver" module="com.microsoft.sqlserver.jdbc">
    <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
</driver>
  • 注意点模块下包的结构和name对应起来

  • Spring使用JNDI数据源

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd


http://www.springframework.org/schema/aop


http://www.springframework.org/schema/aop/spring-aop.xsd


http://www.springframework.org/schema/tx


http://www.springframework.org/schema/tx/spring-tx.xsd


http://www.springframework.org/schema/context


http://www.springframework.org/schema/context/spring-context.xsd

    http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
    ">

   <jee:jndi-lookup id="myDataSource1" jndi-name="java:jboss/datasources/OracleDS" />
   <jee:jndi-lookup id="myDataSource2" jndi-name="java:jboss/datasources/MssqlDS" />
</beans>
  • 控制台查看数据源

http://127.0.0.1:9990

如果无法进入控制台,需要配置用户和组,执行jboss-eap-6.2\bin\add-user.bat,按照提示执行。

http://xhope.top/wp-content/uploads/2016/02/1.jpg

uwsgi部署Django

uwsgi部署Django

此处省去安装Django的步骤,可以参考Django初体验

项目开发

  • 创建项目
cd /var/www/
django-admin.py startproject xhope
cd /xhope

|-- xhope
|   |-- __init__.py
|   |-- settings.py
|   |-- urls.py
|   `-- wsgi.py
`-- manage.py

初始化目录如上所示。

  • 添加项目功能

a. 在settings.py添加模块blog,同时配置mysql数据库

b. 添加视图views.py

from django.http import HttpResponse
import json
from blog.models import wp_posts
from PyJSONSerialization import dump #别人写的插件 Object-->Json String
from django.shortcuts import render

def listPosts(request):

    request.encoding='utf-8'
    if 'post_title' in request.GET:
        post_title =  request.GET['post_title'].encode('utf-8')
    else:
        post_title = ''

    #print post_title
    posts = wp_posts.objects.filter(post_status='publish',post_type='post',post_title__contains='%s'%(post_title)).order_by("-id")

    '''
    print isinstance(posts, list)

    postsArr = [];
    for post in posts:
        postsArr.append(post)

    print dump(postsArr)
    '''
    context = {}
    context['posts'] = posts
    context['post_title'] = post_title
    return render(request, 'list.html', context)

c. 添加模型 models.py

from __future__ import unicode_literals
from django.db import models
import json

# Create your models here.
class wp_posts(models.Model):
    class Meta:
        db_table = "wp_posts"

    post_date = models.DateField
    post_title = models.CharField(max_length=20)
    post_status = models.CharField(max_length=20)
    post_type = models.CharField(max_length=20)

    id = models.AutoField

d. 配置访问路径urls.py

from django.conf.urls import *
from blog.views import listPosts

urlpatterns = patterns("",
    ('^listPosts/$', listPosts),
)

f. 模板文件 list.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>list</title>
    <style>
        ul, li {
            border: 0;
            margin: 0;
            padding:0;
        }

        li {
            font-size: 13px;
            font-family: "黑体";
            padding: 2px;
        }
    </style>
</head>
<body>
    <form action="http://121.42.151.190:8000/listPosts/">
        <input type="text" name="post_title" value="{{post_title}}" /><button>查询</button>
    </form>

    <ul>
        {% for post in posts %}
        <li>{{ post.post_title }}</li>
        {% endfor %}
    </ul>
</body>
</html>

测试运行

python manage.py runserver 0.0.0.0:8000

访问地址:http://121.42.151.190:8000/listPosts

uWSGI部署Django

uwsgi --http :8000 --chdir /var/www/xhope/ --wsgi-file /var/www/xhope/xhope/wsgi.py --daemonize=/var/www/xhope/uwsgi9090.log

访问地址:http://121.42.151.190:8000/listPosts

Django Nginx+uwsgi 安装配置 参照http://www.runoob.com/django/django-nginx-uwsgi.html
但我一直没有执行成功过。

The android.os.NetworkOnMainThreadException exception

The android.os.NetworkOnMainThreadException exception

Android与Web Server交换数据 碰到异常The android.os.NetworkOnMainThreadException exception

原始代码

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        myBtn = (Button) this.findViewById(R.id.myBtn);
        myText = (TextView) this.findViewById(R.id.myText);

        myBtn.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {                        
                HttpClient client = new DefaultHttpClient();
                HttpGet request = new HttpGet("http://localhost:8080/data.jsp");
                HttpResponse response;
                try {
                    response = client.execute(request);
                    // Get the response
                    BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
                    StringBuilder textView = new StringBuilder();

                    String line = "";
                    while ((line = rd.readLine()) != null) {
                        textView.append(line);
                    }
                    myText.setText(textView); //使用远程数据
                } catch (ClientProtocolException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
    }

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

     <Button 
        android:id="@+id/myBtn"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Click Me" />

     <TextView
        android:id="@+id/myText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Hello Rick!!!" />

</LinearLayout>

启动本地Tomcat,访问地址:http://localhost:8080/data.jsp
data.jsp

Hello Android!!!!

<%
    System.out.println("Request from client!!!");
%>

期望:点击按钮“Click Me”,TextView由 “Hello Rick!!!” —> “Hello Android!!!!”,万万没想到,抛出了异常!!!

Google到解决方案http://www.lucazanini.eu/en/2012/android/the-android-os-networkonmainthreadexception-exception/

加权限,同时加了代码。
改动如下:

AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET"/>

Activity.java

StrictMode.ThreadPolicy policy = new
                StrictMode.ThreadPolicy.Builder()
                .permitAll().build();
                StrictMode.setThreadPolicy(policy);

结果后台没有抛出异常,但是没有任何反应,这个纠结了很久。。。。
后来发现: http://localhost:8080/data.jsp,不能使用localhost和127.0.0.1
只能使用机器内网IP:192.168.1.106,然后成功了。
解决地址:http://stackoverflow.com/questions/5495534/java-net-connectexception-localhost-127-0-0-18080-connection-refused

测试结果

http://xhope.top/wp-content/uploads/2016/01/Video_2016-01-30_230438.gif

Django初体验

Django初体验

教程:http://www.runoob.com/django/django-tutorial.html

省略安装过程

Python下有许多款不同的 Web 框架。Django是重量级选手中最有代表性的一位。许多成功的网站和APP都基于Django。
Django是一个开放源代码的Web应用框架,由Python写成。
Django遵守BSD版权,初次发布于2005年7月, 并于2008年9月发布了第一个正式版本1.0 。
Django采用了MVC的软件设计模式,即模型M,视图V和控制器C。
  1. 创建工程
django-admin startproject mysite

生成目录结构

    |-mysite
        |-urls.py
        |-settings.py
        |-wsgi.py
        |-__init__.py
     |-manage.py   

启动服务

D:\workspace\mysite>python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
December 27, 2015 - 21:27:18
Django version 1.9, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
  1. 添加模块
django startapp blog

生成目录结构

    |-blog
        |-__init__.py
        |-admin.py
        |-apps.py
        |-models.py
        |-tests.py
        |-view.py
    |-mysite
        |-urls.py
        |-settings.py
        |-wsgi.py
        |-__init__.py
     |-manage.py   

a. 配置模块 settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'blog'
]

b. 配置数据库

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'rtest',
        'USER': 'rick',
        'PASSWORD': 'jkxyx@05',
        'HOST':'192.168.1.105',
        'PORT':'3306',
    }
}

c. 添加模板文件夹

'DIRS': [BASE_DIR+"/templates"],
  1. 编写blog模块

a. 创建实体类Article
models.py

from __future__ import unicode_literals
from django.db import models
# Create your models here.

class Article(models.Model):
    title = models.CharField(max_length=20)
    author = models.CharField(max_length=20)
    content = models.CharField(max_length=20)

执行脚本自动创建数据库

D:\workspace\mysite>python manage.py makemigrations
No changes detected
D:\workspace\mysite>python manage.py migrate
Operations to perform:
  Apply all migrations: admin, blog, contenttypes, auth, sessions
Running migrations:
  Rendering model states... DONE
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying blog.0001_initial... OK
  Applying sessions.0001_initial... OK

b. 创建视图
views.py

from django.shortcuts import render
from django.http import HttpResponse
from blog.models import Article

def hello(request):

    list = Article.objects.all()
    #print list
    #for art in list:
    #    print art.title
    context = {}
    context['object_list'] = list
    return render(request, 'hello.html', context)

hello.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>hello</title>
</head>
<body>
    <h2>book list</h2>
    <ul>
    {% for article in object_list %}
        <li>{{ article.author }} - {{ article.title }}</li>
    {% endfor %}
    </ul>
</body>
</html>

urls.py

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^hello/', hello),
]

数据库插入测试数据
http://xhope.top/wp-content/uploads/2015/12/11.png

访问地址:http://127.0.0.1:8000/hello/
http://xhope.top/wp-content/uploads/2015/12/2.png