Search

散步道

@dddoriath

Author

樹水侍魂

北美信用卡相关

retention offer

Continue reading “北美信用卡相关”

Python thread

  • 每隔10s打开一次b站
  • 循环3次结束
import webbrowser
import time

total_breaks = 3
break_count = 0

print ("This program started on " + time.ctime())
while (break_count < total_breaks):
    time.sleep(10)
    webbrowser.open("bilibili.com")
    break_count = break_count + 1

  • 提取一个folder里的所有文件的文件名
  • 删除数字
import os

def rename_files():
    #(1) get file names from a folder
    file_list = os.listdir(r"C:\Users\Xiney\Desktop\prank")
    print (file_list)
    saved_path = os.getcwd()
    print("Current Working Directory is" + saved_path)
    os.chdir(r"C:\Users\Xiney\Desktop\prank")

    #(2) for each file, rename filename
    for file_name in file_list:
        print ("Old Name - " + file_name)
        print ("New Name - " + file_name.translate(None, "0123456789"))
        os.rename(file_name, file_name.translate(None, "0123456789"))
    os.chdir(saved_path)

rename_files()

  • 画一个正方形
  • 向右旋转30度
  • 重复此动作一周

import turtle

def draw_square(some_turtle):
    i = 1
    while i <= 12:    
        for x in range (0,4):
            some_turtle.forward(100)
            some_turtle.right(90)            
        some_turtle.right (30)
        i += 1

def draw_art():
    window = turtle.Screen()
    window.bgcolor("red")

    brad = turtle.Turtle()
    draw_square(brad)
   
    window.exitonclick()

draw_art()

  • 画一个菱形
  • 向右旋转5度
  • 重复此动作一周

import turtle

def draw_square(some_turtle):

    for i in range (0,72):

        for x in range (0,2):
            some_turtle.forward(100)
            some_turtle.right(60)
            some_turtle.forward(100)
            some_turtle.right(120)

        some_turtle.right(5)

def draw_art():
    window = turtle.Screen()
    window.bgcolor("grey")

    brad = turtle.Turtle()
    draw_square(brad)
   
    window.exitonclick()

draw_art()

square


  • 打开指定txt,提取内容
  • 利用Google的what do I love检查脏字
  • {“response”: “true”}则代表有脏字

import urllib

def read_text():

    quotes = open("/Users/geniuswxy/Desktop/checktext.rtf")
    contents_of_file = quotes.read()
    print (contents_of_file)
    quotes.close()
    check_profanity(contents_of_file)
    
def check_profanity(text_to_check):
    connection = urllib.urlopen("http://www.wdyl.com/profanity?q="+text_to_check)
    output = connection.read()
    print(output)
    connection.close()
    
read_text()

 


Screen_Shot_2014_04_18_at_4_52_12_PM
  • media.py定义了Class movie
    • movie拥有__init__和show_trailer两个自带method
  • entertainment_center.py用来接受movie个体的不同属性
  • fresh_tomatoes.py生成html文件
import webbrowser

class Movie():
    def __init__(self, movie_title, movie_storyline, poster_image, trailer_youtube):
        self.title = movie_title
        self.storyline = movie_storyline
        self.poster_image_url = poster_image
        self.trailer_youtube_url = trailer_youtube

    def show_trailer(self):
        webbrowser.open(self.trailer_youtube_url)
import media
import fresh_tomatoes

toy_story = media.Movie("Toy Story", "If you love toys, you will love this movie!", "https://upload.wikimedia.org/wikipedia/en/1/13/Toy_Story.jpg", "https://www.youtube.com/watch?v=XSvTH668d50")

#print (toy_story.storyline)

avatar = media.Movie("Avatar", "Avatar 3D is the best 3D movie in the world!", "https://upload.wikimedia.org/wikipedia/en/b/b0/Avatar-Teaser-Poster.jpg", "https://www.youtube.com/watch?v=5PSNL1qE6VY")

#print (avatar.storyline)

spirited_away = media.Movie("Spirited Away", "Most famous Japanese Anime Movie", "https://upload.wikimedia.org/wikipedia/zh/thumb/6/61/Spirited_away.jpg/375px-Spirited_away.jpg", "https://www.youtube.com/watch?v=ByXuk9QqQkk")
#spirited_away.show_trailer()

movies = [toy_story, avatar, spirited_away]

fresh_tomatoes.open_movies_page(movies)

import webbrowser
import os
import re

# Styles and scripting for the page
main_page_head = '''
<head>
    <meta charset="utf-8">
    <title>Fresh Tomatoes!</title>

    <!-- Bootstrap 3 -->
    <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap-theme.min.css">
    <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
    <script src="https://netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
    <style type="text/css" media="screen">
        body {
            padding-top: 80px;
        }
        #trailer .modal-dialog {
            margin-top: 200px;
            width: 640px;
            height: 480px;
        }
        .hanging-close {
            position: absolute;
            top: -12px;
            right: -12px;
            z-index: 9001;
        }
        #trailer-video {
            width: 100%;
            height: 100%;
        }
        .movie-tile {
            margin-bottom: 20px;
            padding-top: 20px;
        }
        .movie-tile:hover {
            background-color: #EEE;
            cursor: pointer;
        }
        .scale-media {
            padding-bottom: 56.25%;
            position: relative;
        }
        .scale-media iframe {
            border: none;
            height: 100%;
            position: absolute;
            width: 100%;
            left: 0;
            top: 0;
            background-color: white;
        }
    </style>
    <script type="text/javascript" charset="utf-8">
        // Pause the video when the modal is closed
        $(document).on('click', '.hanging-close, .modal-backdrop, .modal', function (event) {
            // Remove the src so the player itself gets removed, as this is the only
            // reliable way to ensure the video stops playing in IE
            $("#trailer-video-container").empty();
        });
        // Start playing the video whenever the trailer modal is opened
        $(document).on('click', '.movie-tile', function (event) {
            var trailerYouTubeId = $(this).attr('data-trailer-youtube-id')
            var sourceUrl = 'http://www.youtube.com/embed/' + trailerYouTubeId + '?autoplay=1&html5=1';
            $("#trailer-video-container").empty().append($("<iframe></iframe>", {
              'id': 'trailer-video',
              'type': 'text-html',
              'src': sourceUrl,
              'frameborder': 0
            }));
        });
        // Animate in the movies when the page loads
        $(document).ready(function () {
          $('.movie-tile').hide().first().show("fast", function showNext() {
            $(this).next("div").show("fast", showNext);
          });
        });
    </script>
</head>
'''

# The main page layout and title bar
main_page_content = '''
<!DOCTYPE html>
<html lang="en">
  <body>
    <!-- Trailer Video Modal -->
    <div class="modal" id="trailer">
      <div class="modal-dialog">
        <div class="modal-content">
          <a href="#" class="hanging-close" data-dismiss="modal" aria-hidden="true">
            <img src="https://lh5.ggpht.com/v4-628SilF0HtHuHdu5EzxD7WRqOrrTIDi_MhEG6_qkNtUK5Wg7KPkofp_VJoF7RS2LhxwEFCO1ICHZlc-o_=s0#w=24&h=24"/>
          </a>
          <div class="scale-media" id="trailer-video-container">
          </div>
        </div>
      </div>
    </div>
    
    <!-- Main Page Content -->
    <div class="container">
      <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container">
          <div class="navbar-header">
            <a class="navbar-brand" href="#">Fresh Tomatoes Movie Trailers</a>
          </div>
        </div>
      </div>
    </div>
    <div class="container">
      {movie_tiles}
    </div>
  </body>
</html>
'''

# A single movie entry html template
movie_tile_content = '''
<div class="col-md-6 col-lg-4 movie-tile text-center" data-trailer-youtube-id="{trailer_youtube_id}" data-toggle="modal" data-target="#trailer">
    <img src="{poster_image_url}" width="220" height="342">
    <h2>{movie_title}</h2>
</div>
'''

def create_movie_tiles_content(movies):
    # The HTML content for this section of the page
    content = ''
    for movie in movies:
        # Extract the youtube ID from the url
        youtube_id_match = re.search(r'(?<=v=)[^&#]+', movie.trailer_youtube_url)
        youtube_id_match = youtube_id_match or re.search(r'(?<=be/)[^&#]+', movie.trailer_youtube_url)
        trailer_youtube_id = youtube_id_match.group(0) if youtube_id_match else None

        # Append the tile for the movie with its content filled in
        content += movie_tile_content.format(
            movie_title=movie.title,
            poster_image_url=movie.poster_image_url,
            trailer_youtube_id=trailer_youtube_id
        )
    return content

def open_movies_page(movies):
  # Create or overwrite the output file
  output_file = open('fresh_tomatoes.html', 'w')

  # Replace the placeholder for the movie tiles with the actual dynamically generated content
  rendered_content = main_page_content.format(movie_tiles=create_movie_tiles_content(movies))

  # Output the file
  output_file.write(main_page_head + rendered_content)
  output_file.close()

  # open the output file in the browser
  url = os.path.abspath(output_file.name)
  webbrowser.open('file://' + url, new=2) # open in a new tab, if possible

百度空间没了于是只好转战wordpress

今天洗澡的时候想了很多女权的事情。明明是生活中其实很少想到的话题,但是水冲着冲着倒是把一些细碎的片段连在了一起。就觉得这事情好像不是自己想的那么淡。

S就是我认为的典型的男权主义者。和他吃过几顿饭之后就知道了。和他共事的100%都是男人,唯一他的头头,Z老板是个女的他就觉得人家怎么怎么蠢,我也是有点醉。你也不看看你自己挑的那些男人是个什么水平,还有你自己是什么水平。吃饭换位让女性坐远,说养女朋友怎么怎么了,安心在家里不好偏要出去工作之类的。我每次听他的这些话都很气。

其次就是J了。表面上还好。但是介绍我从来不用姓名,他还觉得他的好朋友一直不知道我叫什么名字因为每次我出现他都是以“我女朋友”为title,呵呵你一脸好吗。我跟他提过无数回以后请说我的名字,而不是XX家的妹子。屡教不改。没有任何用。

这也是为什么我喜欢女性远大于男性。和同性在一起的时候,是很自然平等的感觉。而和男性在一起的时候,总有一种不是自我变小,就是对方刻意使我不变小的感觉。我并不是仇视男性这个群体。也没有说什么如果可以选择自己出生的性别我想当男性胜过女性。只是现实社会上对女性整个群体的态度实在是需要我们进行思考的。

为什么有些地方不让女性雇员升职加薪。有些地方过分注意女性的诉求以彰显自己的公平。有些实验室不招女学生,有些实验室招了女学生但是对她们的要求比男学生要低得多。这两者其实都是不对的。

真正的应该是没有这些规矩而让一个人作为一个人有它自己的选择。

女性只有靠实力在这个社会说话。于是晚婚晚育是最优选择。

今天Myra还转了一个根据美式期权的模式探讨婚姻的,还蛮有意思的一篇文章。已经在微信上分享了。总结就是你觉得自己是看涨的,那就不要早结婚,因为未来会有更好的选择。如果觉得自己开始看跌了,那就结婚吧。

PS 我其实一直是一个好胜的人,虽然不常表现出来but I know it.

China’s iPhone (6, 6plus, 5s) is most expensive among US, HK and Japan (charts)

I did a quick research today to see the actual iPhone price difference among four countries (area): mainland China, Japan, Hong Kong and US. I was amazed how big the difference is. The chart below shows that for a 128GB iPhone 6 plus, Chinese customers pay $246 (1514 yuan) more than US customers.

Reasons behind Apple’s international pricing strategy may be:

  1. Chinese customers are willing to pay more for an iPhone (and there are plenty wealth people)
  2. iPhone doesn’t have to be cheap to attract Chinese’s customers
  3. The newest model gets the highest price difference. i.e. for 16GB iPhone5S, the difference between China and US is the lowest ($140)
  4. Apple’s contract phone policy with its partner wireless carriers generate sales income to compensate relatively cheaper phone price

P4

(The difference may vary according to currency exchange rate)

Click “read more” to see detailed analysis

Continue reading “China’s iPhone (6, 6plus, 5s) is most expensive among US, HK and Japan (charts)”

Create a free website or blog at WordPress.com.

Up ↑