• 开源镜像
  • 开源沙龙
  • 媛宝
  • 猿帅
  • 注册
  • 登录
  • 息壤开源生活方式平台
  • 加入我们

开源日报

  • 2018年3月31日:开源日报第23期

    31 3 月, 2018

    每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,欢迎关注开源日报。交流QQ群:202790710;电报群 https://t.me/OpeningSourceOrg


    今日推荐开源项目:《开源评论系统 ISSO》

    推荐理由:ISSO 是一个由 python 编写服务端的开源的轻量级评论系统,用来代替 Disqus. 从 git 记录来看该项目已经有近 4 年的历史,但是还在持续更新维护中。用户可以自己搭建和管理评论系统,网页评论端的样式可定制,可以和 Disqus 等一类评论系统一样轻松部署在自己的博客与网页当中,还能使用 Markdown 进行评论。

    安装使用

    在它的官网 https://posativ.org/isso/docs/extras/deployment/ 可以查看相关部署和使用文档,但是官网好像被墙了,不翻的话无法访问。网上有一些介绍如何部署安装的中文文档在此推荐 https://sb.sb/debian-8-ubuntu-16-04-install-isso/。安装的配置项还是比较多的,如果看了安装教程有感想的,也可以自己写一个自动安装部署脚本~,奈何小编有心但无时间啊。。。部署好服务端后,在网页端插入 js 脚本和相关 html 标签,UI 展示效果如下。纵观各类评论系统其实 UI 上长得都类似,因为就几个功能,发表评论、展示评论、回复等。

    开源项目精选: 开源评论系统 ISSO

    开源评论系统

    随着多说的下线, Disqus 在国内无法稳定使用,很多博主寻求稳定可靠的评论系统。因此很多开源的评论系统被挖掘和提及,在知乎上也有很多的讨论 https://www.zhihu.com/question/57426274。

    有 PHP 编写的 hashover, 有利用 github issue 来做评论系统的 gitment 等等。当然,您可以使用 WordPress 嘛,就不用操怎么多心了。


    今日推荐英文原文:《Train Your Machine Learning Models on Google’s GPUs for Free — Forever》作者:Nick Bourdakos

    原文链接:https://hackernoon.com/train-your-machine-learning-models-on-googles-gpus-for-free-forever-a41bd309d6ad

    推荐理由:如果你关心机器学习的话,可以试着上手这篇教程,大家都知道 Google 在机器学习领域耕耘颇深,站在巨人的肩膀上,自然能让你前行更快,而这篇文章就是带你在 Google GPU 上训练你的机器学习模型,记得,看完文章后,动手试一试哟。

    Train Your Machine Learning Models on Google’s GPUs for Free — Forever

    Training your model is hands down the most time consuming and expensive part of machine learning. Training your model on a GPU can give you speed gains close to 40x, taking 2 days and turning it into a few hours. However, this normally comes at a cost to your wallet.

    The other day I stumbled upon a great tool called Google Colab. I would describe Colab as the google docs equivalent of Jupyter notebooks. Colab is aimed at being an education and research tool for collaborating on machine learning projects. The great part is, that it’s completely free forever.

    There is no setup to use it. I didn’t even need to log in. (I was already logged into my google account)

    The best part is that you get an unlimited supply of 12 hours of continuous access to a k80 GPU, which is pretty powerful stuff. (You get disconnected after 12 hours, but you can use it as many times as you want)

    I want our focus to be training on a GPU and Colab specific so the notebook is extremely bare bones.

    The first step is to download the notebook (or another notebook of your choice)

    Then, head over to Google Colab, sign into your google account (or create one if you somehow made it this far through life without one)

    Now you should be able to run your notebooks how you normally would. The only difference is the very last part at the end. If you want to download your model or any other files via the browser, you can use their python library:

    from google.colab import files
    files.download("PATH/TO/FILE")

    Final Thoughts

    This was a pretty short post, but hopefully it ends the painful days of training your models on your poor little old laptop for days at a time or dropping a ton of ? on AWS bills.

     


    每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,欢迎关注开源日报。交流QQ群:202790710;电报群 https://t.me/OpeningSourceOrg

  • 2018年3月30日:开源日报第22期

    30 3 月, 2018

    每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,欢迎关注开源日报。交流QQ群:202790710;电报群 https://t.me/OpeningSourceOrg


    今日推荐开源项目:《安全高效的Rust语言》

    推荐理由:Rust 是一个系统编程语言,它注重于三个方面:安全,速度和并发性。因此,它没有采用垃圾回收机制。它的特点也使得它能在其他编程语言不擅长的场景中大显身手。它通过一系列不产生运行时开销的编译时安全检查来提升目前语言所关注的领域,同时消除一切数据竞争。Rust还致力于实现“零开销”,虽然看起来更像是一个高级语言的特性,但我们仍然可以用Rust来实现一些精准的底层控制。

     

    Rust简介:

     

    Rust 是一种 预编译语言(ahead-of-time compiled language),程序编译好后,把它给任何人,他们都不需要安装 Rust 就可运行。如果你给他们一个 .rb , .py 或 .js 文件,他们需要先分别安装 Ruby,Python,JavaScript 实现,不过你只需要一句命令就可以编译和执行你的程序。这一切都是语言设计的权衡取舍。

    Rust使用示例:

    例如,在使用一门语言时,编写一个能够在屏幕上打印“hello world”的小程序,基本上已经成为了一种传统,我们以使用Rust来编写这个程序为例:

    fn main() {
        println!("Hello, world!");
    }

    首先,创建项目文件。值得注意的时Rust并不关心你的代码存放在哪里,打开一个终端并输入如下命令来为这个项目创建一个文件夹:

    $ mkdir ~/projects$ cd ~/projects$ mkdir hello_world$ cd hello_world

    接下来为Rust创建源文件。Rust的源文件有独自的标识,以.rs结尾。

    同时,Rust程序同样会有一个main函数。程序中的第一行就意味着:定义一个main函数,没有参数也没有返回值。

    而println!(“Hello, world!”);则做了这个程序的所以工作,值得注意的是代码前的是四个空格而不是制表符。

    在编译运行这样一个Rust程序时,可以输入rustc命令来使用 Rust 编译器并像这样传递你源文件的名字:

    $ rustc main.rs

    在Linux或OSX系统中在shell下通过如下ls命令你可以看到它:

    $ lsmain  main.rs

    在Windows下:

    $ dirmain.exemain.rs

    Rust程序帮助编写工具——Cargo

    Cargo 是 Rust 的构建系统和包管理工具,同时 Rustacean 们使用 Cargo 来管理它们的 Rust 项目。Cargo 负责三个工作:构建你的代码,下载你代码依赖的库并编译这些库。随着你编写更加复杂的 Rust 程序,你会想要添加代码需要的库,那么如果你使用 Cargo 开始的话,这将会变得简单许多。

    Rust的安装:

    在 Unix 类系统如 Linux 和 macOS 上,你只需打开终端并输入:

    $ curl https://sh.rustup.rs -sSf | sh

    这样会下载一个脚本并开始安装。如果一切顺利,你将会看到:

    Rust is installed now. Great!

    在Windows下:

    安装地址:https://www.rust-lang.org/zh-CN/install.html

    Rust的安全性

    Rust最大的卖点就在于它的高安全性,尽管在老练的程序员手中保证安全性并不算太难,不过使用Rust可以轻松避免一些常见的错误。

    空指针

    如果程序员没有检查返回的指针是否为空,就有可能出现这个问题。Rust简单粗暴的禁用了所有的空指针。

    Rust中使用了引用(References)和借贷(Borrowing),引用就相当于原来的指针,借贷相当于一个读写锁。对于一个变量,你只能单方面的读或者单方面的写,而不能在改变它的值的同时读取它。当你改变指针变量产生了空指针时,它就会被禁用,从而防止了空指针的产生。

    释放内存后再使用

    Rust使用资源获取时初始化(Resource Acquisition Is Initialization)的方式让每个变量在超出范围后一定被释放,同时被释放的内存所有权将会被改变,使得用户无法访问

    返回悬空指针

    在Rust中引用是相当于指针的。而Rust的编译器会核实返回的引用的有效性,即这些引用总是指向有效的内存。

    超出访问权限

    这个问题通常是数组的索引超出了范围导致的,比如以下这一段

    int a[4]={0,0,0,0};
    printf(“%d”,a[4]);

    Rust会在运行时进行检查来减少这种错误的行为。

    Rust到底值不值得花时间学习?

    答案当然是值得,理由如下:

    1、拥有开放,友好,高效的开源社区

    开放源代码、GitHub/Git在线开发 https://github.com/rust-lang/rust

    开放系统设计过程,重要设计项目的提出、讨论、评估、决策均在线进行。

    内部决策过程公开透明,每周的发布会议均有记录

    公开接受第三方开发者提交的 Pull Requests,必要时还指导开发

    有一个核心团队(the core team)负责项目的发展方向和最终决策

    有大量的(超过 1000 人!)第三方开发者给Rust贡献源代码、文档和测试用例

    多次将优秀的第三方开发者吸纳进入官方开发团队和核心团队

    多次在世界各地(包括北京)主办和协办小型本地开发者见面会

    2、十几年勤耕不缀

    2006年,创始人Graydon Hoare启动了Rust编程语言项目,用三年完成了第一个可用版本。

    2011年,Rust语言编译器被用Rust语言重写,完成自举。

    2012年,Servo项目创建,验证了Rust语言开发大型使用项目的能力。

    2015年,发布正式版本1.0。

    2018年,1月4日版本更新到1.23.0

    3、拥有精心设计的规范透明的开发流程

    引入规范化的RFC流程,形成了完整的技术文档,利于集体讨论评估,利于方案实施后期维护。该机制有力地推动了Rust的革新。

    4、不拘一格聘请人才

    Steve Klabnik 因写作才华成为核心开发组成员之一。

    Tilde公司以前开发的Ruby包管理器Bundler在Ruby领域非常流行,其架构设计被实践证实获得成功。14年,Rust官方聘请Tilde公司的核心技术人员Yehuda Katz和Carl Lerche

    深受好评的Rust学习示例网站 http://rustbyexample.com 的早期创建者 Jorge Aparicio 后来也被邀请加入 了(Mozilla公司的)Rust官方团队。

    5、大规模的社区参与

    社区里,用Rust开发的,或者与Rust相关的开源项目:Servo, Cargo, rust-by-example, Hyper, Piston, rust-postgres, gfx-rs, conrod, rust-sdl2, rust-crypto, docopt.rs, zinc, racer, rust-bindgen, glfw-rs, capnproto-rust, rust-rosetta, graphics, rust-openssl, rust-encoding……

    总结:Rust是一个人靠谱,团队靠谱,技术能力靠谱,态度靠谱,社区靠谱的项目。你值得拥有。

    学习链接:

    Rust Book: https://doc.rust-lang.org/book/

    Rust 学习示例:https://rustbyexample.com/

    Rust中文教程:http://wiki.jikexueyuan.com/list/rust/


    今日推荐英文原文:《The Next 10 Years of Interfaces》 作者:Gabriel Valdivia

    原文链接:https://uxdesign.cc/immersive-design-the-next-10-years-of-interfaces-16122cb6eae6

     

    The Next 10 Years of Interfaces

     

    Like many designers, I started my career as a Graphic Designer. I dealt in picas, carried Pantone books, and swore to measure twice and cut once. Then the web came along and with it came Web Designers. We had to become acquainted with HTML, CSS, Javascript and we’re still trying to keep up with the right way to build for it.

    These websites quickly demanded more interaction from us when Flash entered the scene and conquered our hearts. We turned our attention to animation to convey expressive user flows through interaction design. Then, the iPhone showed up and forced us to think smaller. We got excited about skeuomorphism, learned about pixel density, and made a vow to design mobile first.

    After a while, we tried to combine all of the above into a holistic practice that would buy us “a seat at the table,” where we could think not just about aesthetics, interactions, and user needs, but also business needs. And so, the modern Product Designer was born.

    I’m willing to bet that, like many designers before it, the Product Designer is approaching extinction, and setting the stage for the Immersive Designer.

    Virtual Reality (still) matters

    Over the last decade, we’ve seen content move from newsstands, to desks, to our laps, and then into our hands. It seems clear that the next step is to remove the device altogether and place the content in the world itself, eliminating the abstraction between the content and it’s audience. We call the process of designing for this Immersive Design, which includes VR/AR/MR/XR — basically all the Rs.

    We are seeing this realized today in phones through Augmented Reality. Tech giants like Apple, Google, and Samsung are rushing to conquer the AR space like a modern Christopher Columbus in search of spices. We’re seeing identity transfer setting a trend in animojis and virtual characters walk around our videos like a Roger Rabbit fever dream. However, designing for mobile Augmented Reality today feels like developing for the Commodore 64 in 1982; investing in a platform that’s novel but filled with practices that will be rendered obsolete before they’re relevant. I’ve found that Augmented Reality in 2018 has two major limitations when it comes to Immersive Design: field of view and input.

    Source: The Verge.

    Field of view

    So far, Augmented Reality is still restricted to a rectangle in your hands. Content can only aspire to be a window into another world; it hasn’t quite inhabited our own yet. Users feel trapped outside in the mundane world while all the fun is happening inside the phone in their hands as if A-ha’s Take on Me never made it to the first chorus.

    Input

    In 2018, we’ve developed a language for using facial gestures like opening our mouth or raising our eyebrows to control Augmented Reality masks, other experiences rely on the now primitive touch interaction, while the ambitious ones rely on voice commands to interact with the world inside the screen. The input available on the market limits these interactions. However, once we inevitably obviate the phone and achieve immersion through AR glasses, we’ll have to go back to the drawing board and try to answer the billion-dollar question: how do you interact with content in space?

    This is where Virtual Reality comes in.

    The jury is still out on whether Virtual Reality belongs in your living room or as a museum-like destination that you plan for. We’re still experimenting with the medium to find the adequate cadence for virtual experiences and navigating worlds in the much-adored metaverse. If you think about it, it took film quite a bit of time to arrive at the standard 90-minute duration, which is about as long as it takes your bladder to digest a liter of Coke at the cinema.

    Today, Virtual Reality has found a fit as the best way to explore Immersive Design problems present in the Augmented Reality future we crave by taking advantage of a more immersive field of view and using natural gestural interactions. Challenges like thinking in 3D and using volumetric UI that reacts to the environment and the people in it.

    Not only can Virtual Reality improve our quality of life by providing great escapism, but it can also open up a bunch of questions around how people could interact with technology if it were all around us. Among other things, I’ve found that Immersive Design invites designers to question the line between content and UI and rethink the process for creating digital products.

    Content is changing

    As designers we’re often told to get out of the way. To be “content first” and make room for the reason people are using your product in the first place. However, Immersive Design poses an interesting question: where does the line between content and UI start and end?

    Game designers have been asking themselves this question for decades. As they envision a world to be inhabited by players, the interface to navigate it can often be abstracted into menus that live outside the world’s logic. For example, the interface to start a game often lives in this weird in-between software that acknowledges the existence of the world inside the game by using the game’s characters and aesthetics, but operates based on the rules of the player’s world.

    And so, video game companies draw a line between UI and Game Designers. There’s logic to this decision: Game Designers are often proficient in 3D tools while UI designers generally work in 2D. This decision can sometimes lead to immersion-breaking solutions that require players to suspend their disbelief when the game reminds them they’re in a video game with video game systems.

    The explicit line between UI and content is tolerable in a video game, but as we step into the world of Immersive Design, we won’t necessarily have the luxury of flat menu trees that exist outside our reality. We are tasked with finding solutions for UI that follows the rules of our augmented world; where do the menus come from and how do we interact with them?

    As they’ve matured, video games have given us examples of how design can be woven into the environment and blur the line between content and interface.

    On the left image above, 2011’s Skyrim shows UI to manage inventory plagued with floating text alerts around the screen, using the typeface Futura for a game that takes place in medieval times. Although the menu is intuitive and efficient, it grossly breaks immersion and reminds the player that dragons aren’t real. On the right, 2018’s S.O.S. relies on a more immersive schema that pulls out a physical map in the player’s point of view and requires the use of a radio (with radio channels and static) to communicate with other players.

    We are seeing similar practices arise in Virtual Reality games. Although some games rely on the traditional 2D menu systems, others place cues in the environment to educate the user. This is important because, in VR, the player has fewer abstractions to escape to. VR controllers are often shaped around a player’s hand to promote natural interactions that don’t typically lend themselves to menu trees.

    On the left, Doom VFR uses a traditional approach to user interface — a 2D panel of information floating in space. On the right, Winston’s Heart places the UI in the world as a clipboard that can be grabbed and reacts to the lighting in the environment. Doom doesn’t seem concerned with reminding users that they’re in a video game, which of course needs to provide you with text cues for learning how to play the game. However, Winston’s Heart makes an effort to insert those cues as a plausible element in the environment, further enhancing the immersion of that experience.

    On the left, Space Pirate Trainer asks the user to literally shoot menu items to select the game mode. On the right, Arizona Sunshine lets the user grab and insert cartridges into a retro console to pick a game mode. The point-and-shoot interaction is carried over from the mouse and keyboard era and ported into the context of the Space Pirate Trainer while using cartridges to select a game mode fits perfectly within the tone of Arizona Sunshine and evokes a feeling of nostalgia that many VR players crave.

    Arktika 1 applies a clever, mind-bending technique to enter a tutorial: the user is handed a VR headset inside the VR experience. By putting the headset on, the user agrees to suspend their disbelief and enter a virtual world that doesn’t follow the same rules as the Arktika world. It’s a tongue in cheek moment that ambitiously aspires to create not one but two alternate worlds. By contrast, the Arktika world feels much more real because it appears self-aware and higher fidelity than the training environment.

    These are a few examples of the great Immersive Design work happening in Virtual Reality right now. For many of us, stepping into Immersive Design means placing a bet that content won’t be confounded to the boundaries of a screen. We see that as an opportunity to invent interactions that are so intuitive they become invisible — like pinch to zoom or pull to refresh. Today, our work consists in finding those interaction patterns, which will seem obvious in retrospect.


    每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,欢迎关注开源日报。交流QQ群:202790710;电报群 https://t.me/OpeningSourceOrg

  • 2018年3月29日:开源日报第21期

    29 3 月, 2018

    每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,欢迎关注开源日报。交流QQ群:202790710;电报群 https://t.me/OpeningSourceOrg


    今日推荐开源项目:《Wtfpython——更有趣的python教程》

    推荐理由:Python 教程千千万万,试试这个更有趣的?

    Wtfpython讲解了大量的Python编译器的内容。其实它们不一定很实用,只要程序员按照规范的语法输入基本上是不会碰到其中的“BUG“的,不过其中有一部分内容是真的很有趣或者可能有用,这里将其中几个较为有用或有趣的摘录下来,看看能否激起大家前去一阅的兴趣。

    Tips:

    1.python中对“-”号的定义:Pyhon的自由度真的很高啊,不过这个自由度是建立在定义严格的基础上的。-”号是“+”号的反向,具体一点,就是这样:

    开源项目精选:Wtfpython——更有趣的python教程

     

    2.多线程处理:多个Python线程不会同时运行你的Python代码。多线程看起来很直观,可以派生出几个线程,让他们同时执行你的Python代码,但是由于Python存在全局解释器锁(Global Interpreter Lock),你所做的只是让你的线程在相同的内核上轮流执行。Python线程适用于IO绑定任务,但为了实现CPU绑定任务的Python实际并行化,您可能需要使用Python 多处理模块(multiprocessing module)。

    有关全局解释器锁的内容可以查看官方文档:

    https://wiki.python.org/moin/GlobalInterpreterLock

     

    3.关于count函数:

    ‘abc’.count(”) == 4.

    Count函数用于统计字符串中某个子串的出现次数,以下代码模拟了该函数的执行过程,或许可以解释这个问题:

    def count(s, sub):

    result = 0

    for i in range(len(s) + 1 – len(sub)):

    result += (s[i:i + len(sub)] == sub)

    return result

     

    4.两个特殊字符串:

    nan与inf意义分别是“不存在”与“无穷大”,这两个概念在被强制转换为float类型后生效。即:

    a=float(‘inf’) 正无穷大

    b=float(‘-inf’)负无穷大

    c=float(‘nan’)不存在的数

    这样的话会有:

    >>>a+3

    inf

    >>>b+3

    -inf

    >>>c+3

    nan

    Ps:无限的哈希值是10 5 xπ

     

    5.+=的优先级要比+高,除非你把+号连接的内容打上括号。

     

    6.以Python为舟,看看Python的哲学:

    >>>import this

    >>> love = this

    >>> this is love

    True

    >>> love is True

    False

    >>> love is False

    False

    >>> love is not True or False

    True

    >>> love is not True or False; love is love  # Love is complicated(复杂的)

    True

    算一个梗吧,哈哈。

    这是this模块的内容https://hg.python.org/cpython/file/c3896275c0f6/Lib/this.py

     

    7.global的使用:

    在函数外定义的变量,可以被函数引用,但是如果函数内有同名变量的赋值(不论位置),引用都会触发错误。

    例:

    a = 1

    def some_func():

    return a

     

    def another_func():

    a += 1

    return a

    运行:

    >>> some_func()

    1

    >>> another_func()

    UnboundLocalError: local variable ‘a’ referenced before assignment

    除非改成这样:

    def another_func()

    global a

    a += 1

    return a

     

    8、关于哈希:

    some_dict = {}

    some_dict[5.5] = “Ruby”

    some_dict[5.0] = “JavaScript”

    some_dict[5] = “Python”

    运行:

    >>> some_dict[5.5]

    “Ruby”

    >>> some_dict[5.0]

    “Python”

    >>> some_dict[5]

    “Python”

     

    由于5.0的哈希值与5相同,因此JavaScript被Python覆盖了(emmmm,满满的恶意)

    测试两键哈希是否相同用hash(a)==hash(b)即可。

    由于存取只以哈希值为标准,因此字典也被称作哈希表。

     

    9.当并列的语句都含有return时,以最后一句的内容为准。

    def some_func():

    try:

    return ‘from_try’

    finally:

    return ‘from_finally’

    运行:

    >>> some_func()

    ‘from_finally’

     

    更多内容:

    https://github.com/satwikkansal/wtfpython


    今日推荐英文原文:《My first open source project and Google Code-in》原文作者:Manvendra Singh

    原文链接:https://opensource.googleblog.com/2018/03/my-first-open-source-project-and-google.html

     

    My first open source project and Google Code-in

    About two years ago, my friend Gyan and I built a small web app which checked whether or not a given username was available on a few popular social media websites. The idea was simple: judge availability of the username on the basis of an HTTP response. Here’s a pseudo-code example:

    website_url = form_website_url(website, username)
    # Eg: form_website_url('github', 'manu-chroma') returns 'github.com/manu-chroma'
    
    if website_url_response.http_code == 404:
      username available
    else:
      username taken

    Much to our delight, it worked! Well, almost. It had a lot of bugs but we didn’t care much at the time. It was my first Python project and the first time I open sourced my work. I always look back on it as a cool idea, proud that I made it and learned a lot in the process.

    But the project had been abandoned until John from coala approached me. John suggested we use it for Google Code-in because one of coala’s tasks for the students was to create accounts on a few common coding related websites. Students could use the username availability tool to find a good single username–people like their usernames to be consistent across websites–and coala could use it to verify that the accounts were created.

    I had submitted a few patches to coala in the past, so this sounded good to me! The competition clashed with my vacation plans, but I wanted to get involved, so I took the opportunity to become a mentor.

    Over the course of the program, students not only used the username availability tool but they also began making major improvements. We took the cue and began adding tasks specifically about the tool. Here are just a few of the things students added:

    • Regex to determine whether a given username was valid for any given website
    • More websites, bringing it to a total of 13
    • Tests (!)

    The web app is online so you can check username availability too!

    I had such a fun time working with students in Google Code-in, their enthusiasm and energy was amazing. Special thanks to students Andrew, Nalin, Joshua, and biscuitsnake for all the time and effort you put into the project. You did really useful work and I hope you learned from the experience!

    I want to thank John for approaching me in the first place and suggesting we use and improve the project. He was an unstoppable force throughout the competition, helping both students and fellow mentors. John even helped me with code reviews to really refine the work students submitted, and help them improve based on the feedback.

    Kudos to the Google Open Source team for organizing it so well and lowering the barriers of entry to open source for high school students around the world.


    每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,欢迎关注开源日报。交流QQ群:202790710;电报群 https://t.me/OpeningSourceOrg

  • 2018年3月28日:开源日报第20期

    28 3 月, 2018

    每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,欢迎关注开源日报。交流QQ群:202790710;电报群 https://t.me/OpeningSourceOrg


    今日推荐开源项目:《Django——强大的python web框架》

    推荐理由:Django是一个基于Python的开源web应用框架,采用了MT’V的框架模式,他源自一个在线新闻web站点,以比利时的一个柬埔寨吉他手的名字命名(他的曲子真的很不错)。Django不算很年轻,但是对于一个web开发者,深入学习Django,永远都不会过时。

     

    安装(Windows下):

    在安装Django框架之前你的PC需要有一个Python环境,Python环境并不难搭建,就不在此过多赘述。

    搭建好Python环境后,直接在官网的下载栏下载即可(点击此处下载)(目前Django1.6.x以上版本已经完全兼容Python3.x)。下载好安装包后,加压并和Python安装目录放在同一个根目录,进入Django目录。

    在此目录下打开终端,并执行python setup.py install,然后开始安装,Django将要被安装到Python的Lib下site-packages。

    最后是配置环境变量,将目录添加到系统环境变量当中即可。完成后就可以使用Django的django-admin.py命令新建工程了。

    开始你的Django之旅:

    创建django项目:

    使用 django-admin.py 来创建一个名为mysite的项目:

    django-admin.py startproject mysite
    

    创建完成后,通过manage.py启动django自带的服务器:

    python manage.py runserver
    

    默认在127.0.0.1:8000启动服务,访问该地址显示以下页面表示创建成功:

    创建新的app:

    创建完项目后,在mysite目录下创建一个名为HelloDjango的app:

    python manage.py startapp HelloDjango
    

    创建完成后目录结构如下:

    HelloDjango/

    __init__.py

    admin.py

    migrations/

    __init__.py

    models.py

    tests.py

    views.py

    创建完成后在setting.py中找到INSTALLED_APPS,输入‘HelloDjango’

    设计你的模型:

    Django一个比较方便的地方是它附带了一个可以用Python代码描述数据库布局的对象关系映射器,数据模型语法提供了许多丰富的方法来展现你的模型。

    创建一个包含title,content,pub time的模型:

    models.py:

    from django.db import models
    class Article(models.Model):
        title = models.CharField(max_length=32,default='Title')
        content = models.TextField(null=True)
        pub_time = models.DateTimeField(auto_now_add=True)

    创建完成后同步数据库:

    python manage,py makemigrations
    python manage.py migrate
    

    并在admin.py中注册:

    from django.contrib import admin
    from .models import Article
    admin.site.register(Article)

    Admin 管理工具

    Django 最强大的部分之一是自动生成的Admin 界面。它读取模型中的元数据来提供一个强大的、生产环境就绪的界面,使内容提供者能立即用它向站点中添加内容。你可以通过 python manage.py createsuperuser创建管理员账号,通过127.0.0.1:8000/admin访问Admin界面。

    你可在settings.py中将Admin界面的语言和时间设置为中国

    LANGUAGE_CODE = ‘zh-hans’

    TIME_ZONE = ‘Asia/Shanghai’

    在Admin界面中你可访问并管理之前注册的Article模型,如添加一篇新的内容:

    前端页面

    Django的前端页面保存在Templates文件夹中,在HelloDjango中新建Templates文件夹并编写自己的前端代码。图片等资源则需要保存在static文件夹中。

    配置url与views

    我们可以为每个app单独配置url,

    • 首先配置mysite中的urls.py
    from django.contrib import admin
    from django.urls import path
    from django.urls import include
    urlpatterns = [
        path('admin/', admin.site.urls),
        path('HelloDjango/',include('HelloDjango.urls')),
    ]
    • 在HelloDjango中新建urls.py
    from django.conf.urls import url
    from . import views
    urlpatterns = [
        url(r'^$',views.index),
    ]
    • 在views.py中
    from django.shortcuts import render
    from . import models
    def index(request):
        return render(request,'index.html')

    此时访问http://127.0.0.1:8000/HelloDjango则会显示自己编写的index.html的内容

    如:

    在网页中加载数据库中的内容:

    • 在views.py中加载:
    def Article(request,Article_id):
        article = models.Article.objects.get(pk=Article_id)
        return render(request,'article.html',{'article':article})
    • 在urls.py中添加:
    url('article/(?P<Article_id>[0-9]+)$', views.Article)
    • 在article.html中通过{{article.title}},{{article.content}},{{article.pup_time}}可以分别加载出文章的标题,内容,时间(对应自己创建的模型)

    完成后通过‘127.0.0.1:8000/HelloDjango/article/’ + 文章的id 就可以访问指定的文章

    如127.0.0.1:8000/HelloDjango/article/1 访问新建的第一篇文章:

    了解更多,欢迎访问(别着急,后面有彩蛋):

    GitHub:https://github.com/django/django

    官网: https://www.djangoproject.com/

     

    彩蛋:

    关于吉他手Django Reinhardt

    法国著名吉他手,爵士乐史上的伟大琴师。1910年出生于比利时,

    因18岁时一次意外导致只能以三个健全手指进行演奏,但仍然创造了传世的音乐作品

    和令人赞叹的成就。1953年在法国去世。


    今日推荐英文原文:《Becoming a 10x Developer》作者:Kate Heddleston

    原文链接:https://kateheddleston.com/blog/becoming-a-10x-developer

    推荐理由:这篇文章的副标题其实叫做 10 Ways to be a Better Teammate;成为一个好搭档的10种方法。一个好的球星不仅自己是一个很棒的球员,同时也一定是一个很好的助攻,以团队协作来看,好的搭档可谓难得,现在的软件工程以及开源协作都对互相配合提出了很高的要求,好的互助事半功倍、互相拆台则事倍功半,不仅学会自己成为一个好程序员,同时学会成人之美,成为一个好的搭档,也各位重要。

    Becoming a 10x Developer

    When I was first learning to play water polo, a coach told me something I’ve never forgotten. He said, “Great players make everyone around them look like great players.” A great player can catch any pass, anticipating imperfect throws and getting into position. When they make a return pass, they throw the ball so that the other person can make the catch easily.

    Software engineering today is a team sport; like water polo, you can’t build incredible software systems alone. So when I first heard the concept of the 10x engineer, I was confused. How could someone be so talented that it overshadows the power of teamwork? In my experience, individual excellence is necessary, but not sufficient, for greatness. Focusing purely on individual achievement misses the larger picture that teams are required to build great software. So I decided to change the definition of a 10x engineer to this:

    A 10x engineer isn’t someone who is 10x better than those around them, but someone who makes those around them 10x better.

    Over the years I’ve combined my personal experience with research about building and growing effective teams and turned that into a list of 10 ways to be a better teammate, regardless of position or experience level. While many things on this list are general pieces of advice for how to be a good teammate, there is an emphasis on how to be a good teammate to people from diverse backgrounds.

    10 Ways to be a Better Teammate

    1. Create an environment of psychological safety
    2. Encourage everyone to participate equally
    3. Assign credit accurately and generously
    4. Amplify unheard voices in meetings
    5. Give constructive, actionable feedback and avoid personal criticism
    6. Hold yourself and others accountable
    7. Cultivate excellence in an area that is valuable to the team
    8. Educate yourself about diversity, inclusivity, and equality in the workplace
    9. Maintain a growth mindset
    10. Advocate for company policies that increase workplace equality

    1. Create an environment of psychological safety

    In 2012, Google launched Project Aristotle to study hundreds of Google teams and figure out why some teams performed better than others [1]. The study found that there were only two key differences between more productive teams and less productive teams. One of those two the key components was something researchers call Psychological Safety. Harvard Business School professor Amy Edmondson described it as a “shared belief held by members of a team that the team is safe for interpersonal risk-taking” and “a sense of confidence that the team will not embarrass, reject or punish someone for speaking up.” [1] Creating an environment of psychological safety creates a space where team members can trust one another and share their opinions and ideas about work freely. Here are some ways to foster an environment of psychological safety within your own workplace.

    1. Acknowledge people’s ideas and feelings in a non-judgemental way. Acknowledgment is a separate step from judging or assessing.
    2. Respond to ideas with a “yes and” attitude to build off what your teammates say (like in improvisational comedy!) [2].
    3. Give people the benefit of the doubt. Believe them until proven otherwise, as opposed to making them prove themselves until you believe them.

    2. Encourage everyone to participate equally

    Project Aristotle, the research study on effective teams at Google [1], found one other important component for productive teams. It’s a phenomenon that the academic world has named ‘‘equality in distribution of conversational turn-taking.’’ Basically, this just means that people on effective teams participate equally. This doesn’t mean that people have to speak equally in every meeting, but that, over time, everyone on a team will contribute equally. So how can you foster a team culture in which everyone participates equally?

    1. Ask people their opinions in meetings.
    2. Invite discussion with your language by using words like “I think” and “maybe”. (I call this conversational style: “Maybe you should talk more like a woman?”)
    3. Communicate frequently and informally [3].
    4. Notice when someone else might be dominating a conversation and make room for others to speak.

    3. Assign credit accurately and generously

    Giving credit to people accurately for their work is an important part of establishing trust in a team and organization [4]. Many of us have had a personal experience where we felt like we didn’t receive credit for our work, or credit was given to the wrong person.

    One of the great things about giving other people credit is that it doesn’t just make the other person look good, it also makes you look good. People who acknowledge others are seen as both smarter and more likable by other people. Basically, it’s a win-win and there’s no reason to hold back in your praise of others.

    What can you do to help foster a culture where people assign credit to others for their work?

    1. Make sure you take time at the end of each project to thank the people who helped you.
    2. Especially try to notice people who are quiet and don’t do much self-promotion, or people who are new and lack confidence.
    3. Be honest, specific, and genuine when assigning credit and praising others’ work.

    4. Amplify unheard voices in meetings by repeating what they say

    None

    In 2009, a group of President Obama’s female staff banded together and devised a strategy they called “amplification” [5]. They were experiencing a lot of the things women face in male-dominated workplaces—they were having trouble getting into important meetings and, when there, were often overlooked or unheard. So they would amplify each other’s voices. When a female staffer made a key point, the other women would repeat it and give credit to the author, which forced everyone to notice where the idea came from. President Obama himself noticed this and made a point to call on more female staffers more. By his second term, there was an even gender split and half the departments were headed by women.

    This is such a simple, concrete thing that any person on any team can do for their teammates. Notice when people are overlooked or unheard and amplify what they say. While it’s common for women to be spoken over [6], it can also happen to people who are soft-spoken, shy, or introverted.

    5. Give constructive, actionable feedback and avoid personal criticism

    People pretty universally dislike being criticized and, when not given thoughtfully or constructively, criticism can actually damage people’s performance [8]. I’ve talked about this before, but making sure that your feedback is thoughtful and constructive is a really important way you can be a great teammate. Additionally, the way we give feedback can be biased, so spending time learning to give feedback well is important for diverse teams.

    For example, there’s a common perception that women receive criticism that men don’t. Women report being called “bossy”, “pushy”, and “aggressive” more than their male peers. In 2014, Kieran Snyder, founder and CEO of Textio, decided to test that idea [7]. She collected 248 reviews from 180 people, 105 men and 75 women, and analyzed the contents of those reviews. What she found was surprising, even if you know it’s there. Of the women’s reviews, 87.9% percent contained criticism or negative feedback as opposed to 58.9% of men. Furthermore, the criticism given to men and women wasn’t the same. Of the criticism women received, 76% of it was personal in nature as opposed to 2% of criticism given to men.

    Here are some ways you can give better feedback.

    1. Ask people if they’re open to feedback before giving feedback.
    2. Focus your feedback on the person’s work as much as possible.
    3. Tell people how they can make things better. Clearly identify the issue as you see it and explain how you think the person can make things better.
    4. Avoid personal criticism. If you feel that you need to give someone feedback on their person, work with a manager or HR to make sure that you have your thoughts organized.

    6. Hold yourself and others accountable

    Recently I met with a friend of mine, James, who was a football player in college. He’s now the COO of a startup, and he mentioned that he was spending a lot of his time teaching what he considered basic teamwork to employees, especially around accountability. As I thought about it more, I realized that James has spent thousands and thousands of hours practicing being a good teammate. Things that are obvious to him about working well as a team might not be obvious to others, especially when it comes to accountability. Football has a strong culture of accountability, and some of the ways football players hold each other accountable are through being on time to practice, having a positive attitude, encouraging teammates, and holding each other to a standard of excellence. Here are some ways you can hold yourself and others accountable.

    1. Get your work done as on-time as you can (I know as engineers estimates are one of our biggest challenges, but smaller projects with more accurate estimates help foster accountability).
    2. Jeff Lawson once told a group of founders that the most important thing is “doing what you say you’ll do”.
    3. Help others, and ask for help when you need it.
    4. For big projects or issues, stay present until your team’s work is finished [9] (whether that presence is in-person or through remote tools like Slack).

    7. Cultivate excellence in an area that is valuable to the team

    When we talk about being a 10x engineer, this is usually what people are referring to—individual excellence. Individual excellence is a necessary part of being a good teammate. After all, you need to do something for your team. What you choose to become excellent at is really about what motivates you; it should be something that gives you energy and fits your skills and interests. Excellence takes a lot of time and energy to cultivate, especially as our individual knowledge base is becoming more and more specialized [10], so pick something you enjoy doing because you’ll probably be at this a while. I feel that individual excellence is harped on a lot in our society, so I’ll let you read the slew of self-help books and blog posts out there on how to be more excellent at your craft.

    8. Educate yourself about diversity, inclusivity, and equality in the workplace

    None

    Diversity and Inclusion is a team sport—we need everyone at every level to participate. One of the number one things you can do to be a good teammate is to educate yourself about how gender and race discrimination take form in the workplace. In the same way that you need to stay educated on programming languages and tooling, it’s important to stay up to date on all the amazing writing and research about how to create more egalitarian work environments.

    There is a joke that “behind every woke man is an exhausted feminist”, and probably behind every woke white person is an exhausted person of color. Let’s change that. Anyone can read and do research.

    1. Read everything
    2. Ask people for reading suggestions or join mailing lists
    3. Listen as much as you can
    4. Your opinion is as valuable as your education, so if you have not educated yourself, your opinion is not valuable.

    9. Maintain a growth mindset

    Thirty years ago, psychologist Carol Dweck was interested in the concept of failure and resilience [11]. She and her research team noticed that some students rebounded from failure while others were demoralized even by small setbacks. She wanted to know why. After studying thousands of children, she coined the term Growth Mindset, which refers to the belief that abilities and intelligence can be developed. Students who believe that they can increase their abilities and intelligence rebound from failure, while students who believe intelligence is fixed are more likely to be demoralized by setbacks.

    1. Remember you can learn anything given time, effort, and the internet.
    2. Be prepared for feedback on how you can improve.
    3. There is no finish line; being a great engineer and a great teammate is a lifelong, daily practice.

    10. Advocate for companies policies that increase workplace equality

    None

    Finally, speak up about ways you think your company can create a more egalitarian, inclusive workplace for every member of your team. No matter what your level within the organization, you can advocate for policies that will improve your work environment. Reading and doing research per recommendation #8 will make this step a lot easier. Some examples of organizational changes that have proven effects are:

    1. The Rooney Rule: for any key position, you have to interview at least one person of color for the role [12]
    2. Evaluate candidates in groups for promotions [13]
    3. Making meetings, salaries, key initiatives, and internal processes more transparent.

     


    每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,欢迎关注开源日报。交流QQ群:202790710;电报群 https://t.me/OpeningSourceOrg

←上一页
1 … 254 255 256 257 258 … 262
下一页→

Proudly powered by WordPress