github gists 101使代码共享漂亮

If you’ve been going through Medium, looking at technical articles, you’ve undoubtedly seen little windows that look like the below:

如果您一直在阅读Medium,并查看技术文章,那么您无疑会看到类似于以下内容的小窗口:

def hello_there(x):print('Hello there, ' + x)

These are called Github Gists. A gist is an easy way to share excerpts of code or data with others in a clean and reader friendly way. In this article, you’ll see ways to display a function you’ve created, a query into a table, or some other small piece of data (like a sneak peek at a dataframe). These bits of information are hosted by GitHub as a repository. Using gist has all the benefits of utilizing a GitHub repository with a lightweight and easy to share embedding feature.

这些被称为Github Gists。 要点是一种以简洁易懂的方式与他人共享代码或数据摘录的简便方法。 在本文中,您将看到显示创建的函数,查询表或其他小数据(例如偷偷看数据框)的方法。 这些信息由GitHub作为存储库托管。 使用gist具有利用具有轻量级且易于共享的嵌入功能的GitHub存储库的所有好处。

Not only are they cleaner but they allow coders who have vision issues a chance to read through your code using accessibility options.

它们不仅更清洁,而且还使视力有问题的编码人员可以使用辅助功能选项来阅读您的代码。

For now, let’s go through the basics:

现在,让我们看一下基础知识:

1.前往Github Gists (1. Getting to Github Gists)

There are two ways of getting to the gists portion of Github.com. The first way is for you to go to Gist.Github.com and it will take you to the new gist creation. Or you can go through your Github home page.

有两种方法可以访问Github.com的要点部分。 第一种方法是让您转到Gist.Github.com ,它将带您进入新的gist创作。 或者,您可以浏览您的Github主页。

Image for post
The Github homepage lets you get there two ways
Github主页让您到达那里的两种方式

The bottom red arrow, pointing at my profile picture, is how you would get to your repositories or gists. We’ll ignore that one for now and leave it for when we talk about editing old gists. The top arrow, pointing to the plus sign, leads to creating repos, gists, or projects — and that is the one we will be looking at first. After you click on the plus sign, you’ll see a dropdown menu.

底部的红色箭头指向我的个人资料照片,它是您到达存储库或要点的方式。 我们暂时将其忽略,而在谈论编辑旧要点时将其保留。 顶部的箭头指向加号,它会导致创建存储库,要点或项目-这就是我们首先要看的那个。 单击加号后,您会看到一个下拉菜单。

Image for post
The new gist link allows you to create a brand new gist
新的gist链接可让您创建全新的gist

That will bring you to the page below. Note how you have several fields to fill out.

那将带您到下面的页面。 请注意如何填写几个字段。

Image for post
Blank template for a new gist
新要点的空白模板
  1. Description Box — This will be the title and unofficial name of the gist

    说明框 -这将是要点的标题和非正式名称

  2. Filename + Extension — This is going to be where you name the file, in case of download. It is also the place you declare an extension for the programming language you have used.

    Filename + Extension ( 文件名+扩展名) —如果要下载,它将在其中命名文件。 在这里,您可以声明所用编程语言的扩展名。

  3. Code Box — This is where you enter/paste the code/data you want to display.

    代码框 -在此输入/粘贴要显示的代码/数据。

2.创建代码段 (2. Creating a Code Snippet)

From here it’s all plug and play. Let’s try to create a gist with a snippet of code we want to showcase — and I have just the one.

从这里开始即插即用。 让我们尝试创建一个包含要展示的代码片段的要点,而我只有一个。

Below I have a snippet of code written out to impute data from a recent linear regression project I finished. It was written to impute the number of bedrooms a house may have using the bathrooms and square footage of living space of a given house.

下面是我编写的一小段代码,用以估算来自最近完成的线性回归项目的数据。 撰写该文件的目的是使用给定房屋的浴室和居住空间的平方英尺来估算房屋的卧室数量。

Image for post
Snippet of Code I created through gists.github.com
我通过gists.github.com创建的代码片段

The extension is very important. You can put things like .txt, .py or .html. This notifies the reader what language it was written in — if it is not clear already, and it allows the file to be downloaded with the appropriate extension. The gist works whether you put an extension on it or not — but best ‘practices make better job opportunities’ — Paul Torres 2020.

扩展名非常重要。 您可以放入.txt.py.html之类的内容 。 这样可以通知读者使用的是哪种语言-如果尚不清楚,则可以使用适当的扩展名下载文件。 无论您是否进行扩展,要旨都是可行的-但最好的“实践会创造更好的工作机会” —保罗·托雷斯2020。

After simply copy and pasting the code into the window and filled out the description and the file name.

只需将代码复制并粘贴到窗口中,然后填写说明和文件名即可。

I set the settings to public so that the gist could be found in a search on the website. However, you have the option of making a secret gist that cannot be searched — these gists can still be shared with links you can hand out.

我将设置设为公开,以便可以在网站上的搜索中找到要点。 但是,您可以选择创建无法搜索的秘密要点-这些要点仍然可以与您可以分发的链接共享。

3.创建CSV表 (3. Creating a CSV Table)

The next feature we look at is the creation of tables using gists. Gists are not only for showing snippets of code. You can also display small shots of data in them. I say small because as of the publishing of this article, I have not found a method of entering data beyond copy and paste or manual entry.

我们要看的下一个功能是使用要点创建表。 要点不仅用于显示代码片段。 您也可以在其中显示少量数据。 我之所以这么说是因为,在撰写本文时,我还没有找到一种可以复制和粘贴或手动输入数据的方法。

The first step is to start a new gist and edit the file name so that it ends in .csv. This tells the website that you are going to be entering in values for the column index and cells separated by commas. Make sure that each column name is separated by a comma and each subsequent row is ordered in the same was as the column names.

第一步是启动新的摘要并编辑文件名,使其以.csv结尾。 这告诉网站您将要输入列索引的值以及用逗号分隔的单元格。 确保每个列名都用逗号分隔,并且每个后续行的排序顺序与列名相同。

Image for post
Make sure to write the words as you would want them to appear
确保写出您希望它们出现的单词

Looking at the picture above, we can see that the first row of entries are the column names. The second row is the first observation in the data. All of the entries have to be separated by a comma and they all have to be in the order of the column names in the first row. This continues on for the entirety of the table.

看上图,我们可以看到条目的第一行是列名。 第二行是数据中的第一个观察值。 所有条目都必须用逗号分隔,并且它们都必须按照第一行中列名的顺序排列。 对于整个表格,此操作继续进行。

Don’t worry about segmentation of the cells or the font of the column names — the website does it for you.

不必担心单元格的分割或列名称的字体-网站会为您完成。

Now, let’s take a look at the finished table.

现在,让我们看一下完成的表。

Each observation is segmented into a different row and each feature is segmented into its own cell. As we said before, the formatting of the font was done automatically when the column names are bolded and placed at the top of their columns.

每个观察值都被划分为不同的行,并且每个特征都被划分为自己的单元格。 如前所述,当列名加粗并放在其列的顶部时,字体的格式会自动完成。

One very helpful feature is the Search Box on the top of the table. It’s not accessible from the embedding but it is on the website. You can search the table and it returns only the values you designate.

一个非常有用的功能是表格顶部的搜索框 。 无法通过嵌入进行访问,但可以在网站上找到。 您可以搜索该表,它仅返回您指定的值。

4.在中部部署要点 (4. Deploying Gists on Medium)

Now we can talk about showing these gists to the world.

现在我们可以谈论向世界展示这些要旨。

Right here on Medium, it is as simple as clicking on the + on the next paragraph potion and clicking the <> option. After pasting the gist’s url, press enter.

就在此处,在Medium上,只需单击下一个段落部分上的+并单击<>选项即可。 粘贴要点的网址后,按Enter键。

Check out the gif.

查看gif。

演示地址

Quick video of the process of embedding on Medium
嵌入媒体过程的快速视频

5.查找或编辑以前的要点 (5. Finding or Editing Previously Made Gists)

If you go back to your Github homepage, to the right of the create button is your picture. That dropdown menu is going to give you links to your profile and settings — but more importantly your repos, projects, and gists.

如果您返回Github主页,则创建按钮右侧为您的图片。 该下拉菜单将为您提供个人资料和设置的链接,但更重要的是您的存储库,项目和要旨。

Click on the link for Your gists.

单击您的概要的链接。

Image for post
This is where you look for already created repos and gists
在这里寻找已创建的仓库和要点

At which point, you will be taken to a page listing all of your gists.

届时,您将进入一个列出所有要点的页面。

Image for post
My three most recently updated gists
我最近更新的三个要点

Click on one and you will be able to edit. Any gist you edit will update any embedding you have elsewhere. This is a very handy feature in case you spot a mistake or want to format the code in a more pleasing way. Instead of having to visit each embedding, you can just update the gist and it will do the work for you.

单击一个,就可以进行编辑。 您编辑的要点将更新您在其他地方的任何嵌入。 如果发现错误或想要以更令人愉悦的方式格式化代码,这是一个非常方便的功能。 无需访问每个嵌入,您只需更新要点,它将为您完成工作。

Thanks for reading. I hope this helps you distribute the beautiful code I know you will write.

谢谢阅读。 希望这可以帮助您分发我知道您会编写的漂亮代码。

Connect with me on LinkedIn here.

在此处通过LinkedIn与我联系。

For more information about the projects these gists came from, check out my Github here. And you can check out the articles these gists came from below:

有关这些要点来自的项目的更多信息,请在此处查看我的Github 。 您可以查看以下要点的文章:

翻译自: https://towardsdatascience.com/github-gists-101-making-code-sharing-pretty-163d9321a0af

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/389438.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

基于Netty的百万级推送服务设计要点

1. 背景1.1. 话题来源最近很多从事移动互联网和物联网开发的同学给我发邮件或者微博私信我&#xff0c;咨询推送服务相关的问题。问题五花八门&#xff0c;在帮助大家答疑解惑的过程中&#xff0c;我也对问题进行了总结&#xff0c;大概可以归纳为如下几类&#xff1a;1&#x…

鲜为人知的6个黑科技网站_6种鲜为人知的熊猫绘图工具

鲜为人知的6个黑科技网站Pandas is the go-to Python library for data analysis and manipulation. It provides numerous functions and methods that expedice the data analysis process.Pandas是用于数据分析和处理的Python库。 它提供了加速数据分析过程的众多功能和方法…

VRRP网关冗余

实验要求 1、R1创建环回口&#xff0c;模拟外网 2、R2&#xff0c;R3使用VRRP技术 3、路由器之间使用EIGRP路由协议  实验拓扑  实验配置  R1(config)#interface loopback 0R1(config-if)#ip address 1.1.1.1 255.255.255.0R1(config-if)#int e0/0R1(config-if)#ip addr…

大熊猫卸妆后_您不应错过的6大熊猫行动

大熊猫卸妆后数据科学 (Data Science) Pandas is used mainly for reading, cleaning, and extracting insights from data. We will see an advanced use of Pandas which are very important to a Data Scientist. These operations are used to analyze data and manipulate…

数据eda_关于分类和有序数据的EDA

数据eda数据科学和机器学习统计 (STATISTICS FOR DATA SCIENCE AND MACHINE LEARNING) Categorical variables are the ones where the possible values are provided as a set of options, it can be pre-defined or open. An example can be the gender of a person. In the …

jdk重启后步行_向后介绍步行以一种新颖的方式来预测未来

jdk重启后步行“永远不要做出预测&#xff0c;尤其是关于未来的预测。” (KK Steincke) (“Never Make Predictions, Especially About the Future.” (K. K. Steincke)) Does this picture portray a horse or a car? 这张照片描绘的是马还是汽车&#xff1f; How likely is …

mongodb仲裁者_真理的仲裁者

mongodb仲裁者Coming out of college with a background in mathematics, I fell upward into the rapidly growing field of data analytics. It wasn’t until years later that I realized the incredible power that comes with the position. As Uncle Ben told Peter Par…

优化 回归_使用回归优化产品价格

优化 回归应用数据科学 (Applied data science) Price and quantity are two fundamental measures that determine the bottom line of every business, and setting the right price is one of the most important decisions a company can make. Under-pricing hurts the co…

大数据数据科学家常用面试题_进行数据科学工作面试

大数据数据科学家常用面试题During my time as a Data Scientist, I had the chance to interview my fair share of candidates for data-related roles. While doing this, I started noticing a pattern: some kinds of (simple) mistakes were overwhelmingly frequent amo…

scrapy模拟模拟点击_模拟大流行

scrapy模拟模拟点击复杂系统 (Complex Systems) In our daily life, we encounter many complex systems where individuals are interacting with each other such as the stock market or rush hour traffic. Finding appropriate models for these complex systems may give…

vue.js python_使用Python和Vue.js自动化报告过程

vue.js pythonIf your organization does not have a data visualization solution like Tableau or PowerBI nor means to host a server to deploy open source solutions like Dash then you are probably stuck doing reports with Excel or exporting your notebooks.如果…

plsql中导入csvs_在命令行中使用sql分析csvs

plsql中导入csvsIf you are familiar with coding in SQL, there is a strong chance you do it in PgAdmin, MySQL, BigQuery, SQL Server, etc. But there are times you just want to use your SQL skills for quick analysis on a small/medium sized dataset.如果您熟悉SQ…

计算机科学必读书籍_5篇关于数据科学家的产品分类必读文章

计算机科学必读书籍Product categorization/product classification is the organization of products into their respective departments or categories. As well, a large part of the process is the design of the product taxonomy as a whole.产品分类/产品分类是将产品…

交替最小二乘矩阵分解_使用交替最小二乘矩阵分解与pyspark建立推荐系统

交替最小二乘矩阵分解pyspark上的动手推荐系统 (Hands-on recommender system on pyspark) Recommender System is an information filtering tool that seeks to predict which product a user will like, and based on that, recommends a few products to the users. For ex…

python 网页编程_通过Python编程检索网页

python 网页编程The internet and the World Wide Web (WWW), is probably the most prominent source of information today. Most of that information is retrievable through HTTP. HTTP was invented originally to share pages of hypertext (hence the name Hypertext T…

火种 ctf_分析我的火种数据

火种 ctfOriginally published at https://www.linkedin.com on March 27, 2020 (data up to date as of March 20, 2020).最初于 2020年3月27日 在 https://www.linkedin.com 上 发布 (数据截至2020年3月20日)。 Day 3 of social distancing.社会疏离的第三天。 As I sit on…

data studio_面向营销人员的Data Studio —报表指南

data studioIn this guide, we describe both the theoretical and practical sides of reporting with Google Data Studio. You can use this guide as a comprehensive cheat sheet in your everyday marketing.在本指南中&#xff0c;我们描述了使用Google Data Studio进行…

人流量统计系统介绍_统计介绍

人流量统计系统介绍Its very important to know about statistics . May you be a from a finance background, may you be data scientist or a data analyst, life is all about mathematics. As per the wiki definition “Statistics is the discipline that concerns the …

乐高ev3 读取外部数据_数据就是新乐高

乐高ev3 读取外部数据When I was a kid, I used to love playing with Lego. My brother and I built almost all kinds of stuff with Lego — animals, cars, houses, and even spaceships. As time went on, our creations became more ambitious and realistic. There were…

图像灰度化与二值化

图像灰度化 什么是图像灰度化&#xff1f; 图像灰度化并不是将单纯的图像变成灰色&#xff0c;而是将图片的BGR各通道以某种规律综合起来&#xff0c;使图片显示位灰色。 规律如下&#xff1a; 手动实现灰度化 首先我们采用手动灰度化的方式&#xff1a; 其思想就是&#…