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

开源日报

  • 开源日报第818期:《解锁歌曲 Unlock-netease-cloud-music》

    29 6 月, 2020
    开源日报 每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,坚持阅读《开源日报》,保持每日学习的好习惯。
    今日推荐开源项目:《解锁歌曲 Unlock-netease-cloud-music》
    今日推荐英文原文:《Technical Ergonomics for the Efficient Developer》

    今日推荐开源项目:《解锁歌曲 Unlock-netease-cloud-music》传送门:GitHub链接
    推荐理由:该项目能将网易云音乐上灰色的单曲全部恢复成可以播放的音乐,原理是利用使用 QQ / 虾米 / 百度 / 酷狗 / 酷我 / 咪咕 / JOOX 的音源替换变灰歌曲的链接。
    今日推荐英文原文:《Technical Ergonomics for the Efficient Developer》作者:Victoria Drake
    原文链接:https://medium.com/better-programming/technical-ergonomics-for-the-efficient-developer-76bf0177e037
    推荐理由:题为工程学,但说的却是如何减轻大脑的负担而不是脖子和手腕:使用语法高亮、Git Hooks 和类型系统(Type System)。

    Technical Ergonomics for the Efficient Developer

    Syntax highlighting, type systems, and more

    This article isn’t going to tell you about saving your neck with a Roost stand, or your wrists with a split keyboard — I’ve already done that. This article is about saving your brain.

    When I first began to program full time, I found myself constantly tired from the mental exertion. Programming is hard! Thankfully, you can take some solace in knowing it gets easier with practice, and with a great supporting cast. Some very nice folks who preceded us both came up with tools to make the difficult bits of communicating with computers much easier on our poor human meat-brains.

    I invite you to explore these helpful technical tools. They’ll improve your development setup and alleviate much of the mental stress of programming. You won’t believe how you managed without them.

    Not Your Average Syntax Highlighting

    If you’re still working with syntax highlighting that just picks out variable and class names for you, that’s cute. Time to turn it up a notch!

    (A screenshot of Kabukichō, with syntax highlight upgrades.)
    In all seriousness, syntax highlighting can make it much easier to find what you’re looking for on your screen. The current line, where your current code block starts and ends, or the absolute game-changing which-bracket-set-am-I-in highlight. I primarily use Visual Studio Code, but similar extensions can be found for all the major text editors.

    Here are my favorites:
    • Bracket Pair Colorizer highlights sequential bracket pairs in different matching colors, making the pain of picking through nested brackets and parentheses a thing of the past.
    • TODO Highlight effectively removes any excuse you may have had for unintentionally committing TODO and FIXME comments by making them really easy to see. You can even add your own custom keywords to be highlighted (I suggest, wtf, but you didn’t hear it from me.)
    • Indented Block Highlighting puts an easy-to-distinguish but unobtrusive highlight behind your current indented code block, so you can see just where that if ends and why that last else isn’t doing anything at all.
    • Highlight Line puts a (slightly too) bright line where you last left your cursor. You can customize the line’s appearance — I set the borderWidth of mine to 1px.
    The theme pictured in Visual Studio Code above is Kabukichō. I made it.

    Use Git Hooks

    I previously brought you an interactive pre-commit checklist in the style of infomercials that’s both fun and useful for reinforcing the quality of your commits. But that’s not all!

    Git hooks are scripts that run automatically at pre-determined points in your workflow. Use them well and you can save a ton of brainpower. A pre-commit hook remembers to do things like lint and format code, and even runs local tests for you before you indelibly push something embarrassing. Hooks can be a little annoying to share (the .git/hooks directory isn’t tracked and thus omitted when you clone or fork a repository) but there’s a framework for that: the confusingly-named pre-commit framework, which allows you to create a sharable configuration file of Git hook plugins, not just for pre-commit. I spend a majority of my time these days coding in Python, so here is my current favorite .pre-commit-config.yaml:
    fail_fast: true
    repos:
      - repo: https://github.com/pre-commit/pre-commit-hooks
        rev: v3.1.0 # Use the ref you want to point at
        hooks:
          - id: detect-aws-credentials
          - id: end-of-file-fixer
          - id: trailing-whitespace
      - repo: https://github.com/psf/black
        rev: 19.3b0
        hooks:
          - id: black
      - repo: https://github.com/asottile/blacken-docs
        rev: v1.7.0
        hooks:
          - id: blacken-docs
            additional_dependencies: [black==19.3b0]
      - repo: https://github.com/pre-commit/mirrors-mypy
        rev: v0.780
        hooks:
          - id: mypy
      - repo: local
        hooks:
          - id: isort
            name: isort
            stages: [commit]
            language: system
            entry: isort
            types: [python]
          - id: black
            name: black
            stages: [commit]
            language: system
            entry: black
            types: [python]
    
    There are lots of supported hooks to explore.

    Use a Type System

    If you write in languages like Python and JavaScript, get yourself an early birthday present and start using a static type system. Not only will this help improve the way you think about code, it can help make type errors clear before running a single line.

    For Python, I like using mypy for static type checking. You can set it up as a pre-commit hook (see above) and it’s supported in Visual Studio Code too.

    TypeScript is my preferred way to write JavaScript. You can run the compiler on the command line using Node.js (see instructions in the repo), it works pretty well with Visual Studio Code out of the box, and of course, there are multiple options for extension integrations.

    Quit Unnecessarily Beating up Your Meat-Brain

    I mean, you wouldn’t stand on your head all day to do your work — it would be rather inconvenient to read things upside down all the time (at least until your brain adjusted), and in any case, you’d probably get uncomfortably congested in short order. Working without taking advantage of the technical ergonomic tools I’ve given you today is a little like unnecessary inversion — why would you, if you don’t have to?


    下载开源日报APP:https://opensourcedaily.org/2579/
    加入我们:https://opensourcedaily.org/about/join/
    关注我们:https://opensourcedaily.org/about/love/
  • 开源日报第817期:《电梯 elevator.js》

    28 6 月, 2020
    开源日报 每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,坚持阅读《开源日报》,保持每日学习的好习惯。
    今日推荐开源项目:《电梯 elevator.js》
    今日推荐英文原文:《What Are Snowflake IDs?》

    今日推荐开源项目:《电梯 elevator.js》传送门:GitHub链接
    推荐理由:滚动页面,滚动页面,然后到底了,按一下回到顶部的按钮回到页面顶端。这个项目对这个习以为常的回到顶部功能进行了一些创意性的调整——让它表现得如同电梯上升一般,你甚至可以自定义这个电梯需要什么样的音效,对于那些需要追求独特风格的页面来说可自定义这一点就显得相当有用处了。
    今日推荐英文原文:《What Are Snowflake IDs?》作者:Nassos Michas
    原文链接:https://medium.com/better-programming/uuid-generation-snowflake-identifiers-unique-2aed8b1771bc
    推荐理由:一人一个唯一的 ID 看似不难,但是随着环境的愈加复杂,可能需要更多的手段解决这个问题

    What Are Snowflake IDs?

    How to generate unique IDs in a distributed environment at scale

    Generating unique identifiers is a task all programmers have had to deal with at some point in the course of an application’s development lifecycle. Unique IDs allow us to properly identify data objects, persist them, retrieve them, and have them participate in complex relational patterns.

    But how are these unique IDs generated and which approach works best at various scales of load? How do IDs remain unique in a distributed environment where multiple computing nodes compete for the next available ID?

    In this piece, I’ll discuss three of the most common techniques that work — from a small, single-node scale to a Twitter-scale.

    Universal Unique Identifiers — UUIDs

    Universal Unique Identifiers is a well-known concept that’s been used in software for years. A UUID is a 128-bit number that, when generated in a controlled and standardised way, provides an extremely large keyspace, virtually eliminating the possibility of collision.

    A UUID is a synthetic ID comprising of several distinct parts, such as time, the node’s MAC address, or an MD5 hashed namespace. To accommodate all these combinations there have been multiple versions of the UUID specification over the years, notably versions 1 and 4. However, other versions may be of interest to you depending on your data and business domain.

    Dealing with 128-bit numbers is not the most developer-friendly way to depict information, so UUIDs are usually represented in a canonical text form where the 16 octets (16 * 8 bits = 128 bits) are converted to 32 hexadecimal characters separated by hyphens, for a total of 36 characters:

    A sample of a v4 UUID (image by author)

    As becomes apparent, the most interesting feature of UUIDs is that they can be generated in isolation and still guarantee uniqueness in a distributed environment. In addition, the underlying ID generation algorithm is not complicated nor does it require any synchronisation (at least, down to the 100-nanosecond level), so it can be executed in parallel:

    Generating unique Ids in a distributed environment (image by author)

    The intrinsic property of self-generation uniqueness make UUIDs one of the most frequently used ID-generation techniques in distributed environments. However, keep in mind that UUIDs require extra storage and may negatively affect your querying performance.

    Persistence Layer Generated IDs

    A common approach when you don’t want to generate unique IDs at the application level is to let your persistence storage take care of it. All recent RDBMS provide some sort of a column data type allowing you to delegate the generation of a unique identifier to them. MongoDB provides ObjectID, MySQL, and MariaDB provide AUTO_INCREMENT, MS SQL Server provides IDENTITY, etc. The actual representation of the ID differs between different database implementation, however, the semantics about uniqueness remains the same.

    Persistence layer generated IDs alleviate the problem of having to generate unique IDs in application code. However, if you operate a large database cluster with a very busy application in front, this approach may not be performant-enough for your needs.

    Another practical issue when using persistence layer generated IDs is that the generated ID is not known to your code without a roundtrip to the database:

    RDBMS vs code generate Id (image by author)

    The above extra roundtrip to the RDBMS may slow down your application and can make your code look needlessly more complex, however, modern ORM frameworks can help you do this in a standardised way, irrespectively of the underlying RDBMS product you’re using.

    ID servers, or Snowflake IDs

    An ID server takes care of generating unique IDs for your distributed infrastructure. According to the implementation of your ID server, it can be a single server creating Ids or a cluster of servers creating high numbers of IDs per second.

    Twitter needs no special introduction and with an average of 9000 tweets per second and peaks as high as 143199 tweets per second, they needed a solution that not only scales across their vast infrastructure of servers but also generates IDs efficient for storage. This is how Twitter came up with the Snowflake project:
    Snowflake is a network service for generating unique ID numbers at high scale with some simple guarantees.
    Twitter was looking for a minimum of 10000 IDs per second per process with a response rate of <2ms. ID servers should require no network coordination at all between them and generated Ids should be, roughly, time-ordered. Finally, to keep storage to a minimum, IDs had to be compact.

    To solve the above project, Twitter developed the Snowflake project as a Thrift Server written in Scala. The generated Ids were composed of:
    • Time — 41 bits (millisecond precision)
    • Configured machine ID — 10 bits
    • Sequence number — 12 bits — rolls over every 4096 per machine
    Although Snowflake is now a retired Twitter project, replaced by a broader project, TwitterServer, the basic principles of how a distributed ID generator works still apply. Because of the independent nature of each generator, Twitter was able to scale its infrastructure as required, without introducing additional latency thanks to cluster synchronisation and coordination.

    A solution with an ID server works in a similar way to the code-generated IDs:
    Id server-generated Ids (image by author)

    As you may notice, performance is still degraded by the roundtrips to the ID server, however, this additional delay is considerably less than flushing an object to an RDBMS as it doesn’t involve complex database operations.

    An ID server provides a middle-ground solution, empowering you to control how and where your unique Ids are generated without introducing a complex, high latency-inducing infrastructure.

    Conclusion

    Generating unique identifiers is a necessity for all applications that eventually need to persist data.

    In this article three commonly used approaches were discussed: UUIDs — generating IDs locally, persistence layer driven IDs — centrally creating IDs, and Snowflake IDs — generating IDs as a network service.

    Choosing a strategy for generating unique IDs in your application needs to look at your data as well as your persistence option and network infrastructure. As there is no one-size-fits-all solution, you should evaluate your options and choose the one aligned to your requirements and the scale you want to achieve.

    Thank you for reading this article. I hope to see you in the next one.
    下载开源日报APP:https://opensourcedaily.org/2579/
    加入我们:https://opensourcedaily.org/about/join/
    关注我们:https://opensourcedaily.org/about/love/
  • 开源日报第816期:《PowerToys》

    27 6 月, 2020
    开源日报 每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,坚持阅读《开源日报》,保持每日学习的好习惯。
    今日推荐开源项目:《PowerToys》
    今日推荐英文原文:《Twitter challenges millions of accounts every week to determine if they’re bots or not》

    今日推荐开源项目:《PowerToys》传送门:GitHub链接
    推荐理由:windows自带的很多功能往往非常难用,因此我们不得不借助一些增强工具来弥补windows的天生缺陷.powerToys是一款使用工具的集合,包括: 设置和调整桌面窗口布局,修改键盘映射,批量重命名等功能.
    今日推荐英文原文:《Twitter challenges millions of accounts every week to determine if they’re bots or not》作者:Queenie Wong 
    原文链接:Twitter challenges millions of accounts every week to determine if they’re bots or not
    推荐理由:开小号,造水军等伪造账户的问题一直存在于各大社交软件.这其中就包括备受争议的2016年俄罗斯干预美国总统大选.因此,推特每周都要检测大量的账号来判定是否存在机器人账号.

    Twitter challenges millions of accounts every week to determine if they’re bots or not

    Twitter Chief Technology Officer Parag Agrawal said Thursday that the company challenges millions of accounts every week to determine if they’re run by a human or completely automated.

    The use of fake accounts has been a big concern for tech companies especially after revelations surfaced in 2016 that Russian trolls used social networks to sow discord among Americans during the US presidential election. Agrawal, who was speaking at the Collison from Home tech conference, said there are various categories of fake accounts that can be used by bad actors.

    Some accounts are completely automated while other accounts are bots with “humans in the loop.” There are also accounts run by humans that attempt to manipulate conversations and accounts that get compromised and then get used by bad actors.

    “Any attempt to manipulate the conversation actually applies some combination of all four of these potentially to do so,” he said.

    Outside of challenging accounts, Agrawal said that Twitter suspends millions of accounts every month before a user sees them on their timelines or in search results.

    The company uses technology, he said, to monitor the behaviors of a large number of accounts and detect patterns. Once Twitter sees “anomalies” that can’t be explained by “normal usage,” the company knows whether or not it should investigate certain accounts.

    Figuring out whether a Twitter account is fake, he said, isn’t always easy because there are accounts with no profile picture and a limited number of tweets that look like bots but they’re actually run by humans. Twitter also allows users to use pseudonyms.

    Still, he said, it isn’t the accounts that look fake that are potentially the most problematic.

    “The most dangerous fake accounts actually don’t look fake on the surface,” he said.
    下载开源日报APP:https://opensourcedaily.org/2579/
    加入我们:https://opensourcedaily.org/about/join/
    关注我们:https://opensourcedaily.org/about/love/
  • 开源日报第815期:《3D图片 3d-photo-inpainting》

    26 6 月, 2020
    开源日报 每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,坚持阅读《开源日报》,保持每日学习的好习惯。
    今日推荐开源项目:《3D图片 3d-photo-inpainting》
    今日推荐英文原文:《Ideas Are the Only Tool You Need》

    今日推荐开源项目:《3D图片 3d-photo-inpainting》传送门:GitHub链接
    推荐理由:该项目能将深度图像 RGB-D 转换为3D图像,其原理主要是运用基于机器学习的修复模型将新的区域颜色和深度内容将原来的部分遮挡,然后利用动态视差的原理合成3D图片。
    今日推荐英文原文:《Ideas Are the Only Tool You Need》作者:Frank the man
    原文链接:
    推荐理由:设备不是最重要的,重要的是使用设备的人。

    Ideas Are the Only Tool You Need

    Stop chasing the latest technology and focus on what you can learn

    I have a friend photographer. I mean, photography is not his full-time job, yet. He’s balancing a daily job together with his real passion, photography and I really admire him for that.

    He’s a bit nerdy and every time our conversation gravitates around the topic of photography he can’t help but talk about the next, latest, shiniest gear he’s currently looking at. Every year he needs to renovate his arsenal, in the hope to become the best photographer of all, but I honestly often wonder if it’s really the tools that would make him better in his pursue, rather than honing the techniques and creative ideas in order to stands out from the mass.

    I’m not a photographer myself, so I don’t really know. It is probably my way of thinking, coming from design education.

    One of the most valuable lessons I got from one of my teachers from College was: “ It doesn’t matter how expensive and sophisticated your tools are, the only thing that makes any difference is your mind and ideas.”
    He was a teacher in digital publishing and design. Back in the 90s, he exploited the interactive power of PDFs to revolutionize the concept of magazines and their fruition, and all his career followed the idea of finding the unexplored edges of new tools and technologies to create new concepts out of it.

    At that time, the content industry was trying to make sense of new consumer tools, such as iPads to develop new formats. One of the best examples of this wild creative exploration was a short-lived magazine called Katachi, which aged pretty well still now.

    The tools behind these new forms of entertainment and communication were in the early stages and fairly simple. In fact, the ideas and creativity behind them were the only main engine.

    That teacher showed us that most of the time we already have the tools to develop something new and creative, we just have to look at them in a different way. Just search in your pocket: you already have the capability of a full-fledged computer at your fingertips. Something not even Apollo’s astronauts and researches could even dare to dream.

    The only difference is how we use all this power. Some would use it for searching cute images of kitties. Some other would fly people to the moon. Is just a matter of priorities, after all.
    I use these examples to remind myself sometimes that I don’t have to put up so many excuses to avoid chasing my dreams and aspirations. Most of the time is only fear that holds us back, not the lack of tools or knowledge.

    That was back in 2010. Flash forward to today: is twentytwenty. Excuses don’t work anymore today.

    • You wanna get new knowledge? There are countless resources, free and widely available. There are online courses, such as Skillshare or Udemy. Just take one of them and follow through. Consistency and commitment are the only criteria to make them fruitful.
    • You wanna become a photographer? Don’t wait to get the latest gear, the latest impossible-to-live-without-new-polarize-filter for your camera. Just grab your phone and start right now. Maybe the first shots will look like Kevin’s famous Chili on the floor, but that’s okay. This first experience will teach you maybe how to better optimize natural light and backgrounds, or maybe to exploit new creative ideas to make it good and original the next time.
    • You wanna become a film-maker? Yes, you don’t have to wait to be Michel Gondry to start something on your own. Or.. wait! Maybe you can. In fact, one of his latest movies, Détour, was actually shot using an iPhone.
    You see, is not really a matter of gears and big investments anymore. Is rather a question of willingness and commitment to your ideas.
    The most inspiring example of this comes from the unexpected town of Kaduna, Nigeria. There, a bunch of young creatives started to produce and develop their own sci-fi movies, with amazing results.

    The collective is called Critics Company, “a bunch of teenagers in northern Nigeria trying to change the narrative”, and they’ve released a few good feats on Youtube already, rising quickly to popularity. Their aspiration was to reach Nollywood Industry. They didn’t wait for the opportunity to come, they run forward to grab it!

    How they did it? They watched Youtube tutorials, created a makeshift studio in their garage, and just kicked it! Excuses weren’t enough to stop them, not even the legendary Nigerian slow connection.

    “No costs are involved as they do everything themselves but they have to keep their works short — or it would take too long to upload.”
    And you know what? Their work hasn’t flown by unnoticed since they’ve become the first Nigerians to get nominated for a Webby Award.

    Another great, great example of the limitless power of ideas comes from Tatsuo Horiuchi, the self-taught excel painter. Tatsuo was already retired when he decided he wanted to start painting digitally. He didn’t have the tools and resources to buy high-end software. But this didn’t stop him.

    In fact, he used the tools he already had and known well, such as Microsoft Excel, and radically transformed a tool for tables, statistics, and analysis in a powerful generator of illustrations. Nobody in the world has ever thought to do what he did, and that’s why Tetsuo now stands out from anyone other in the world, creating a new genre of art on its own.

    Just a reminder to everyone that nothing can stop the power of good ideas.

    So what are you waiting for? Don’t let your ideas sit only in your brain. Nobody will make your best ideas come true for you, you have to do this part. Grab a tutorial and the best tools you already have, and make wonders out of them.

    The entire world needs better ideas, not more tools.


    下载开源日报APP:https://opensourcedaily.org/2579/
    加入我们:https://opensourcedaily.org/about/join/
    关注我们:https://opensourcedaily.org/about/love/
←上一页
1 … 54 55 56 57 58 … 262
下一页→

Proudly powered by WordPress