Code snippets are an easy way to save and share reusable notebook paragraphs. Use Zepl's code snippets to shorten the learning curve for new users by sharing repetitive tasks such as, connecting to data, data preparation, and setting visualization parameters or common color palettes.
In a notebook, create a paragraph with the desired code or text for to save
Select the gear icon for paragraph settings
Select "Add to code snippets"
In the New Code Snippet modal:
Name: Add any name to reference this code snippet
Description (markdown supported): Add a description
Code / Output / Meta Data: These values are for display only
Create
After any member of your Zepl organization creates a code snippet, all code snippets will be found in side any notebook.
In any notebooks right hand menu, select the code snippet icon.
If no code snippets are created, you will be prompted to create one
In the table, select the code snippet of your choice to preview the Code and Meta Data of the code snippet
Code snippets can be sorted by three meta data categories. To do so, select the icon with the corresponding value below:
Name: Alphanumeric order
Recently Created
Recently Used
The code snippet list can easily be sorted in ascending or descending order by selecting the ascending or descending arrow icon:
Code snippets can be searched by selecting the search icon
Code snippets can be filtered by selecting one of the pre-built filters. To select a filter, select the "All snippets" icon
Below are the pre-built filters to choose from:
Created by Me: Only display the code snippets which your user account has created
Created by Others: Only display the code snippets that other user accounts have created. Exclude the code snippets which your user created.
Favorites: Only display the code snippets which your user account has selected the favorite star icon
There are several ways to insert a code snippet into your notebook:
Select the menu icon in the code snippet list > Select "Add to Notebook"
Select the code snippet icon as it appears in the snippet list and description
Code snippets are inserted below the last paragraph of your notebook
Editing a code snippet allows the user to change the Title and the Description of the code snippet. To edit a code snippet:
Select the menu icon in the code snippet list
Select Edit
If the user would like to edit the code of the code snippet, insert the code snippet into a notebook, make the desired changes, and create a new code snippet.
Duplicating a code snippet will make a copy of the code, but give the user the ability to edit the Title and Description. To duplicate a code snippet:
Select the menu icon in the code snippet list
Select Duplicate
Deleting a code snippet allows the user to remove a code snippet from the list for all users. Code snippets can only be deleted by the user that created them. To delete a code snippet:
Select the menu icon in the code snippet list
Select Remove
Repeatable tasks that make for great code snippets!
%pythonimport pandas as pd# establish connection to Snowflakecur = z.getDatasource("Shainsky_Snowflake")# execute querycur.execute("select * from LINEITEM LIMIT 10000")# convert datasource into pandas dataframedf = cur.fetch_pandas_all()# print dataframe as tablez.show(df)
%sparksc.hadoopConfiguration.set("fs.s3a.impl", "org.apache.hadoop.fs.s3a.S3AFileSystem")sc.hadoopConfiguration.set("fs.s3a.access.key", access_key)sc.hadoopConfiguration.set("fs.s3a.secret.key", secret_key)sc.hadoopConfiguration.set("fs.s3a.endpoint", "s3.us-west-2.amazonaws.com")sc.hadoopConfiguration.set("com.amazonaws.services.s3.enableV4", "true")
%pythondef card(title, value, secondValue = ""):print("""%html<div style="width: 200px;text-align:center;float:left;margin:10px 10px"><div style="font-weight:bold;font-size:16px;color:#2BB5E9">{title}</div><div style='background-color:#62C1E2;color:white;padding:10px 10px; font-size: 30px'>{value}<div style="font-size:15px">{secondValue}</div></div></div>\n""".format(title=title, value=value, secondValue=secondValue))print("""%html<style>.dataframe td {padding: 5px 5px;}.dataframe th {padding: 5px 5px;}.analytics {font-size:24px;color:#62C1E2;}.analyticsHL {font-size:28px;color:#2BB5E9;font-weight:bold;}</style>""")# Call Card functioncard("United Kingdom", 2848, "GDP")
%md<video width="100%" height="100%" autoplay loop><source src="https://zepl-dev.s3.amazonaws.com/home/ken/Tesla_video_4_Zepl.mp4" type="video/mp4" />Your browser does not support the video tag.</video>