> 2021年04月23日信息消化 ### 每天学点算法 这个问题是由Facebook提出的。给定一个能生成1到k(包括)之间完全随机的数字的函数,其中k是一个输入,请写一个函数,**只用交换**来洗一副数组牌。 This problem was asked by Facebook.Given a function that generates perfectly random numbers between 1 and k (inclusive), where k is an input, write a function that shuffles a deck of cards represented as an array using only **swaps**. It should run in O(N) time. ```python # https://akashravichandran.github.io/dcp/ from random import randint NUM_CARDS = 52 def get_random_number(k): return randint(0, k) def shuffle_card_deck(): cards = [x for x in range(NUM_CARDS)] for old_pos in cards: new_pos = old_pos + get_random_number(NUM_CARDS - old_pos - 1) temp = cards[new_pos] cards[new_pos] = cards[old_pos] cards[old_pos] = temp return cards for _ in range(10): assert all(x in shuffle_card_deck() for x in range(NUM_CARDS)) ``` ### 其他值得阅读 #### 高级软件工程师的五大技能 原文:[The Top 5 Skills of Senior Software Engineers](https://levelup.gitconnected.com/the-top-5-skills-of-senior-software-engineers-deadb0bc3bde) ##### 1. Ownership | 自主权 领导者在生活中最基本的一个方面就是不断地实践所有权。在《极端的主人翁精神》中,退役的海豹突击队军官Jocko Willink详细介绍了他在美国海豹突击队20多年的经验教训。在书中,乔科讲述了领导者是一个团队--或一个公司--是否会成功的最终因素的故事。 "极端所有权的核心是最基本和最重要的真理:没有坏的团队,只有坏的领导者。" - Jocko Willink > One of the most fundamental aspects of leaders in life is the practice of constant ownership. In [Extreme Ownership](https://bookshop.org/a/21935/9781250183866), retired Navy SEAL officer Jocko Willink details the lessons of over 20 years in the U.S. Navy SEALs teams. In the book, Jocko recounts stories of leaders being the ultimate factor of whether not a team — or a corporation, will succeed. > > “The most fundamental and important truths at the heart of Extreme Ownership: there are no bad teams, only bad leaders.” — Jocko Willink 如果一个初级工程师没有达到票据的验收标准,那是因为你作为领导没有花时间解释并确保它被理解。 如果你的某个队友很难联系上,那是因为你没有明确什么时候可以联系上,以及需要多长时间的沟通。 如果有问题的代码进入了生产,那是因为你没有适当地花时间去评估代码审查。 作为一名高级软件工程师,就是要把注意力放在你能控制的事情上,并利用这种力量把别人提高到更高的水平。 > If a junior engineer doesn’t meet acceptance criteria for a ticket, it’s because you as the leader did not take the time to explain it and make sure it was understood. > If one of your teammates is difficult to contact, it’s because you did not clarify when to be available and how often communication is required. > If buggy code makes it to production, it’s because you didn’t properly take the time to evaluate a code-review. > Being a senior software engineer is all about focusing on what YOU can control, and taking that power to raise OTHERS to a higher level. ##### 2. 沟通 | Communication 能点。但是,如果这一点在任何地方都被列出,你为什么不不断尝试改进呢?随着公司转向完全的远程工作,技术领域正在发生翻天覆地的变化。为了成为一名高级工程师,现在比以往任何时候都更需要磨练你的沟通技巧。 提高沟通技巧的第一步是保持你的写作清晰和简洁。通过文字向别人表达你的想法可能是出乎意料的困难--尤其是在工程方面。你可以通过Slack等渠道积极努力地进行沟通,但要在你的信息后面加上 "这有意义吗?"或 "有什么更好的方式来表达吗?"。你的队友应该很乐意提供反馈,因为这让每个人的生活更轻松。 > Yep, gotta hit the most overstated skill-point in any article that tells you how to excel at your career. But if this point is listed everywhere, why don’t you constantly try to improve on it? The technology space is seeing a radical change as companies shift to fully remote work. It is more important now, more than ever, to hone in on your communication skills in order to become a senior engineer. > The first step to improving your communication skills is to keep your writing clear and concise. It can be surprisingly difficult to articulate your thoughts to someone else over text — especially in an engineering context. You can actively work on your communication over channels like slack but following up your messages with, “does that make sense?” or, “is there a better way to phrase that?”. Your teammates should be happy to give feedback, as it makes everyone’s lives easier. ##### 3. 消除你的自负 | Remove Your Ego 一个伟大的领导者总是能够谦虚地向别人学习。如果你的一个队友告诉你,有一个新的测试框架,可以做所有你花哨的自定义测试,但以标准化和可重用的方式,不要为你的代码辩护,而是感谢你的队友让团队变得更好。这不是关于你的代码,而是关于团队的代码。 > Instead, a great leader is always able to humble themself to learn from others. If one of your teammates tells you that there’s a new testing framework that does everything your fancy custom tests do but in a standardized and reusable manner, **don’t get defensive of your code** and instead thank your teammate for making the team better. It’s not about your code, it’s about the team’s code. ##### 4.学习如何写出好的文档 | Learn How to Write Awesome Documentation 你应该一直努力写出干净简洁的代码,但偶尔你也会需要留下评论。你还需要记录如何使用你的新API。而如果你的新产品没有任何架构文档,看看当需求发生变化时,这能让你走多远。 此外,如果你想创建更好的定义票据,你需要关注谁-什么-为什么-什么时候-什么方法,然后再关注一些。你应该问自己,然后在你的票据文档中回答的常见问题是:为什么我们需要这个变化?这些变化将在哪些项目中发生?创建这一变化的高级技术步骤是什么? > You should always try to write clean and concise code, but occasionally you’re gonna need to leave a comment. You also need to document how to work with your new API. And if your new product doesn’t have any architecture documentation, see how far that gets you when requirements change. > In addition, if you want to create better defined tickets, you need to focus on the **who-what-why-when-how and then** some. Common questions you should ask yourself, and then answer in your ticket documentation, is why do we need this change? Which projects will these changes take place? What are the high-level technical steps to create this change? > Creating better flow diagrams is also huge. #### 掌握这三项技能以改善时间管理 ???? 原文:[Master These Three Skills to Improve Time Management ????](https://beyond-average.hashnode.dev/master-these-three-skills-to-improve-time-management) ##### Develop Self-Awareness | 培养自我意识 我们中的大多数人一定读过几本生产力方面的书和一打关于80/20法则或吃青蛙的文章,但我们中只有少数人采取行动,审查我们的时间管理习惯并采用新的习惯。为什么呢?因为我们大多数人都没有足够的自我意识。 > Most of us must’ve read a few productivity books and a dozen of articles about the 80/20 Rule or Eating the Frog, but only a few of us take action to review our time management habits and adopt the new ones. Why? Because most of us are not self-aware enough for that. 自我意识是意识到、控制和表达自己情绪的能力。如果我们能调节自己的情绪,我们就能清楚地了解自己的长处、弱点和局限性,了解我们收集和处理信息的方式以及处理压力的情况。在时间管理方面,自我意识为我们的行为和技能奠定了基础,包括目标设定、沟通、激励、压力和时间管理。只要我们了解自己的倾向和局限性,我们就可以选择适当的时间管理策略,为我们提供最佳服务。自我意识是意识到、控制和表达自己情绪的能力。如果我们能调节自己的情绪,我们就能清楚地了解自己的长处、弱点和局限性,了解我们收集和处理信息的方式以及处理压力的情况。在时间管理方面,自我意识为我们的行为和技能奠定了基础,包括目标设定、沟通、激励、压力和时间管理。只要我们了解自己的倾向和局限性,我们就可以选择适当的时间管理策略,为我们提供最佳服务。 > Self-awareness is the capacity to be aware of, control, and express your emotions. If we can regulate our emotions, we can clearly understand our strengths, weaknesses, and limitations, the way we gather and process information and handle stressful situations. In terms of time management, self-awareness lays the foundation for our behavior and skills including goal setting, communication, motivation, stress and time management. As long as we understand our inclinations and limitations, we can choose appropriate time management strategies that will serve us best. ###### Master Goal Setting & Reflection | 主目标设定与反思 - Get some perspective. 如果你专注于你的目标和愿景,它将为你的日常工作带来更多意义,并增强你的信心。 - Develop an action plan. 制定一个行动计划。在你确立了下一个目标或项目的愿景后,你需要把它分解成符合SMART标准的可管理的步骤:具体、可衡量、可实现、相关(现实)和有时限。 - Reflect on your progress. 反思你的进展。 - Ask for feedback. 征求反馈意见 ###### Leave Out Low-Output Activities | 抛开低产出的活动 - Identify unproductive activities. 识别非生产性活动。使用你的时间跟踪数据来识别那些无助于项目成功的任务,你可以在对结果几乎没有损害的情况下取消这些任务。 评估任务的重要性。即使你正在执行任务,并注意到它已经花费了太多的时间,也要退后一步,评估其重要性和结果。 ###### Use Your Energy Wisely | 明智地使用你的能量 - Focus on the end result. 专注于最终结果。 - Use peak performance time. 利用巅峰表现时间。 - Get comfortable with imperfection. 适应不完美。 - Practice self-care. 练习自我护理。 ##### Improve Your Time Assessment Skills | 时间评估技能 - **Estimate your activities.** When planning your next task, project or Sprint, estimate these items for future productivity analysis. - 估计你的活动。当计划你的下一个任务、项目或冲刺时,估计这些项目,以便将来进行生产力分析。 - **Allow for some buffer time.** Buffer time takes into account unexpected circumstances that should be included in your estimations. - 留出一些缓冲时间。缓冲时间考虑到了意外情况,应该包括在你的估计中。 - **Use time tracking software**. Upload your tasks and time estimates into your time tracker and record time against them. - 使用时间跟踪软件。将你的任务和时间估计上传到你的时间追踪器,并对照它们记录时间。 - **See how your estimated and actual time stack up**. After you finish a task, project or Sprint, run a report in your time tracking software where you can see your estimated and actual time, review your fudge ratio for activity type and use this data to better plan your future activities. - 看看你的估计时间和实际时间是如何叠加的。在你完成一项任务、项目或冲刺后,在时间跟踪软件中运行一份报告,你可以看到你的估计时间和实际时间,审查你的活动类型的折中率,并使用这些数据来更好地计划你的未来活动。 - **Calculate the total fudge ratio**. Build a list of tasks, make your time estimates for each item and track time against them. Add up your total time spent, divide it by the total estimated time and multiply the result by 100%. - 计算总的折中率。建立一个任务清单,对每个项目做出你的时间估计,并对照它们追踪时间。把你花费的总时间加起来,除以估计的总时间,然后把结果乘以100%。 - **Ask for feedback**. To reduce estimation errors, ask a neutral party for feedback about your task estimates. If appropriate, discuss your estimations with the project manager at task estimation meetings. - 征求反馈意见。为了减少估计错误,请一个中立方对你的任务估计进行反馈。如果合适,在任务估算会议上与项目经理讨论你的估算。 ##### Improve Organizational Skills | 改善组织技能 ###### Upgrade Project Management | 项目管理 - Integrate and automate. - Delegate. - Outsource ###### Master Prioritization | 了解优先度 - Set deadlines. - Focus on 20% of the tasks. - Separate urgent from important. - Learn to say “no”. ###### Improve Scheduling | 改善日程 - Create a routine. - Schedule protected time. - Schedule me time. ### 一点收获 - 基础设施监视开源解决方案 - [oguzhaninan/Stacer](https://github.com/oguzhaninan/Stacer) Linux System Optimizer and Monitoring - [netdata/netdata](netdata/netdata) | infrastructure monitoring and troubleshooting. - 很多时候别人/朋友找你搭话只是为了寻找共感,这是只要表达同意就行了(不用强行思考有的没的)