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

开源日报

  • 开源日报第862期:《寓教于乐 blockly-games》

    12 8 月, 2020
    开源日报 每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,坚持阅读《开源日报》,保持每日学习的好习惯。
    今日推荐开源项目:《寓教于乐 blockly-games》
    今日推荐英文原文:《8 Unheard Browser APIs You Should Be Aware Of》

    今日推荐开源项目:《寓教于乐 blockly-games》传送门:项目链接
    推荐理由:这个项目是 Google 推出的面向儿童的编程入门游戏教学,通过图形来介绍各种在编程中常见的概念,游戏之间环环相扣,到了最后的池塘大战就已经是对初学者来说相当有挑战的难度了。不过,让儿童早早进行编程的学习究竟是好还是坏,现在看来并没有一个标准答案。
    今日推荐英文原文:《8 Unheard Browser APIs You Should Be Aware Of》作者:Mahdhi Rezvi
    原文链接:https://medium.com/better-programming/8-unheard-of-browser-apis-you-should-be-aware-of-45247e7d5f3a
    推荐理由:一些 web 开发人员会感兴趣的实验性浏览器 API

    Experimental browser APIs that have the potential to change the way we develop web apps

    With the increase in popularity, browsers started shipping APIs for complex functionalities that sometimes can only be implemented via a native application. Fast-forward to the present: It’s indeed quite rare to find a web application that doesn’t make use of at least one browser API.

    As the field of web development continues to grow, browser vendors also try to keep up with the rapid development around them. They constantly develop newer APIs that can bring new nativelike functionalities to your web application. Furthermore, there are some APIs that people don’t know much about, even though they’re fully supported in modern browsers.

    Here are some APIs you should be aware of — as they will play a vital role in the future.

    The Web Locks API

    This API allows you to run a web application on multiple tabs to access and coordinate resource sharing. Although it’s quite uncommon for simple everyday web applications to run on multiple tabs, there can be advanced use cases where you’d need to run multiple browser tabs of a web application and keep them synced. This API can come in handy at those instances.

    Although APIs such as SharedWorker, BroadcastChannel, localStorage, sessionStorage, postMessage, unload handler can be used to manage tab communication and synchronization, they each have their shortcomings and require workarounds, which decreases code maintainability. The Web Locks API tries to simplify this process by bringing in a more standardized solution.

    Even though it’s enabled by default in Chrome 69, it’s still not supported by major browsers such as Firefox and Safari.

    Note: You should know your way around concepts like deadlocks to avoid falling into one when using this API.

    The Shape Detection API

    As a web developer, you’ve probably had many instances requiring the installation of external libraries to handle the detection of elements such as faces, text, and barcodes in images. This was because there was no web standard API for developers to utilize.

    The Chrome team is trying to change this by providing an experimental Shape Detection API in Chrome browsers and making it a web standard.

    Although this feature is experimental, it can be accessed locally by enabling the #enable-experimental-web-platform-features flag in chrome://flags.

    The Payment Request API

    The Payment Request API helps customers and sellers complete the checkout process more seamlessly. This new approach eliminates checkout forms and improves the user’s payment experience from the ground up. With support for Apple Pay and Google Pay, this API can be expected to be a major component in the e-commerce sector.

    Furthermore, as the credentials are managed in the browser, it’s easier for the customer to switch from mobile to desktop browsers and still access their card information. This API also allows for customization from the merchant’s end. You can mention the supported payment methods and supported cards and even provide shipping options based on the shipping address.

    The Page Visibility API

    It’s quite common for you to come across a PC with around 20 odd tabs opened in the browser. I once had a friend who just closed around 100+ tabs, after fixing a bug. Browsers have even started to implement features to group your tabs to make them more organized.

    With the help of the Page Visibility API, you can detect whether your web page is idle or not. In other words, you can find out whether the tab that contains your web page is being viewed by the user.

    Although this sounds straightforward, it can be very effective in increasing the user experience of a website. There are several use cases where this API can be used.
    • Download the remainder of the application bundle resources and media resources while the browser tab is inactive. This will help you use the idle time very efficiently.
    • Pause videos when the user minimizes or switches to another tab.
    • Pause the image slideshow/carousal when the tab is inactive.
    Although developers have used events such as blur and focus on the window in the past, they didn’t tell whether your page was actually hidden to the user. The Page Visibility API helped addresses this issue.

    This browser API is compatible with most browsers.

    Source: MDN Docs

    The Web Share API

    The Web Share API allows you to share links, text, and files to other apps installed on the device in the same way as native apps. This API can help increase user engagement with your web application. You can read this blog post by Joe Medley to learn more about this cool API.

    As of mid-2020, this API is only available on Safari and on Android in Chromium forks. The MDN has more details regarding browser compatibility.

    The Web Share Target API

    Progressive web apps are changing the way we understand applications by providing an applike experience in the web form. According to the website StateOfJS, around 48.2% of users have used PWAs and 45.5% of users are aware of what PWAs are. This shows the impact of PWAs. You can read more about PWAs in my article over here.

    Although PWAs have many nativelike features, they lacked a way to receive files from native apps. This API allows you to receive links, text, and files from other native applications. It’s supported on Chrome 76 and above for Android only. You can read more about this API over here(https://web.dev/web-share-target/).

    The Push API

    The Push API allows web applications to receive messages pushed to them from a server, regardless of whether the app is in the foreground or not. It can work even when the app isn’t loaded on a browser. This enables developers to deliver asynchronous notifications to the user in a timely manner. But for this to work, the user permission should be obtained prior to the API being used.

    You can read more about the Push API in this awesome article by Flavio(https://flaviocopes.com/push-api/).

    The Cookie Store API

    Working with cookies is known to be a bit slow, as it’s synchronous. But the Cookie Store API provides asynchronous access to HTTP cookies. Furthermore, this API also exposes these HTTP cookies to service workers.

    Although there are helper libraries to facilitate all of the usual cookie operations, with the Cookie Store API, it’ll be much easier and more performant. This API is also sometimes referred to as the Async Cookies API.

    You can read more about this API over here(https://wicg.github.io/cookie-store/explainer.html).

    Conclusion

    I was surprised by how cool the above APIs were when I played around with them. The only letdown of the above APIs, as mentioned before, is the lack of support from major browsers. This means it’s not simple to use these in production. But it can be assured that these APIs will definitely play a vital role in the future of browsers and web development.

    Thank you for reading, and happy coding.
    下载开源日报APP:https://opensourcedaily.org/2579/
    加入我们:https://opensourcedaily.org/about/join/
    关注我们:https://opensourcedaily.org/about/love/
  • 开源日报第861期:《public-apis》

    11 8 月, 2020
    开源日报 每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,坚持阅读《开源日报》,保持每日学习的好习惯。
    今日推荐开源项目:《public-apis》
    今日推荐英文原文:《COVID contact tracing apps bring privacy pitfalls around the world》

    今日推荐开源项目:《public-apis》传送门:项目链接
    推荐理由:本项目列举了非常丰富的开源免费的API来助力你的软件和网站开发. 你只需要找到自己需要的内容, 点击超链接就可以到那些API的官网进行体验.
    今日推荐英文原文:《COVID contact tracing apps bring privacy pitfalls around the world》作者:Laura Hautala
    原文链接:https://www.cnet.com/news/covid-contact-tracing-apps-bring-privacy-pitfalls-around-the-world/
    推荐理由:随着新冠病毒的不断传播, 全球各地的政府部门开始推出一些追踪人们轨迹的app. 这虽然降低了传染风险, 但同时也可能会收集一些不必要的隐私, 跟人们的生活带来困扰.

    COVID contact tracing apps bring privacy pitfalls around the world

    Public health experts rushed to create contact tracing apps in countries all over the world this spring. They serve an important purpose in determining who might’ve been exposed to the novel coronavirus so they can be tested and isolated. But the risks were clear too. Contact tracing apps have the power to amass personal data that reveals your movements, activities and relationships.

    The potential harm from contact tracing apps came into focus at Defcon, an annual gathering of hackers that’s taking place online this week. Two presentations focused on the privacy failings of contact tracing apps. The verdict is clear: The apps have a tendency to collect information they don’t need.

    This data-hungry mindset isn’t how governments should approach contact tracing apps, said Eivind Arvesen, a security researcher from Norway who presented at Defcon on Friday. Instead, they should be asking themselves, “How little data can I get away with to try to solve this concrete issue, and no more?”

    Arvesen presented on Norway’s now-defunct contact tracing app, which he helped review as part of a government funded third-party audit. Another presentation, on Saturday, will focus on the permissions asked for by contact tracing apps, as well as COVID-19 symptom tracking and information apps.

    Human contact tracers usually hunt down the known contacts of someone who tests positive for a contagious disease like COVID-19. Apps seek to fill in the blanks as to where a contagious person has exposed a stranger to a disease. As two strangers stand near each other, for example, the apps record that contact in case either of them tests positive in the days that follow. For the apps to be effective, a high percentage of the population has to use them.

    As soon as public health agencies turned to apps to augment the contact tracing process, privacy experts warned of risks. Governments should be transparent about the data they take from phones, avoid collecting unnecessary data, and also plan to end the collection and delete the data when the pandemic passes. Universities, including MIT, and tech companies, like Apple and Google, jumped to create privacy-respecting software that governments could use in their apps.

    Norway’s contact tracing app

    Arvesen said Norway’s app collected location data and one, unchanging identification code for users, creating a permanent and thorough record of their movements to be stored centrally on a server. That might actually sound ideal for contact tracers, but privacy experts say that collecting location data is unnecessary and should be avoided. Where two people were when they met doesn’t matter. All that counts is that they met.

    It also isn’t necessary to give one user a single, unchanging identifier. Other apps have found ways to avoid this, with some protocols changing the user’s identifier as often as once a minute. This approach makes it much harder for someone to abuse the data, using it to track one person’s movements while using the app.

    Finally, some apps store the data locally on the user’s phone and access it only if that person tests positive and agrees to share the data.

    As Arvesen and his fellow reviewers prepared their report on Norway’s app, regulators from the country’s Data Protection Authority signaled they were also concerned. Then, the country shut down the app.

    Apps around the world take location data

    Arvesen said he found the app to be worse on privacy than other contact tracing apps in Europe. But data-hungry apps exist elsewhere in the world. The creators of COVID-19 App Tracker, who are presenting their findings on Saturday, automatically scanned 136 apps from countries around the world and found that most of them ask for permissions they don’t need.

    Of the apps scanned, three quarters asked for location data, said Megan DeBlois, a co-creator of the website. Some of the apps simply help users keep track of their symptoms, and have no reason to ask for location data.

    DeBlois teamed up with her brother and their respective partners to create the app tracker, and all are volunteers. The goal of the project is to capture information about every governmental COVID app on the Google Play store and make it publicly available.

    Permissions are only part of the picture. To really understand how an app behaves, researchers have to look at the data it sends and receives when it’s in use. Security auditors like Arvesen can do that on behalf of governments.

    DeBlois said she’d like to see more transparency about the data used in contact tracing apps. Ideally, governments would make the code open-source, making it easy for privacy researchers to analyze it and flag any problems for the general public.

    One possible reason governments haven’t done this is the speed with which they’ve had to create the apps. The rush could’ve prompted governments to set aside security reviews that would normally take place before software gets deployed to users. Open-source code would then make it easy for bad actors to look for obvious flaws and exploit them.

    Without the reviews, DeBlois and Arvesen both said, users can’t trust that the government is taking only the data it needs, and keeping it safe.

    “We want people to look at the code,” DeBlois said. “You can verify it through the code, build that trust.”
    下载开源日报APP:https://opensourcedaily.org/2579/
    加入我们:https://opensourcedaily.org/about/join/
    关注我们:https://opensourcedaily.org/about/love/
  • 开源日报第860期:《手焊键盘 python-keyboard》

    10 8 月, 2020
    开源日报 每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,坚持阅读《开源日报》,保持每日学习的好习惯。
    今日推荐开源项目:《手焊键盘 python-keyboard》
    今日推荐英文原文:《Your Code Should Read Like a Book》

    今日推荐开源项目:《手焊键盘 python-keyboard》传送门:GitHub链接
    推荐理由:作者手焊了一个 Python 代码实现的 USB 蓝牙双模键盘,并提供了手把手设计(焊接)教程。跑 Python 的键盘,不仅是个键盘,也是一个U盘,键盘的 Python 代码则保存在U盘中,可以用任意文本编辑器修改 Python 代码,无需配置任何开发环境,也就是说,可以自己设计键盘的功能。目前该项目的成品已经登陆淘宝。
    今日推荐英文原文:《Your Code Should Read Like a Book》作者:Zachary Minott
    原文链接:https://medium.com/better-programming/your-code-should-read-like-a-book-873b27f71fe5
    推荐理由:优美整洁的代码令人赏心悦目,杂乱无章的代码……还是忘了它吧。

    Your Code Should Read Like a Book

    It makes life easier for everyone involved

    There’s a pandemic among programmers. Long functions, broad and nondescriptive names for functions, classes, and variable names, overly commented code, disorganized structure, and a lack of overall streamlined flow.

    It’s much too often that I take a peek at someone else’s working code just to notice that I have to exert a strenuous amount of effort just to understand what it does in the first place.

    I have to try my best to reason about ambiguous variable names such as i, k, num, counter, etc. What type of num are we representing, and what is the purpose of the operations that surround it? What is the purpose of the counter? What is it tracking? Why is it there?

    I have to constantly jump all over the class to see how each function builds on top of the other functions around it, just to realize that the names of each function don’t really tell me anything about what the function does.

    I’d even have to sometimes read paragraphs of comments that explain the purpose of what a function might do, but still, I shouldn’t have to be reading an essay to simply understand what a function does. I should be able to reason about this simply by taking a quick glance at the function.

    Your code should read like a book. Just how a book is structured through paragraphs and chapters that follow a descriptive story that flows in a streamlined and progressive fashion, your code should be structured and designed in a way that I can enter into a class and be able to understand its purpose within moments of engagement. Please don’t make any developer, including yourself, who is looking at your code have to embody Sherlock Holmes in order to deduce the purpose and meaning behind what you wrote.

    What exactly should you do?

    Self Commenting Code Through Meaningful Names

    Code should be self-commenting, which means that the names of your functions, your classes, and your variables should be so descriptive that commenting would be completely unnecessary. A sure sign of poorly written code is matched with its need to have comments.

    Stop abbreviating names (unless the translation of the abbreviation is blatantly obvious), stop using letters as variables, and start writing names with the intent to describe exactly what that function’s or variable’s purpose is. The names must be both intention-revealing and pronounceable.

    In essence, don’t just write code that only a computer will read. Write code that is human-readable as well. This is extremely simple in practice, but you’ll find that you will become a lot more thoughtful about the naming of everything you write and it’ll allow you to better reason about the intent of what you are programming which ultimately will influence fluid production of your code.

    “A long descriptive name is better than a short enigmatic name. A long descriptive name is better than a long descriptive comment.” ― Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship
    If you still don’t understand, here is a simple example of me populating a picklist with values (language is in Salesforce’s Apex, but you should still understand the gist of what I’m trying to convey):
    public static final Integer YEARS_IN_SCHOOL = 12;
    public static final Integer GRADUATION_MONTH = 6;
    private List<Integer> getGradYearPicklistValues() {
        List<Integer> gradYearValuesList 
                = new List<Integer>();
        Integer earliestYearInPicklist = Date.today().year();
        Integer latestYearInPicklist 
                = earliestYearInPicklist + YEARS_IN_SCHOOL;
        if (Date.today().month() >= GRADUATION_MONTH) {
            earliestYearInPicklist += 1;
            latestYearInPicklist += 1;
        }
        for (Integer year = earliestYearInPicklist; year <= latestYearInPicklist; year++) {
            gradYearValuesList.add(year);
        }
        return gradYearValuesList;
    }
    
    As you can see, I use very descriptive variable names and use descriptive function names so that we know exactly the purpose of each variable, and what the purpose this function serves. It becomes very easy for other developers to reason exactly what this function is doing.

    Organized Top-Down Code Structure

    The way you format your code serves as a direct indicator of the amount of thoughtfulness, attention to detail, and effort put into writing it. When others come to review your code, you want them to be struck with the impressive neatness, orderliness, and readability of the code. The last thing you want is to deliver a monolithic wall of scrambled, unorderly code that at a glance looks like it was written while being hammered off of White Claws and Bud Lights. This only leads to the conclusion that no thought or attention to detail was put into the code whatsoever, which ultimately reflects poorly on you.

    The way you should format your code is best explained by the Newspaper Metaphor in Robert C Martin’s Clean Code (a book all programmers should read, by the way):

    “Think of a well-written newspaper article. You read it vertically. At the top, you expect a headline that will tell you what the story is about and allows you to decided whether it is something you want to read. The first paragraph gives you a synopsis of the whole story, hiding all the details while giving you the broad-brush concepts. As you continue downward, the details increase until you have all the dates, names, quotes, claims, and other minutiae. We would like a source file to be like a newspaper article.”

    What does this tell us? Our class name is our headline — it’s going to describe the contents of what we can find inside the class. At the top of the class is where we are going to find our high-level concepts and algorithms and as we traverse down the class we should be seeing the details increase and increase until we find ourselves at the lowest level function.

    How do we follow this structure? Well, it’s very easy, actually. We essentially want the most important details to come first and express those concepts downward with the most precise and concise details. Any function that is called should be placed right below the function that is doing the calling. If a function is too large (my rule of thumb is to keep functions below 20–25 lines), break it up into smaller bite-size functions that provide complete clarity about what a few lines of code are processing. Normally large functions indicate that function is doing too much and that it is starting to get messy, so that’s why we do this. To be more descriptive. To be more neat and orderly.

    Takeaway

    Programming is very mentally challenging work as it is, and I understand how the importance of great readable code can easily be ignored given that we become so engulfed in the act of programming that we completely forget about the art and design of it. Take a step back and think about what you’re doing — the intention, the neatness, and its readability. It’ll not only help you understand the code you write more but help others understand it better as well. Ultimately, you’ll become a better and more revered programmer because of it. Who knows, you may get some praise for producing something beautiful.


    下载开源日报APP:https://opensourcedaily.org/2579/
    加入我们:https://opensourcedaily.org/about/join/
    关注我们:https://opensourcedaily.org/about/love/
  • 开源日报第859期:《自动流程图 js-code-to-svg-flowchart》

    9 8 月, 2020
    开源日报 每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,坚持阅读《开源日报》,保持每日学习的好习惯。
    今日推荐开源项目:《自动流程图 js-code-to-svg-flowchart》
    今日推荐英文原文:《4 Ways to Ask Better Questions as a Software Engineer》

    今日推荐开源项目:《自动流程图 js-code-to-svg-flowchart》传送门:项目链接
    推荐理由:回忆一下开始学程序时老师(如果有的话)给你的任务吧,你得写个程序,再为它专门画个流程图……但是现在已经有了新的解决方案。这个项目根据你提供的 JS 代码可以自动生成一个 SVG 代码流程图,用于教育新人读懂仓库里那一大堆代码这样急切需要代码可读性的场合自然再好不过,至于拿去交作业嘛,如果你确定你不会被老师教育的话可以试试看。
    今日推荐英文原文:《4 Ways to Ask Better Questions as a Software Engineer》作者:Devin Soni
    原文链接:https://medium.com/better-programming/4-ways-to-ask-better-questions-as-a-software-engineer-a342ffc251a1
    推荐理由:在向别人求助之前,先把自己能做的都做好可是基本常识

    4 Ways to Ask Better Questions as a Software Engineer

    How to stop asking bad questions

    No matter how experienced you are, everyone eventually has to ask someone else a question at work.

    However, not all questions are made equal.

    The thing that separates people is how they ask their questions.

    By following the tips below, you can ensure that you are being respectful of others’ time and maximizing your chance of getting the answer you need.

    1. Research Beforehand

    Before asking for help, try to find a solution yourself. While you should not feel afraid to ask questions, you should also be respectful of others’ time and first try to see if you can do it on your own.

    The key here is to timebox your investigation to a set amount of time. Exactly how long you should wait is up to you and your company’s culture, but typically this should be between 30 minutes and a few hours.

    If you repeatedly ask questions that can be answered with a few minutes of research, you will probably end up being overly reliant on others and deprive yourself of the opportunity to develop your searching skills. Conversely, if you often waste hours or days searching for answers that others could have told you within a few minutes, your productivity and your team’s productivity will suffer.

    Finding this balance is an important component of developing your own skills while still remaining productive.

    2. Give Context

    Once you have determined that you should be asking your question, it helps to provide as much context as possible to the person who will answer your question.

    Consider these two ways of asking the same question:
    • “My deploy failed. Can you help?”
    • “My deploy on service X failed with Y error message in the logs. The most recent change I made was Z. Can you help take a look? You can view the logs at [link] and you can view the pull request for my change at [link].”
    With the first approach, you are either going to get no response or force the person you are asking to have a lengthy back-and-forth with you while they try to clarify the problem and get context.

    With the second approach, the person you are asking hopefully has enough context to understand the problem and can begin helping you out.

    In order to save everyone’s time and increase the chances of getting an answer, it is always helpful to provide as much context as possible. The person you are asking is not all-knowing and will probably need to spend some time of their own investigating, so giving them a head start makes a big difference.

    3. List What You’ve Tried So Far

    In addition to providing context, it also helps to tell the person you are asking what you have already tried. If you followed Step 1 and did your own research before asking the question, you should have some solutions you have already tried or at the very least a list of things you searched for.

    In a similar vein to providing context, by telling them what you have done already, this removes some of the back-and-forth while they are helping you. If they know certain approaches did not work, they can more easily identify methods that would work. They might also realize that you have already tried every approach that they know of, so they know that they need to redirect you to someone else who has more expertise.

    4. Write Down the Answer

    Finally, once you’ve asked your question and hopefully gotten an answer, make sure that you write down the answer somewhere. It’s perfectly fine not to know everything, but if you have to ask the same question more than once because you didn’t write down the answer, you aren’t being respectful of others’ time.

    In addition, consider adding the answer to public documentation or some other knowledge-sharing platform like Stack Overflow. It’s unlikely that you will be the only person to ever ask this question or run into this issue, so by making the solution public knowledge, you can save others time in the future.

    Cultivating a company culture of knowledge sharing and public documentation is important, as it helps people onboard quickly and reduces interruptions throughout the day.
    下载开源日报APP:https://opensourcedaily.org/2579/
    加入我们:https://opensourcedaily.org/about/join/
    关注我们:https://opensourcedaily.org/about/love/
←上一页
1 … 43 44 45 46 47 … 262
下一页→

Proudly powered by WordPress