Liberal host Cenk Uygur files for congressional run in Katie Hill's former district
by Joseph WulfsohnLiberal host Cenk Uygur appears to be jumping in the race to fill the vacant congressional seat left behind by Rep. Katie Hill, D-Calif., following her resignation.
Mediaite first noted that a filing named "Cenk for Congress" appeared in a Federal Election Commission database Wednesday, fueling speculation that Uygur will run in California's 25th district, which Hill represented until she stepped down following accusations of multiple inappropriate relationships with subordinates. Hill announced her resignation late last month.
Uygur had a simple response to reporters, in a tweet: "no comment."
Uygur founded the progressive digital network The Young Turks and previously was an MSNBC host.
On Tuesday, Uygur and co-host Ana Kasparian formally endorsed Sen. Bernie Sanders, I-Vt., for president, calling for a "revolution" in 2020 instead of "reform."
"In my opinion, Bernie Sanders' strategy is going to be quicker, more effective," Uygur declared. "Bernie Sanders is the one candidate that has clearly said that he is going to be up against that system, entirely."
George Papadopoulos, a former campaign aide to President Trump, also recently filed paperwork to launch a bid for Hill's old congressional seat.
CLICK HERE TO GET THE FOX NEWS APP
Papadopoulos was a key figure in the investigation over ties between Russia and the Trump campaign. The probe began after revelations that Papadopoulos had learned in 2016 from Maltese professor Joseph Mifsud that Russia had "dirt" on presidential candidate Hillary Clinton in the form of thousands of emails. The aide then used that connection to try setting up a meeting between Trump, then a Republican presidential candidate, and Russian President Vladimir Putin.
Papadopoulos pleaded guilty to lying to the FBI and cooperated in former Special Counsel Robert Mueller’s investigation. He was sentenced last year to 14 days in prison.
Fox News' Gregg Re contributed to this report.


Site search Search for site information by...
Help with Site Search
You can narrow the number of Site matches found by adding more of these optional search filters. You may enter part or all of a search term (with 3 or more characters), wildcards are not needed.
Note that you cannot search by vehicle test classes alone.


Thank you for taking the time to help us improve on our services
Why did you patronize our Cafe?
Would you recommend our Cafe to a friend?
Was the music too loud?
Were the lights too glaring?
How did the air-conditioning feel?
What is your favorite experience of the Cafe?
What would you like to see improved? (Check all that apply)
Any comments or suggestions?


Watcher of Valakas Klein:
Why are you here? Are you by any chance looking for the Hall of Flames behind me?
"Tell me more about the Hall of Flames."
"Tell me about the Amulet of Blessing and Amulet of Rescue."
"I want to enter the Hall of Flames."
Quest


There are four major trends in hacking.
Nation-State Based Hacking
This form is conducted by governments and is generally kept a secret. Governments use hacking against other governments or to manage their own populations. Governments hire highly qualified coders to do their dirty work. When governments hack each other, it is called cybersabotage or cyberespionage.
Cybersabotage can be used to take control of another governmet's cyber network. One of the most famous examples is the Stuxnet worm, created by the United States, that infilitrated Iranian state computer networks. This worm allowed the United States to control the centrifuges that enriched uranium and caused them to spin at irregular speeds.
Cyberespionage is used to spy on other governments and steal state/industry secrets.
When governments aren't hacking other governments, they are managing their own populations. They create programs that collect invasive amounts of personal information, then use profiling techniques to identify individuals. It has been revealed that China, United Kingdom, and the United States all use similar programs on their citizens. In the west, these techniques are typically used for the "War on Terror."


--- title = "Button" summary = "rarirurero rarirurero" description = """ hoge fgua """ [style] height = "300px" --- Button Active Button Disabled Button


This tag only writes its body to the output if the current user
is neither logged in nor remembered from a previous session (via
the "remember me" cookie).
This tag only writes its body to the output if the current user
is remembered from a previous session (via the "remember me"
cookie) but not currently logged in.
This tag only writes its body to the output if the current user
is either logged in or remembered from a previous session (via
the "remember me" cookie).
Inspects cookies associated with user session per:
http://wiki.developers.facebook.com/index.php/Verifying_The_Signature
To determine if their authentication as advised by Facebook is valid.


If you are a TUM student, your username should have the format ab12xyz. Do not include<EMAIL_ADDRESS>or '@tum.de'.


--- layout: post title: Tool use confimed in monkeys date: 2004-12-15 00:00:00 categories: books personal --- Tool use confirmed in monkeys: read the excellent "Next of Kin for a theory on how tool use led to the evolution of language in primates.


view_images module¶
-
view_images.
concatenate_ims
(ims)¶ Concatenates PIL original and processed images to a single image
Parameters: ims (list) – list of PIL image objects, [original, processed] Returns: a single, concatenated image Return type: PIL obj
-
view_images.
get_num_channels
(df)¶ Get the number of image channels of the input image.
We make the assumption that the number of channels will not be different for the processed image
Parameters: df (dict) – dictionary containing original images Returns: the number of channels in the image Return type: int
-
view_images.
hist_colors
(num_chans)¶ This function returns a list of colors to be used for histogram plotting based on whether the image is grayscale or RGB.
Parameters: num_chans (int) – the number of channels contained Returns: colors, a list of colors of len=1 or len=3 list: color_names, names of the colors, will be used for labeling Return type: list
-
view_images.
run_image_viewer
(df)¶ This functions calls the functions in this script to dispaly images and histograms.
Parameters: df (dict) – dictionary passed from the GUI Returns:
-
view_images.
separate_ims
(df)¶ Creates an image which is to be send to a viewer function. For cases in which both the original and processed images are to be shwon this function creates a horizontally concatenated image.
Parameters: df (dict) – dictionary containing images and display instructions Returns: a 2D or 3D numpy array (includes channels) containing the image to be shown Return type: numpy array
-
view_images.
show_hist
(df)¶ Plot histograms of the shown images.
Histogram values were calculated on the server. They are only plotted here.
Parameters: df (dict) – dictionary containing calculated histograms and display metadata Returns:
-
view_images.
show_ims
(im)¶ Function which uses skimage viewer to display the desired image(s). The window cretaed by this function needs be closed before the GUI can continue.
Parameters: im (numpy array) – a 2D numpy array (or 3D with channels) Returns:


Reports Menu > Sites > Activity Sum By Site For Acct
Select 1st and last day of month
Click Send to Printer Check Box
Press Ok
Repeat Process but choose Last Day of Month Before and First day of month ahead ex. (If month is May, Select April 30th - June 1st.
Print two copies of each (or make a copy of each) and give one to Rob Rabinowitz and Jack Monteleone
Pump setup
Open reader at pump (key required)
Turn off power
On "Switch Two", press toggle "No6" up
Turn power on
Select "No" on options screen until you reach "program chip key"
Select "Yes" when you read "program chip key"
Select "Yes" for "System Format 2"
Type in "0700"- Click "Enter"
Type in thirteen 0's then enter key number<PHONE_NUMBER>000xx) - There should be a total of 15 digits with the 0's and the two-digit key number
Select "No" for "Odometer" reading
Set the limit to 0
Insert key
Remove key when prompted
Repeat steps 1 and 2
On "Switch Two", press toggle "No6" down
Turn power on
Close and lock reader
Computer setup
Open "Phoenix"
Select "Site Information"
Click on "Cards"
Select Account
Set card type to "Single"
Click "New"
Enter account number (0700) followed by thirteen 0's and the key number<PHONE_NUMBER>0000000xx)
Name the account
Setup PIN
Update card
Poll site
Make sure the final validation screen appears with card number and PIN
Open Phoenix
Click Site Information (Picture of Gas Pump)
Click Cards Tab at top
Under Account Drop down Menu > Choose Store
Click on Card #’s until you find the PIN that needs resetting (NOTE: Sometimes stores have the same PIN for multiple card #'s. Be sure to do the next two steps to ALL cards with the same PIN)
Check Update Card checkbox
Press Save
Close out of that Menu
Press Poll Site (Picture of Computer and Modem)
Press Poll Site in pop-up window
This pop-up and a couple others will show up (NOTE: If no pop-ups appear, you will need to restart the computer and start over)
Import Summary screen will appear. Press Close
You will see a few more pop-ups come up. After no more pop-ups appear, the key should now be reset. You may close out of Pheonix
Call Fox Fuel at 2000 gallons<PHONE_NUMBER>)
Tell them you’re calling from Conicelli and the current gallons


Constructor
new InputRange(props)
Parameters:
| Name | Type | Description |
|---|---|---|
props |
Object | React component props |
- Source:
Extends
- React.Component
Members
(static) defaultProps
Default props of InputRange
Properties:
| Name | Type | Description |
|---|---|---|
defaultClassNames |
Object.<string, string> | |
defaultValue |
number | |
disabled |
boolean | |
maxValue |
number | |
minValue |
number | |
step |
number | |
value |
Range | number |
- Source:
(static) propTypes
Accepted propTypes of InputRange
Properties:
| Name | Type | Description |
|---|---|---|
ariaLabelledby |
function | |
classNames |
function | |
defaultValue |
function | |
disabled |
function | |
maxValue |
function | |
minValue |
function | |
name |
function | |
onChange |
function | |
onChangeComplete |
function | |
step |
function | |
value |
function |
- Source:
isMultiValue :boolean
Return true if the component accepts a range of values
Type:
- boolean
- Source:
trackClientRect :ClientRect
Return the clientRect of the component's track
Type:
- ClientRect
- Source:
Methods
decrementValue(key)
Decrement the value of a slider by key name
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | max/min |
- Source:
handleInteractionEnd()
Handle the end of any user-triggered event
- Source:
handleInteractionStart()
Handle the start of any user-triggered event
- Source:
handleKeyDown(event)
Handle any keydown event received by the component
Parameters:
| Name | Type | Description |
|---|---|---|
event |
SyntheticEvent | User event |
- Source:
handleKeyUp(event)
Handle any keyup event received by the component
Parameters:
| Name | Type | Description |
|---|---|---|
event |
SyntheticEvent | User event |
- Source:
handleMouseDown(event)
Handle any mousedown event received by the component
Parameters:
| Name | Type | Description |
|---|---|---|
event |
SyntheticEvent | User event |
- Source:
handleMouseUp(event)
Handle any mouseup event received by the component
Parameters:
| Name | Type | Description |
|---|---|---|
event |
SyntheticEvent | User event |
- Source:
handleSliderKeyDown(event, slider)
Handle any keydown event received by the slider
Parameters:
| Name | Type | Description |
|---|---|---|
event |
SyntheticEvent | User event |
slider |
Slider | React component |
- Source:
handleSliderMouseMove(event, slider)
Handle any mousemove event received by the slider
Parameters:
| Name | Type | Description |
|---|---|---|
event |
SyntheticEvent | User event |
slider |
Slider | React component |
- Source:
handleTouchEnd(event)
Handle any touchend event received by the component
Parameters:
| Name | Type | Description |
|---|---|---|
event |
SyntheticEvent | User event |
- Source:
handleTouchStart(event)
Handle any touchstart event received by the component
Parameters:
| Name | Type | Description |
|---|---|---|
event |
SyntheticEvent | User event |
- Source:
handleTrackMouseDown(event, slider, position)
Handle any mousedown event received by the track
Parameters:
| Name | Type | Description |
|---|---|---|
event |
SyntheticEvent | User event |
slider |
Slider | React component |
position |
Point |
- Source:
incrementValue(key)
Increment the value of a slider by key name
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | max/min |
- Source:
render() → {string}
Render method of the component
- Source:
Returns:
Component JSX
- Type
- string
updatePosition(key, position)
Update the position of a slider by key
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | min/max |
position |
Point | x/y |
- Source:
updatePositions(positions)
Update the position of sliders
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
positions |
Object |
Properties
|
- Source:
updateValue(key, value)
Update the value of a slider by key
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | max/min |
value |
number | New value |
- Source:
updateValues(values)
Update the values of all sliders
Parameters:
| Name | Type | Description |
|---|---|---|
values |
Object | number | Object if multi-value, number if single-value |
- Source:


--- layout: post authors: ["Justin Kitzes"] title: "Further Thoughts on Building Better Teachers" date: 2014-09-10 time: "09:00:00" tags: ["Community", "Opinion", "Teaching"] ---
On Greg's recommendation, I just finished reading Building a Better Teacher - it was an interesting book, and a well-written story. It turns out that I completely agree with Greg's assessment of the book's lessons and the challenges facing Software Carpentry, but I very much disagree with his proposed solutions!
On the idea of having a group call to discuss how recent bootcamps have gone every other week, I suspect that this is going to run into the fundamental problem that most of us not only teach bootcamps only once or twice a year, but we also only think about teaching bootcamps once or twice a year. I don't think many people (speaking for myself as well) are going to make the time to show up for one of these calls if we're not immediately about to teach a bootcamp, when we're in "teaching mode". On the taping idea, 5-10 minutes isn't nearly long enough to learn anything useful about the flow of a lesson - especially since, as the book points out, the important skill of teaching is usually how to respond to uncertainty and perceive misunderstandings from individual students' behaviors. I doubt that we'll be able to see that in such a short slice of time.
More generally, in both cases, I think these miss the second biggest point of the book (after "good teachers can be made, but it requires coaching and practice"), which is that direct, "thick", interpersonal interactions are the way that coaching works. Big group events like this are too impersonal, in my opinion, to deal with the subtleties of learning to teach well.
But I don't think all is lost. Here are two concrete counter-proposals that I think would work better (also inspired, of course, by the book). Both are essentially built around individual bootcamp experiences, when we have instructors' attention. Some of the other comments so far on Greg's blog post have hinted at similar ideas.
Mentorship. This has been floated before in various forms, but I think that it's a great idea to have a handful of the instructors (senior instructors?) volunteer, or be nominated, or apply, to be a class of mentors. New instructors should be strongly encouraged (in a perfect world, required, but that's probably not feasible) to teach one of their first two bootcamps under the guidance of a mentor. The mentor will help with lesson planning, observe the lesson, help with real-time adjustments (i.e., whisper in the instructor's ear) if things are going off track, and provide feedback after the fact. This gives the new instructor the additional benefit of watching an experienced instructor frame an entire two day workshop. New instructors who really wanted to dive in deep could be encouraged to travel around to teach with a selection of several mentors.
A sticking point would be how to select mentors and get them the additional training needed to be effective mentors. That would take some logistical work, but I think it's increasingly worthwhile to have this second "tier" of instructors as our group continues to grow. Think of those academic family trees - Greg is the "root PI", who trained a set of new PhD's at the beginning, some of whom (who wanted to put in the time and effort) started their own labs.
Single bootcamp jugyokenkyu. Sort of a light version of the above. At every bootcamp, the other instructors and helpers who are present should be tasked with observing (at least out of the corner of their eye) how an instructor teaches each lesson. Every instructor/helper should fill out a short, half page form at the end of a lesson telling the instructor four things - what went well from a teaching perspective and what could be improved, and what went well from a content perspective and what could be improved (always in a friendly way, of course). These are given to the instructors for review.
Then, at the conclusion of the bootcamp, the instructors sit together for 15-30 minutes to debrief on how the bootcamp went, discussing what's on the forms as well as bigger picture items. The lead instructor then reports back a summary of this discussion - a form could be useful, but I think two paragraphs of prose written to SWC central could be better. Note that this places a bit more burden on the lead instructor while removing it from the other instructors, as compared to each instructor filling out a survey.
In both cases, what these really do is address what is at heart a question of scalability - how to create a less centralized and more networked architecture for SWC that is organized around smaller hubs and sub-groups of instructors, rather than have everything organized around a back and forth to and from the mothership, steered by Greg. Note that both of Greg's suggestions are based on a mothership-coordination model.
Of course these are just suggestions, and details could surely be improved with further discussion. Speaking of which, perhaps we should organize a "task force" of us who are particularly interested in the pedegogical aspects of Software Carpentry to put a bit more effort into addressing these challenges?


Dear {{data.first_name}} {{data.last_name}},
Thank you for registering for the July 2023 DESC Meeting at SLAC!
Registration fees and collaboration dinner tickets are billed separately.
Your registration fee is ${{reg_fee}}, and your total dinner ticket charge is ${{dinner_cost}}.
Please click the links below to proceed with these payments and complete your registration.


Manage your facility better
Manage Booking
Add/Edit courts and slots.
Manage Courts/Slots
Basic info, things to note, address, amenities,...
Facility Information
View present/past bookings.
Coupons
Add/Edit courts and slots.
Gallery
Add/Edit courts and slots.
Customers
Basic info, things to note, address, amenities,...
Reviews
View present/past bookings.
Analytics
Add/Edit courts and slots.
Revenue/Payouts
Add/Edit courts and slots.
Users
Add/Edit courts and slots.
Notifications
This is title
Just see the my new admin!
9:30 AM
This is another title
Just a reminder that you have event
9:10 AM
This is title
You can customize this template as you want
9:08 AM
This is another title
Just see the my admin!
9:02 AM
Check all notifications
You have 4 new messages
Michael Qin
Just see the my admin!
9:30 AM
John Doe
I've sung a song! See you at
9:10 AM
Mr. John
I am a singer!
9:08 AM
Michael Qin
Just see the my admin!
9:02 AM
See all e-Mails
Profile
Balance
Inbox
Setting
Logout
Manage Users
Home
Users
List of users
Show
10
25
50
100
entries
Search:
Name
Email
Mobile
Age
Last login
User name
<EMAIL_ADDRESS>+91 0000 0000 00
33
2008/11/28
Edit
User name
<EMAIL_ADDRESS>+91 0000 0000 00
33
2008/11/28
Edit
User name
<EMAIL_ADDRESS>+91 0000 0000 00
33
2008/11/28
Edit
Showing 1 to 10 of 57 entries
Previous
1
2
Next


I enjoy hiking, working with GPS, sailing and reading
I'm known as a Jack of All Trades, but Master of None
Use El GitHub del Masta to contact me


This is an example with no model, and minimal amount of code using plain images. Swipe left or right.
Here is a more complete example.
Here is an example that is sort of like angular-carousel.
Here is an example of using a watch.


Getting Started
Introduction
LookAt exposes an extensive API which enables partners to develop integrations both in and out of LookAt -
From uploading files, sharing, using metadata or extracting custom usage reports.
Before you get started make sure you have API access enabled and your account ID (used in some of the calls). For more inquiries contact<EMAIL_ADDRESS>get Get Token
Returns a token to be used in every API call
Get https://app.lookat.io/Token
Data Params:
grant_type=password&username=<email>&password=<password>
Sample Code (Javascript):
Projects
Description
Projects are the highest level entity in LookAt. Projects can be only created on the dashboard and cannot be nested under other projects or folders.
Any action in LookAt must start by creating a Project for the simple reason that content can only be uploaded into projects rather than directly to the Dashboard.
The Project object inherits from a Folder object and this is why it contains both ProjectID and FolderID properties. Keep this in mind since some of the queries require both or one of those ID's.
 The link can be used only by users who are shared with the project or users who have "View All Projects" permission.
Get https://app.lookat.io/external_api/projects/{projectId}/folders/{FolderIDofProject}/getFolderLink
Header:
{ 'Authorization': 'Bearer {access_token}', userEmail<EMAIL_ADDRESS>} // userEmail is owner of project
Sample Code (Javascript):
Get Get a List of Projects for a User
Use this call to retrieve a list of all the projects owned by a user
Get https://app.lookat.io/external_api/v1/projects/getUserProjects
Header:
{ 'Authorization': 'Bearer {access_token}', userEmail<EMAIL_ADDRESS>}
Sample Code (Javascript):
Get Get a List of Collaborators for a Project
Use this call to retrieve a list of collaborators on a specific project
Get https://app.lookat.io/external_api/v1/projects/{projectId}/getProjectUsers
Header:
{ 'Authorization': 'Bearer {access_token}' }
Sample Code (Javascript):
delete Remove Collaborator from a Project
Use this call to remove collaborator from a specific project
Delete https://app.lookat.io/external_api/v1/projects/{projectId}/folders/{projectFolderId}/users/{userId}/removeUserFromProject
Header:
{ 'Authorization': 'Bearer {access_token}', 'Content-Type': 'application/json'}
Sample Code (Javascript):
Folders
Description
Folders are containers for files and/or other folders.
Use folders to better originize your content or to share different content with different collaborators.
Post Create New Folder
Use this call to create a new folder.  The link can be used only by users who are shared with the folder.

This section contains all calls related to files in LookAt.
get Get a list of Files for a User
Use this call to retrieve an array of all files own by a user
Get https://app.lookat.io/external_api/v1/videos/getUserFiles
Header:
{ 'Authorization': 'Bearer {access_token}', userEmail<EMAIL_ADDRESS>Sample Code (Javascript):
get Get Versions List for a File
Use this call to retrieve an array of versions of a file
ENUM MediaType { Video, Audio, Image, Video360, Image360, Txt, Pdf, Presentation, Word, Excel, Html, HtmlInteractive }
Get https://app.lookat.io/external_api/projects/{projectId}/videos/{videoId}/videoversions/getUserVideoVersions
Header:
{ 'Authorization': 'Bearer {access_token}', userEmail<EMAIL_ADDRESS>Sample Code (Javascript):
delete Delete a File
Use this call to delete a file
Delete https://app.lookat.io/external_api/v1/projects/{projectId}/videos/{videoId}/delete // videoID == fileID
Header:
{ 'Authorization': 'Bearer {access_token}', userEmail<EMAIL_ADDRESS>// userEmail - email of the original uploader
Sample Code (Javascript):
put Lock a File
Use this call to lock a file from adding new comments or submitting / changing approval decisions
Put https://app.lookat.io/external_api/v1/projects/{projectId}/folders/{folderUserParentId}/videos/{videoId}/lock // videoID == fileID
Header:
{ 'Content-Type': 'application/json', 'userEmail'<EMAIL_ADDRESS>'Authorization': 'Bearer {access_token}' }
Sample Code (Javascript):
put Unlock a File
Use this call to unlock a locked file.
Put https://app.lookat.io/external_api/v1/projects/{projectId}/folders/{folderUserParentId}/videos/{videoId}/unlock // videoID == fileID
Header:
{ 'Content-Type': 'application/json', 'userEmail'<EMAIL_ADDRESS>'Authorization': 'Bearer {access_token}' }
Sample Code (Javascript):
Upload Files and Versions
Description
LookAt utilizes a CDN technology for both streaming and uploads. This is why uploading files or versions requires 2 API calls:
1. Retrieving a designated URL for the upload call.
2. Upload to the designated URL.
post Get URL for New File Upload
Use this call to retrieve a designated URL for the upload
Post https://app.lookat.io/external_api/v1/projects/{projectID}/folders/{folderId}/videos/url
Data Params: (Object)
{"fileName":name,"FileSizeInKB":fileSize,"is360":bool}
Header:
{ 'Authorization': 'Bearer {access_token}', userEmail<EMAIL_ADDRESS>// userEmail - file will be uploaded on-behalf of this user
Sample Code (Javascript):
Post Get URL for New Version Upload
Use this call to retrieve a designated URL for the version update.
Post https://app.lookat.io/external_api/v1/projects/{projectID}/videos/{fileId}/videoversions/url
Data Params: (Object)
{"fileName":name,"FileSizeInKB":fileSize,"is360":bool}
Header:
{ 'Authorization': 'Bearer {access_token}', userEmail<EMAIL_ADDRESS>// userEmail - file will be uploaded on-behalf of this user
Sample Code (Javascript):
put Upload File or Version
Use this call to to upload a new file/files or new versions to the designated URL returned from the previous call
Put Designated URL
Body
The file
Sample Code (Javascript):
Complete Upload New File or Version Example
Sample Code (Javascript):
Sharing Files
Description
Each file in LookAt can be shared in unlimited number of private discussion groups.
Sharing a specific file in LookAt actually means you add a user to a certain group. Every file contains at least one group (Created automatically when a file is uploaded).
get Get List of Groups for a File
Use this call to retrieve the groups list for a file
Get https://app.lookat.io/external_api/v1/projects/{projectId}/videos/{fileId}/getVideoGroups
Header:
{ 'Authorization': 'Bearer {access_token}', userEmail<EMAIL_ADDRESS>// userEmail - file owner
Sample Code (Javascript):
post Create New Group
Use this call to create new private discussion group
Post https://app.lookat.io/external_api/v1/projects/{projectId}/videos/{fileId}/group
Data Params: (Object)
{ Title: {group_name} }
Header:
{ 'Authorization': 'Bearer {access_token}', userEmail<EMAIL_ADDRESS>// userEmail - file owner
Sample Code (Javascript):
post Add Collaborators to a Group (Share a File)
Use this call to add collaborators to a group (Simply put - Share a file)
Post https://app.lookat.io/external_api/v1/projects/{projectId}/videos/{fileId}/group/{groupId}/addUser
Data Params: (Object)
{ Email: {Collaborator_Email} }
Header:
{ 'Authorization': 'Bearer {access_token}', userEmail<EMAIL_ADDRESS>// userEmail - file owner
Sample Code (Javascript):
delete Remove Collaborator from a Group (Un-Share a File)
Use this call to remove a user from group (Simply put - Un-share a file)
Delete https://app.lookat.io/external_api/v1/projects/{projectId}/folders/{folderId}/videos/{fileId}/groups/{groupId}/user/{userId}/removeUser
Header:
{ 'Authorization': 'Bearer {access_token}'}
Sample Code (Javascript):
Approvals
Description
Use to following calls get approval status, create new or update exixting approvals
get Get Approval By ID
Use this call to retreive data about the status of an existing approval. To find the ID for the approval use "Get Versions List for a File" query.
Get https://app.lookat.io/external_api/v1/projects/{projectId}/folders/{folderUserParentId}/videos/{videoId}/videoversions/{versionId}/approval/{approvalId}
Header:
{ 'Authorization': 'Bearer {access_token}', userEmail<EMAIL_ADDRESS>// userEmail - file owner
Sample Code (Javascript):
get Get List Of Potential Approvers
Use this call to retreive a list of all users who are shared with a specific file in order to include them in a new approval.
Get https://app.lookat.io/external_api/v1/projects/{projectId}/folders/{folderUserParentId}/videos/{videoId}/videoversions/{versionId}/approval/possibleApprovalUsersForFile
Header:
{ 'Authorization': 'Bearer {access_token}', userEmail<EMAIL_ADDRESS>// userEmail - file owner
Sample Code (Javascript):
post Create a new Approval for a file
Use this call to create a new approval for a file. Request body should include an Approval object containing an array of UserApproval objects. See example below for both objects
Post https://app.lookat.io/external_api/v1/projects/{projectId}/folders/{folderUserParentId}/videos/{videoId}/videoversions/{versionId}/approval
Header:
{ 'Content-Type': 'application/json', 'userEmail'<EMAIL_ADDRESS>'Authorization': 'Bearer {access_token}' }
Sample Code (Javascript):
put Update an existing Approval
Use this call to change setting or add/remove users for an existing Approval
Put https://app.lookat.io/external_api/v1/projects/{projectId}/folders/{folderUserParentId}/videos/{videoId}/videoversions/{versionId}/approval/{approvalId}
Header:
{ 'Content-Type': 'application/json', 'userEmail'<EMAIL_ADDRESS>'Authorization': 'Bearer {access_token}' }
Sample Code (Javascript):
put Submit a Decision on-behalf of a user
Use this call to submit a decision on-behalf a user who is a part of an existing approval
Put https://app.lookat.io/external_api/v1/projects/{projectId}/folders/{folderUserParentId}/videos/{videoId}/videoversions/{versionId}/approval/{approvalId}/submitDecisionOnBehalf
Header:
{ 'Content-Type': 'application/json', 'userEmail'<EMAIL_ADDRESS>'Authorization': 'Bearer {access_token}' } // 'userEmail' - email of the "on-behalf" user
Sample Code (Javascript):
Team
Description
Use to following calls to retrieve data and manage your team members
get Get List of Team Members
Use this call to retrieve a list of your team members
Get https://app.lookat.io/external_api/v1/payingGroups/{accountId}/videos/getTeamMembers
Header:
{ 'Authorization': 'Bearer {access_token}' }
Sample Code (Javascript):
get Get List of Team Projects
Use this call to retrieve a list of your team members' projects
Get https://app.lookat.io/external_api/v1/payingGroups/{accountId}/getTeamProjects
Header:
{ 'Authorization': 'Bearer {access_token}' }
Sample Code (Javascript):
get Get List of Team Files
Use this call to retrieve a list of files uploaded by your team members
Get https://app.lookat.io/external_api/v1/payingGroups/{accountId}/videos/getTeamVideos
Header:
{ 'Authorization': 'Bearer {access_token}' }
Sample Code (Javascript):
get Reset Password
Use this call to reset a team member's password
Get https://app.lookat.io/external_api/v1/user/{userId}/resetPassword
Header:
{ 'Authorization': 'Bearer {access_token}' }
Sample Code (Javascript):
Comments
Description
Use the following calls to retrieve list of comments from a single file or multiple files.
get Get list of Comments for a File
Use this call to retrieve a list of comments on a specific version in a file
post Get list of Comments for multiple files
Use this call to retrieve a list of all comments on multiple files


This is just a demo how to add CTAs (action indicators) to the dat.gui interface.
The function is called arrowBounce(string,string) and expects a label text and an optional class name to attach to the label.
This demos uses a class named 'hideAfter5s' which hides the label after 5 seconds using a fadeout animaion (CSS).


--- layout: post title: What My Blog Is tags: ---
Before I begin posting, I want to give a short explanation of what this blog really is. I look at this blog the same way that most open source is viewed: I am creating it for me and if it happens to benefits others then great! I need a place to dumb all this information, if in the process of doing so, this helps someone out, that is awesome. Sometimes when I describe a topic I may go into detail, most times though I will probably simply drop one of two lines in and move on just because its something fun I want to remember.


Visualization of Airbnb Data in San Francisco in 2015 Reset All
Explore the prices of renting properties that were listed on
Airbnb
in San Francisco between May 2015 and May 2016
Insight from the data :
(1) Renting
entire home is more expensive than renting
private room or shared room
(2) It is cheaper to visit SF
during the off-peak season (Jan - Apr, Oct - Dec)
or
during the weekdays (Mon - Thur)
(3)
Renting private room in the most expensive area
is about the same price as
renting entire home in the least expensive area
Click through each chart to see how the price pattern changes with room type, time, and/or location.
Click color box or link to select. Click again to reset.
(Data Source: Inside Airbnb)
Room Type
listed properties
Price by Month
x axis : average price / night
Price by day
x axis : average price / night
Price vs. Availability by Area
Click bubble to select. Click again to reset. (color code represents area, bubble area : total number of review)
Price Distribution
Drag mouse to select a specific region
Price Varies with Time
Move mouse to the curve to see date and price
Price by Neighborhood
x axis : average price / night
(color code represents area)


which accepts another value that the given value should be compared for equality.
struct interface Equatable {
pub fun equals(_ other: {Equatable}): Bool
}
// Declare a struct named `Cat`, which has one field named `id`
// that has type `Int`, i.e., the identifier of the cat.
//
// `Cat` also will implement the interface `Equatable`
// to allow cats to be compared for equality.
//
struct Cat: Equatable {
pub let id: Int
init(id: Int) {
self.id = id
}
pub fun equals(_ other: {Equatable}): Bool {
if let otherCat = other as? Cat {
// Cats are equal if their identifier matches.
//
return otherCat.id == self.id
} else {
return false
}
}
}
Cat(1) == Cat(2) // is `false`
Cat(3) == Cat(3) // is `true`
Hashable
Interface🚧 Status: The
Hashable
interface is not implemented yet.
A hashable type is a type that can be hashed to an integer hash value,
i.e., it is distilled into a value that is used as evidence of inequality.
Types are hashable when they implement the Hashable
interface.
Hashable types can be used as keys in dictionaries.
Hashable types must also be equatable,
i.e., they must also implement the Equatable
interface.
This is because the hash value is only evidence for inequality:
two values that have different hash values are guaranteed to be unequal.
However, if the hash values of two values are the same,
then the two values could still be unequal
and just happen to hash to the same hash value.
In that case equality still needs to be determined through an equality check.
Without Equatable
, values could be added to a dictionary,
but it would not be possible to retrieve them.
Most of the built-in types are hashable, like booleans and integers. Arrays are hashable when their elements are hashable. Dictionaries are hashable when their values are equatable.
Hashing a value means passing its essential components into a hash function.
Essential components are those that are used in the type's implementation of Equatable
.
If two values are equal because their equals
function returns true,
then the implementation must return the same integer hash value for each of the two values.
The implementation must also consistently return the same integer hash value during the execution of the program when the essential components have not changed. The integer hash value must not necessarily be the same across multiple executions.
struct interface Hashable: Equatable {
pub hashValue: Int
}
// Declare a structure named `Point` with two fields
// named `x` and `y` that have type `Int`.
//
// `Point` is declared to implement the `Hashable` interface,
// which also means it needs to implement the `Equatable` interface.
//
struct Point: Hashable {
pub(set) var x: Int
pub(set) var y: Int
init(x: Int, y: Int) {
self.x = x
self.y = y
}
// Implementing the function `equals` will allow points to be compared
// for equality and satisfies the `Equatable` interface.
//
pub fun equals(_ other: {Equatable}): Bool {
if let otherPoint = other as? Point {
// Points are equal if their coordinates match.
//
// The essential components are therefore the fields `x` and `y`,
// which must be used in the implementation of the field requirement
// `hashValue` of the `Hashable` interface.
//
return otherPoint.x == self.x
&& otherPoint.y == self.y
} else {
return false
}
}
// Providing an implementation for the hash value field
// satisfies the `Hashable` interface.
//
pub synthetic hashValue: Int {
get {
// Calculate a hash value based on the essential components,
// the fields `x` and `y`.
//
var hash = 7
hash = 31 * hash + self.x
hash = 31 * hash + self.y
return hash
}
}
}
Structure and resource types can be restricted. Restrictions are interfaces. Restricted types only allow access to a subset of the members and functions of the type that is restricted, indicated by the restrictions.
The syntax of a restricted type is T{U1, U2, ... Un}
,
where T
is the restricted type, a concrete resource or structure type,
and the types U1
to Un
are the restrictions, interfaces that T
conforms to.
Only the members and functions of the union of the set of restrictions are available.
Restricted types are useful for increasing the safety in functions that are supposed to only work on a subset of the type. For example, by using a restricted type for a parameter's type, the function may only access the functionality of the restriction: If the function accidentally attempts to access other functionality, this is prevented by the static checker.
// Declare a resource interface named `HasCount`,
// which has a read-only `count` field
//
resource interface HasCount {
pub let count: Int
}
// Declare a resource named `Counter`, which has a writeable `count` field,
// and conforms to the resource interface `HasCount`
//
pub resource Counter: HasCount {
pub var count: Int
init(count: Int) {
self.count = count
}
pub fun increment() {
self.count = self.count + 1
}
}
// Create an instance of the resource `Counter`
let counter: @Counter <- create Counter(count: 42)
counterRef.count // is `42`
counterRef.increment()
counterRef.count // is `43`
// Move the resource in variable `counter` to a new variable `restrictedCounter`,
// but typed with the restricted type `Counter{HasCount}`:
// The variable may hold any `Counter`, but only the functionality
// defined in the given restriction, the interface `HasCount`, may be accessed
//
let restrictedCounter: @Counter{Count} <- counter
// Invalid: Only functionality of restriction `Count` is available,
// i.e. the read-only field `count`, but not the function `increment` of `Counter`
//
restrictedCounter.increment()
// Move the resource in variable `restrictedCounter` to a new variable `unrestrictedCounter`,
// again typed as `Counter`, i.e. all functionality of the counter is available
//
let unrestrictedCounter: @Counter <- restrictedCounter
// Valid: The variable `unrestrictedCounter` has type `Counter`,
// so all its functionality is available, including the function `increment`
//
unrestrictedCounter.increment()
// Declare another resource type named `Strings`
// which implements the resource interface `HasCount`
//
pub resource Strings: HasCount {
pub var count: Int
access(self) var strings: [String]
init() {
self.count = 0
self.strings = []
}
pub fun append(_ string: String) {
self.strings.append(string)
self.count = self.count + 1
}
}
// Invalid: The resource type `Strings` is not compatible
// with the restricted type `Counter{HasCount}`.
// Even though the resource `Strings` implements the resource interface `HasCount`,
// it is not compatible with `Counter`
//
let counter2: @Counter{HasCount} <- create Strings()
In addition to restricting concrete types is also possible
to restrict the built-in types AnyStruct
, the supertype of all structures,
and AnyResource
, the supertype of all resources.
For example, restricted type AnyResource{HasCount}
is any resource type
for which only the functionality of the HasCount
resource interface can be used.
The restricted types AnyStruct
and AnyResource
can be omitted.
For example, the type {HasCount}
is any resource that implements
the resource interface HasCount
.
pub struct interface HasID {
pub let id: String
}
pub struct A: HasID {
pub let name: String
init(name: String) {
self.name = name
}
}
pub struct B: HasID {
pub let name: String
init(name: String) {
self.name = name
}
}
// Create two instances, one of type `A`, and one of type `B`.
// Both types conform to interface `HasID`, so the structs can be assigned
// to variables with type `AnyResource{HasID}`: Some resource type which only allows
// access to the functionality of resource interface `HasID`
let hasID1: {HasID} = A(name: "1")
let hasID2: {HasID} = B(name: "2")
// Declare a function named `getID` which has one parameter with type `{HasID}`.
// The type `{HasID}` is a short-hand for `AnyStruct{HasID}`:
// Some structure which only allows access to the functionality of interface `HasID`.
//
pub fun getID(_ value: {HasID}): String {
return value.id
}
let id1 = getID(hasID1)
// `id1` is "1"
let id2 = getID(hasID2)
// `id2` is "2"
Only concrete types may be restricted, e.g., the restricted type may not be an array,
the type [T]{U}
is invalid.
Restricted types are also useful when giving access to resources and structures to potentially untrusted third-party programs through references, which are discussed in the next section.
It is possible to create references to objects, i.e. resources or structures. A reference can be used to access fields and call functions on the referenced object.
References are copied, i.e. they are value types.
References are created by using the &
operator, followed by the object,
the as
keyword, and the type through which they should be accessed.
The given type must be a supertype of the referenced object's type.
References have the type &T
, where T
is the type of the referenced object.
let hello = "Hello"
// Create a reference to the "Hello" string, typed as a `String`
//
let helloRef: &String = &hello as &String
helloRef.length // is `5`
// Invalid: Cannot create a reference to `hello`
// typed as `&Int`, as it has type `String`
//
let intRef: &Int = &hello as &Int
References are covariant in their base types.
For example, &T
is a subtype of &U
, if T
is a subtype of U
.
// Declare a resource interface named `HasCount`,
// that has a field `count`
//
resource interface HasCount {
count: Int
}
// Declare a resource named `Counter` that conforms to `HasCount`
//
resource Counter: HasCount {
pub var count: Int
pub init(count: Int) {
self.count = count
}
pub fun increment() {
self.count = self.count + 1
}
}
// Create a new instance of the resource type `Counter`
// and create a reference to it, typed as `&Counter`,
// so the reference allows access to all fields and functions
// of the counter
//
let counter <- create Counter(count: 42)
let counterRef: &Counter = &counter as &Counter
counterRef.count // is `42`
counterRef.increment()
counterRef.count // is `43`
References may be authorized or unauthorized.
Authorized references have the auth
modifier, i.e. the full syntax is auth &T
,
whereas unauthorized references do not have a modifier.
Authorized references can be freely upcasted and downcasted, whereas unauthorized references can only be upcasted. Also, authorized references are subtypes of unauthorized references.
// Create an unauthorized reference to the counter,
// typed with the restricted type `&{HasCount}`,
// i.e. some resource that conforms to the `HasCount` interface
//
let countRef: &{HasCount} = &counter as &{HasCount}
countRef.count // is `43`
// Invalid: The function `increment` is not available
// for the type `&{HasCount}`
//
countRef.increment()
// Invalid: Cannot conditionally downcast to reference type `&Counter`,
// as the reference `countRef` is unauthorized.
//
// The counter value has type `Counter`, which is a subtype of `{HasCount}`,
// but as the reference is unauthorized, the cast is not allowed.
// It is not possible to "look under the covers"
//
let counterRef2: &Counter = countRef as? &Counter
// Create an authorized reference to the counter,
// again with the restricted type `{HasCount}`, i.e. some resource
// that conforms to the `HasCount` interface
//
let authCountRef: auth &{HasCount} = &counter as auth &{HasCount}
// Conditionally downcast to reference type `&Counter`.
// This is valid, because the reference `authCountRef` is authorized
//
let counterRef3: &Counter = authCountRef as? &Counter
counterRef3.count // is `43`
counterRef3.increment()
counterRef3.count // is `44`
Programs can import declarations (types, functions, variables, etc.) from other programs.
Imports are declared using the import
keyword.
It can either be followed by a location, which imports all declarations;
or it can be followed by the names of the declarations that should be imported,
followed by the from
keyword, and then followed by the location.
If importing a local file, the location is a string literal, and the path to the file.
🚧 Status: Imports from local files are not currently implemented.
If importing an external type in a different account, the location is an address literal, and the address of the account where the declarations are deployed to and published.
// Import the type `Counter` from a local file.
//
import Counter from "examples/counter.cdc"
// Import the type `Counter` from an external account.
//
import Counter from 0x299F20A29311B9248F12
Every account can be accessed through two types:
As a Public Account with the type PublicAccount
,
which represents the publicly available portion of an account.
struct PublicAccount {
let address: Address
// Storage operations
fun getCapability<T>(_ path: Path): Capability<T>?
fun getLinkTarget(_ path: Path): Path?
}
Any code can get the PublicAccount
for an account address
using the built-in getAccount
function:
fun getAccount(_ address: Address): PublicAccount
As an Authorized Account with type AuthAccount
,
which represents the authorized portion of an account.
Access to an AuthAccount
means having full access to its storage,
public keys, and code.
Only signed transactions can get the AuthAccount
for an account.

}
Accounts can be created by calling the AuthAccount
constructor
and passing the account that should pay for the account creation for the payer
parameter.
The payer
must have enough funds to be able to create an account.
If the account does not have the required funds, the program aborts.
To authorize access to the account, keys can be added using the addPublicKey
function.
Keys can also later be removed using the removePublicKey
function.
For example, to create an account and have the signer of the transaction pay for the account creation, and authorize one key to access the account:
transaction(key: [UInt8]) {
prepare(signer: AuthAccount) {
let account = AuthAccount(payer: signer)
account.addPublicKey(key)
}
}
All accounts have storage.
Objects are stored under paths in storage. Paths consist of a domain and an identifier.
Paths start with the character /
, followed by the domain, the path separator /
,
and finally the identifier.
For example, the path /storage/test
has the domain storage
and the identifier test
.
There are only three valid domains: storage
, private
, and public
.
Objects in storage are always stored in the storage
domain.
Both resources and structures can be stored in account storage.
Account storage is accessed through the following functions of AuthAccount
.
This means that any code that has access to the authorized account has access
to all its stored objects.
fun save<T>(_ value: T, to: Path)
Saves an object to account storage. Resources are moved into storage, and structures are copied.
T
is the type parameter for the object type.
It can be inferred from the argument's type.
If there is already an object stored under the given path, the program aborts.
The path must be a storage path, i.e., only the domain storage
is allowed.
fun load<T>(from: Path): T?
Loads an object from account storage.
If no object is stored under the given path, the function returns nil
.
If there is an object stored, the stored resource or structure is moved
out of storage and returned as an optional.
When the function returns, the storage no longer contains an object
under the given path.
T
is the type parameter for the object type.
A type argument for the parameter must be provided explicitly.
The type T
must be a supertype of the type of the loaded object.
If it is not, the function returns nil
.
The given type does not necessarily need to be exactly the same as the type of the loaded object.
The path must be a storage path, i.e., only the domain storage
is allowed.
fun copy<T: AnyStruct>(from: Path): T?
Returns a copy of a structure stored in account storage, without removing it from storage.
If no structure is stored under the given path, the function returns nil
.
If there is a structure stored, it is copied.
The structure stays stored in storage after the function returns.
T
is the type parameter for the structure type.
A type argument for the parameter must be provided explicitly.
The type T
must be a supertype of the type of the copied structure.
If it is not, the function returns nil
.
The given type does not necessarily need to be exactly the same as
the type of the copied structure.
The path must be a storage path, i.e., only the domain storage
is allowed.
// Declare a resource named `Counter`.
//
resource Counter {
pub var count: Int
pub init(count: Int) {
self.count = count
}
}
// In this example an authorized account is available through the constant `authAccount`.
// Create a new instance of the resource type `Counter`
// and save it in the storage of the account.
//
// The path `/storage/counter` is used to refer to the stored value.
// Its identifier `counter` was chosen freely and could be something else.
//
authAccount.save(<-create Counter(count: 42), to: /storage/counter)
// Run-time error: Storage already contains an object under path `/storage/counter`
//
authAccount.save(<-create Counter(count: 123), to: /storage/counter)
// Load the `Counter` resource from storage path `/storage/counter`.
//
// The new constant `counter` has the type `Counter?`, i.e., it is an optional,
// and its value is the counter resource, that was saved at the beginning
// of the example.
//
let counter <- authAccount.load<@Counter>(from: /storage/counter)
// The storage is now empty, there is no longer an object stored
// under the path `/storage/counter`.
// Load the `Counter` resource again from storage path `/storage/counter`.
//
// The new constant `counter2` has the type `Counter?` and is `nil`,
// as nothing is stored under the path `/storage/counter` anymore,
// because the previous load moved the counter out of storage.
//
let counter2 <- authAccount.load<@Counter>(from: /storage/counter)
// Create another new instance of the resource type `Counter`
// and save it in the storage of the account.
//
// The path `/storage/otherCounter` is used to refer to the stored value.
//
authAccount.save(<-create Counter(count: 123), to: /storage/otherCounter)
// Load the `Vault` resource from storage path `/storage/otherCounter`.
//
// The new constant `vault` has the type `Vault?` and its value is `nil`,
// as there is a resource with type `Counter` stored under the path,
// which is not a subtype of the requested type `Vault`.
//
let vault <- authAccount.load<@Vault>(from: /storage/otherCounter)
// The storage still stores a `Counter` resource under the path `/storage/otherCounter`.
// Save the string "Hello, World" in storage
// under the path `/storage/helloWorldMessage`.
authAccount.save("Hello, world!", to: /storage/helloWorldMessage)
// Copy the stored message from storage.
//
// After the copy, the storage still stores the string under the path.
// Unlike `load`, `copy` does not remove the object from storage.
//
let message = authAccount.copy<String>(from: /storage/helloWorldMessage)
// Create a new instance of the resource type `Vault`
// and save it in the storage of the account.
//
authAccount.save(<-createEmptyVault(), to: /storage/vault)
// Invalid: Cannot copy a resource, as this would allow arbitrary duplication.
//
let vault <- authAccount.copy<@Vault>(from: /storage/vault)
As it is convenient to work with objects in storage
without having to move them out of storage,
as it is necessary for resources,
it is also possible to create references to objects in storage:
This is possible using the borrow
function of an AuthAccount
:
fun borrow<T: &Any>(from: Path): T?`
Returns a reference to an object in storage without removing it from storage.
If no object is stored under the given path, the function returns nil
.
If there is an object stored, a reference is returned as an optional.
T
is the type parameter for the object type.
A type argument for the parameter must be provided explicitly.
The type argument must be a reference to any type (&Any
; Any
is the supertype of all types).
It must be possible to create the given reference type T
for the stored / borrowed object.
If it is not, the function returns nil
.
The given type does not necessarily need to be exactly the same as the type of the borrowed object.
The path must be a storage path, i.e., only the domain storage
is allowed.
// Declare a resource interface named `HasCount`, that has a field `count`
//
resource interface HasCount {
count: Int
}
// Declare a resource named `Counter` that conforms to `HasCount`
//
resource Counter: HasCount {
pub var count: Int
pub init(count: Int) {
self.count = count
}
}
// In this example an authorized account is available through the constant `authAccount`.
// Create a new instance of the resource type `Counter`
// and save it in the storage of the account.
//
// The path `/storage/counter` is used to refer to the stored value.
// Its identifier `counter` was chosen freely and could be something else.
//
authAccount.save(<-create Counter(count: 42), to: /storage/counter)
// Create a reference to the object stored under path `/storage/counter`,
// typed as `&Counter`.
//
// `counterRef` has type `&Counter?` and is a valid reference, i.e. non-`nil`,
// because the borrow succeeded:
//
// There is an object stored under path `/storage/counter`
// and it has type `Counter`, so it can be borrowed as `&Counter`
//
let counterRef = authAccount.borrow<&Counter>(from: /storage/counter)
counterRef?.count // is `42`
// Create a reference to the object stored under path `/storage/counter`,
// typed as `&{HasCount}`.
//
// `hasCountRef` is non-`nil`, as there is an object stored under path `/storage/counter`,
// and the stored value of type `Counter` conforms to the requested type `{HasCount}`:
// the type `Counter` implements the restricted type's restriction `HasCount`
let hasCountRef = authAccount.borrow<&{HasCount}>(from: /storage/counter)
// Create a reference to the object stored under path `/storage/counter`,
// typed as `&{SomethingElse}`.
//
// `otherRef` is `nil`, as there is an object stored under path `/storage/counter`,
// but the stored value of type `Counter` does not conform to to the requested type `{Other}`:
// the type `Counter` does not implement the restricted type's restriction `Other`
let otherRef = authAccount.borrow<&{Other}>(from: /storage/counter)
// Create a reference to the object stored under path `/storage/nonExistent`,
// typed as `&{HasCount}`.
//
// `nonExistentRef` is `nil`, as there is nothing stored under path `/storage/nonExistent`
//
let nonExistentRef = authAccount.borrow<&{HasCount}>(from: /storage/nonExistent)
Users will often want to make it so that specific other users or even anyone else can access certain fields and functions of a stored object. This can be done by creating a capability.
As was mentioned before, access to stored objects is governed by the tenets of Capability Security. This means that if an account wants to be able to access another account's stored objects, it must have a valid capability to that object.
Capabilities are identified by a path and link to a target path, not directly to an object. Capabilities are either public (any user can get access), or private (access to/from the authorized user is necessary).
Public capabilities are created using public paths, i.e. they have the domain public
.
After creation they can be obtained from both authorized accounts (AuthAccount
)
and public accounts (PublicAccount
).
Private capabilities are created using private paths, i.e. they have the domain private
.
After creation they can be obtained from authorized accounts (AuthAccount
),
but not from public accounts (PublicAccount
).
Once a capability is created and obtained, it can be borrowed to get a reference to the stored object. When a capability is created, a type is specified that determines as what type the capability can be borrowed. This allows exposing and hiding certain functionality of a stored object.
Capabilities are created using the link
function of an authorized account (AuthAccount
):
fun link<T: &Any>(_ newCapabilityPath: Path, target: Path): Capability<T>?
newCapabilityPath
is the public or private path identifying the new capability.
target
is any public, private, or storage path that leads to the object
that will provide the functionality defined by this capability.
T
is the type parameter for the capability type.
A type argument for the parameter must be provided explicitly.
The type parameter defines how the capability can be borrowed, i.e., how the stored value can be accessed.
The link function returns nil
if a link for the given capability path already exists,
or the newly created capability if not.
It is not necessary for the target path to lead to a valid object; the target path could be empty, or could lead to an object which does not provide the necessary type interface:
The link function does not check if the target path is valid/exists at the time the capability is created and does not check if the target value conforms to the given type.
The link is latent. The target value might be stored after the link is created, and the target value might be moved out after the link has been created.
Capabilities can be removed using the unlink
function of an authorized account (AuthAccount
):
fun unlink(_ path: Path)
path
is the public or private path identifying the capability that should be removed.
To get the target path for a capability, the getLinkTarget
function
of an authorized account (AuthAccount
) or public account (PublicAccount
) can be used:
fun getLinkTarget(_ path: Path): Path?
path
is the public or private path identifying the capability.
The function returns the link target path,
if a capability exists at the given path,
or nil
if it does not.
Existing capabilities can be obtained by using the getCapability
function
of authorized accounts (AuthAccount
) and public accounts (PublicAccount
):
fun getCapability<T>(_ at: Path): Capability<T>?
For public accounts, the function returns a capability
if the given path is public.
It is not possible to obtain private capabilities from public accounts.
If the path is private or a storage path, the function returns nil
.
For authorized accounts, the function returns a capability
if the given path is public or private.
If the path is a storage path, the function returns nil
.
T
is the type parameter that specifies how the capability can be borrowed.
The type argument is optional, i.e. it must not be provided.
The getCapability
function does not check if the target exists.
The link is latent.
The check
function of the capability can be used to check if the target currently exists and could be borrowed,
fun check<T: &Any>(): Bool
T
is the type parameter for the reference type.
A type argument for the parameter must be provided explicitly.
The function returns true if the capability currently targets an object that satisfies the given type, i.e. could be borrowed using the given type.
Finally, the capability can be borrowed to get a reference to the stored object.
This can be done using the borrow
function of the capability:
fun borrow<T: &Any>(): T?
The function returns a reference to the object targeted by the capability, provided it can be borrowed using the given type.
T
is the type parameter for the reference type.
If the function is called on a typed capability, the capability's type is used when borrowing.
If the capability is untyped, a type argument must be provided explicitly in the call to borrow
.
The function returns nil
when the targeted path is empty, i.e. nothing is stored under it,
and when the requested type exceeds what is allowed by the capability (or any interim capabilities).
// Declare a resource interface named `HasCount`, that has a field `count`
//
resource interface HasCount {
count: Int
}
// Declare a resource named `Counter` that conforms to `HasCount`
//
resource Counter: HasCount {
pub var count: Int
pub init(count: Int) {
self.count = count
}
}
// In this example an authorized account is available through the constant `authAccount`.
// Create a new instance of the resource type `Counter`
// and save it in the storage of the account.
//
// The path `/storage/counter` is used to refer to the stored value.
// Its identifier `counter` was chosen freely and could be something else.
//
authAccount.save(<-create Counter(count: 42), to: /storage/counter)
// Create a public capability that allows access to the stored counter object
// as the type `{HasCount}`, i.e. only the functionality of reading the field
//
authAccount.link<&{HasCount}>(/public/hasCount, target: /storage/counter)
To get the published portion of an account, the getAccount
function can be used.
Imagine that the next example is from a different account as before.
// Get the public account for the address that stores the counter
//
let publicAccount = getAccount(0x42)
// Get a capability for the counter that is made publicly accessible
// through the path `/public/hasCount`.
//
// Use the type `&{HasCount}`, a reference to some object that provides the functionality
// of interface `HasCount`. This is the type that the capability can be borrowed as
// (it was specified in the call to `link` above).
// See the example below for borrowing using the type `&Counter`.
//
// After the call, the declared constant `countCap` has type `Capability<&{HasCount}>`,
// a capability that results in a reference that has type `&{HasCount}` when borrowed.
//
let countCap = publicAccount.getCapability<&{HasCount}>(/public/hasCount)!
// Borrow the capability to get a reference to the stored counter.
//
// This borrow succeeds, i.e. the result is not `nil`,
// it is a valid reference, because:
//
// 1. Dereferencing the path chain results in a stored object
// (`/public/hasCount` links to `/storage/counter`,
// and there is an object stored under `/storage/counter`)
//
// 2. The stored value is a subtype of the requested type `{HasCount}`
// (the stored object has type `Counter` which conforms to interface `HasCount`)
//
let countRef = countCap.borrow()!
countRef.count // is `43`
// Invalid: The `increment` function is not accessible for the reference,
// because it has the type `&{HasCount}`
//
countRef.increment()
// Again, attempt to get a get a capability for the counter, but use the type `&Counter`.
//
// Getting the capability succeeds, because it is latent, but borrowing fails
// (the result s `nil`), because the capability was created/linked using the type `&{HasCount}`:
//
// The resource type `Counter` implements the resource interface `HasCount`,
// so `Counter` is a subtype of `{HasCount}`, but the capability only allows
// borrowing using unauthorized references of `{HasCount}` (`&{HasCount}`)
// instead of authorized references (`auth &{HasCount}`),
// so users of the capability are not allowed to borrow using subtypes,
// and they can't escalate the type by casting the reference either.
//
// This shows how parts of the functionality of stored objects
// can be safely exposed to other code
//
let counterRef = countCap.borrow()
// `counterRef` is `nil`
// Invalid: Cannot access the counter object in storage directly,
// the `borrow` function is not available for public accounts
//
let counterRef2 = publicAccount.borrow<&Counter>(/storage/counter)
A contract in Cadence is a collection of type definitions of interfaces, structs, resources, data (its state), and code (its functions) that lives in the contract storage area of an account in Flow. Contracts are where all composite types like structs, resources, events, and interfaces for these types in Cadence have to be defined. Therefore, an object of one of these types cannot exist without having been defined in a deployed Cadence contract.
Contracts can be created, updated, and deleted using the setCode
function of accounts.
This functionality is covered in the next section
Contracts are types. They are similar to composite types, but are stored differently than structs or resources and cannot be used as values, copied, or moved like resources or structs.
Contract stay in an account's contract storage area and can only be updated or deleted by the account owner with special commands.
Contracts are declared using the contract
keyword. The keyword is followed
by the name of the contract.
pub contract SomeContract {
// ...
}
Contracts cannot be nested in each other.
pub contract Invalid {
// Invalid: Contracts cannot be nested in any other type.
//
pub contract Nested {
// ...
}
}
One of the simplest forms of a contract would just be one with a state field,
a function, and an `init` function that initializes the field:
```cadence,file=contract-hello.cdc
// HelloWorldResource.cdc
pub contract HelloWorld {
// Declare a stored state field in HelloWorld
//
pub let greeting: String
// Declare a function that can be called by anyone
// who imports the contract
//
pub fun hello(): String {
return self.greeting
}
init() {
self.greeting = "Hello World!"
}
}
This contract could be deployed to an account and live permanently in the contract storage. Transactions and other contracts can interact with contracts by importing them at the beginning of a transaction or contract definition.
Anyone could call the above contract's hello
function by importing
the contract from the account it was deployed to and using the imported
object to call the hello function.
import HelloWorld from 0x42
// Invalid: The contract does not know where hello comes from
//
log(hello()) // Error
// Valid: Using the imported contract object to call the hello
// function
//
log(HelloWorld.hello()) // prints "Hello World!"
// Valid: Using the imported contract object to read the greeting
// field.
log(HelloWorld.greeting) // prints "Hello World!"
// Invalid: Cannot call the init function after the contract has been created.
//
HelloWorld.init() // Error
There can be any number of contracts per account and they can include an arbitrary amount of data. This means that a contract can have any number of fields, functions, and type definitions, but they have to be in the contract and not another top-level definition.
// Invalid: Top-level declarations are restricted to only be contracts
// or contract interfaces. Therefore, all of these would be invalid
// if they were deployed to the account contract storage and
// the deployment would be rejected.
//
pub resource Vault {}
pub struct Hat {}
pub fun helloWorld(): String {}
let num: Int
Another important feature of contracts is that instances of resources and events that are declared in contracts can only be created/emitted within functions or types that are declared in the same contract.
It is not possible create instances of resources and events outside the contract.
The contract below defines a resource interface Receiver
and a resource Vault
that implements that interface. The way this example is written,
there is no way to create this resource, so it would not be usable.
// Valid
pub contract FungibleToken {
pub resource interface Receiver {
pub balance: Int
pub fun deposit(from: @Receiver) {
pre {
from.balance > 0:
"Deposit balance needs to be positive!"
}
post {
self.balance == before(self.balance) + before(from.balance):
"Incorrect amount removed"
}
}
}
pub resource Vault: Receiver {
// keeps track of the total balance of the accounts tokens
pub var balance: Int
init(balance: Int) {
self.balance = balance
}
// withdraw subtracts amount from the vaults balance and
// returns a vault object with the subtracted balance
pub fun withdraw(amount: Int): @Vault {
self.balance = self.balance - amount
return <-create Vault(balance: amount)
}
// deposit takes a vault object as a parameter and adds
// its balance to the balance of the Account's vault, then
// destroys the sent vault because its balance has been consumed
pub fun deposit(from: @Receiver) {
self.balance = self.balance + from.balance
destroy from
}
}
}
If a user tried to run a transaction that created an instance of the Vault
type,
the type checker would not allow it because only code in the FungibleToken
contract can create new Vault
s.
import FungibleToken from 0x42
// Invalid: Cannot create an instance of the `Vault` type outside
// of the contract that defines `Vault`
//
let newVault <- create FungibleToken.Vault(balance: 10)
The contract would have to either define a function that creates new
Vault
instances or use its init
function to create an instance and
store it in the owner's account storage.
This brings up another key feature of contracts in Cadence. Contracts
can interact with its account's storage
and published
objects to store
resources, structs, and references.
They do so by using the special self.account
object that is only accessible within the contract.
Imagine that these were declared in the above FungibleToken
contract.
pub fun createVault(initialBalance: Int): @Vault {
return <-create Vault(balance: initialBalance)
}
init(balance: Int) {
let vault <- create Vault(balance: 1000)
self.account.save(<-vault, to: /storage/initialVault)
}
Now, any account could call the createVault
function declared in the contract
to create a Vault
object.
Or the owner could call the withdraw
function on their own Vault
to send new vaults to others.
import FungibleToken from 0x42
// Valid: Create an instance of the `Vault` type by calling the contract's
// `createVault` function.
//
let newVault <- create FungibleToken.createVault(initialBalance: 10)
Contracts have the implicit field let account: Account
,
which is the account in which the contract is deployed too.
This gives the contract the ability to e.g. read and write to the account's storage.
In order for a contract to be used in Cadence, it needs to be deployed to an account.
A contract can be deployed to an account using the setCode
function of the AuthAccount
type:
fun AuthAccount.setCode(_ code: [UInt8], ... contractInitializerArguments)
The code
parameter is the byte representation of the source code.
All additional arguments that are given are passed further to the initializer
of the contract that is being deployed.
For example, assuming the following contract code should be deployed:
pub contract Test {
pub let message: String
init(message: String) {
self.message = message
}
}
The contract can be deployed as follows:
// Decode the hex-encoded source code into a byte array
// using the built-in function `decodeHex`.
//
// (The ellipsis ... indicates the remainder of the string)
//
let code = "70756220636f6e...".decodeHex()
// `code` has type `[UInt8]`
let signer: Account = ...
signer.setCode(
code,
message: "I'm a new contract in an existing account"
)
Like composite types, contracts can have interfaces that specify rules about their behavior, their types, and the behavior of their types.
Contract interfaces have to be declared globally. Declarations cannot be nested in other types.
If a contract interface declares a concrete type, implementations of it must also declare the same concrete type conforming to the type requirement.
If a contract interface declares an interface type, the implementing contract
does not have to also define that interface. They can refer to that nested
interface by saying {ContractInterfaceName}.{NestedInterfaceName}
// Declare a contract interface that declares an interface and a resource
// that needs to implement that interface in the contract implementation.
//
pub contract interface InterfaceExample {
// Implementations do not need to declare this
// They refer to it as InterfaceExample.NestedInterface
//
pub resource interface NestedInterface {}
// Implementations must declare this type
//
pub resource Composite: NestedInterface {}
}
pub contract ExampleContract: InterfaceExample {
// The contract doesn't need to redeclare the `NestedInterface` interface
// because it is already declared in the contract interface
// The resource has to refer to the resource interface using the name
// of the contract interface to access it
//
pub resource Composite: InterfaceExample.NestedInterface {
}
}
Events are special values that can be emitted during the execution of a program.
An event type can be declared with the event
keyword.
event FooEvent(x: Int, y: Int)
The syntax of an event declaration is similar to that of a function declaration; events contain named parameters, each of which has an optional argument label. Types that can be in event definitions are restricted to booleans, strings, integer, and arrays or dictionaries of these types.
Events can only be declared within a contract body. Events cannot be declared globally or within resource or struct types.
Resource argument types are not allowed because when a resource is used as an argument, it is moved. A piece of code would not want to move a resource to emit an event, so it is not allowed as a parameter.
// Invalid: An event cannot be declared globally
//
event GlobalEvent(field: Int)
pub contract Events {
// Event with explicit argument labels
//
event BarEvent(labelA fieldA: Int, labelB fieldB: Int)
// Invalid: A resource type is not allowed to be used
// because it would be moved and lost
//
event ResourceEvent(resourceField: @Vault)
}
To emit an event from a program, use the emit
statement:
pub contract Events {
event FooEvent(x: Int, y: Int)
// Event with argument labels
event BarEvent(labelA fieldA: Int, labelB fieldB: Int)
fun events() {
emit FooEvent(x: 1, y: 2)
// Emit event with explicit argument labels
// Note that the emitted event will only contain the field names,
// not the argument labels used at the invocation site.
emit FooEvent(labelA: 1, labelB: 2)
}
}
Emitting events has the following restrictions:
Events can only be invoked in an emit
statement.
This means events cannot be assigned to variables or used as function parameters.
Events can only be emitted from the location in which they are declared.
Transactions are objects that are signed by one or more accounts and are sent to the chain to interact with it.
Transactions are structured as such:
First, the transaction can import any number of types from external accounts using the import syntax.
import FungibleToken from 0x01
The body is declared using the transaction
keyword and its contents
are contained in curly braces.
Next is the body of the transaction, which first contains local variable declarations that are valid throughout the whole of the transaction.
transaction {
// transaction contents
let localVar: Int
...
}
Then, four optional main phases: Preparation, preconditions, execution, and postconditions, in that order. The preparation and execution phases are blocks of code that execute sequentially.
The following empty Cadence transaction contains no logic, but demonstrates the syntax for each phase, in the order these phases will be executed:
transaction {
prepare(signer1: AuthAccount, signer2: AuthAccount) {
// ...
}
pre {
// ...
}
execute {
// ...
}
post {
// ...
}
}
Although optional, each phase serves a specific purpose when executing a transaction and it is recommended that developers use these phases when creating their transactions. The following will detail the purpose of and how to use each phase.
Transactions may declare parameters. Transaction parameters are declared like function parameters. The arguments for the transaction are passed in the sent transaction.
Transaction parameters are accessible in all phases.
// Declare a transaction which has one parameter named `amount`
// that has the type `UFix64`
//
transaction(amount: UFix64) {
}
The prepare
phase is used when access to the private AuthAccount
object
of signing accounts is required for your transaction.
Direct access to signing accounts is only possible inside the prepare
phase.
For each signer of the transaction the signing account is passed as an argument to the prepare
phase.
For example, if the transaction has three signers,
the prepare must have three parameters of type AuthAccount
.
prepare(signer1: AuthAccount) {
// ...
}
As a best practice, only use the prepare
phase to define and execute logic that requires access
to the AuthAccount
objects of signing accounts,
and move all other logic elsewhere.
Modifications to accounts can have significant implications,
so keep this phase clear of unrelated logic to ensure users of your contract are able to easily read
and understand logic related to their private account objects.
The prepare phase serves a similar purpose as the initializer of a contract/resource/structure.
For example, if a transaction performs a token transfer, put the withdrawal in the prepare
phase,
as it requires access to the account storage, but perform the deposit in the execute
phase.
AuthAccount
objects have the permissions
to read from and write to the /storage/
and /private/
areas
of the account, which cannot be directly accessed anywhere else.
They also have the permission to create and delete capabilities that
use these areas.
The pre
phase is executed after the prepare
phase, and is used for checking
if explicit conditions hold before executing the remainder of the transaction.
A common example would be checking requisite balances before transferring tokens between accounts.
pre {
sendingAccount.balance > 0
}
If the pre
phase throws an error, or does not return true
the remainder of the transaction
is not executed and it will be completely reverted.
The execute
phase does exactly what it says, it executes the main logic of the transaction.
This phase is optional, but it is a best practice to add your main transaction logic in the section,
so it is explicit.
execute {
// Invalid: Cannot access the authorized account object,
// as `account1` is not in scope
let resource <- account1.load<@Resource>(from: /storage/resource)
destroy resource
// Valid: Can access any account's public Account object
let publicAccount = getAccount(0x03)
}
You may not access private AuthAccount
objects in the execute
phase,
but you may get an account's PublicAccount
object,
which allows reading and calling methods on objects
that an account has published in the public domain of its account (resources, contract methods, etc.).
Statements inside of the post
phase are used
to verify that your transaction logic has been executed properly.
It contains zero or more condition checks.
For example, the a transfer transaction might ensure that the final balance has a certain value, or e.g. it was incremented by a specific amount.
post {
result.balance == 30: "Balance after transaction is incorrect!"
}
If any of the condition checks result in false
, the transaction will fail and be completely reverted.
Only condition checks are allowed in this section. No actual computation or modification of values is allowed.
A Note about pre
and post
Phases
Another function of the pre
and post
phases is to help provide information
about how the effects of a transaction on the accounts and resources involved.
This is essential because users may want to verify what a transaction does before submitting it.
pre
and post
phases provide a way to introspect transactions before they are executed.
For example, in the future the phases could be analyzed and interpreted to the user in the software they are using, e.g. "this transaction will transfer 30 tokens from A to B. The balance of A will decrease by 30 tokens and the balance of B will increase by 30 tokens."
Cadence transactions use phases to make the transaction's code / intent more readable and to provide a way for developer to separate potentially 'unsafe' account modifying code from regular transaction logic, as well as provide a way to check for error prior / after transaction execution, and abort the transaction if any are found.
The following is a brief summary of how to use the prepare
, pre
, execute
,
and post
phases in a Cadence transaction.
transaction {
prepare(signer1: AuthAccount) {
// Access signing accounts for this transaction.
//
// Avoid logic that does not need access to signing accounts.
//
// Signing accounts can't be accesed anywhere else in the transaction.
}
pre {
// Define conditions that must be true
// for this transaction to execute.
}
execute {
// The main transaction logic goes here, but you can access
// any public information or resources published by any account.
}
post {
// Define the expected state of things
// as they should be after the transaction executed.
//
// Also used to provide information about what changes
// this transaction will make to accounts in this transaction.
}
}
Deploying contract code to an account was covered in the Deploying and Updating Contracts section of the spec.
Once a contract or contract interface has been deployed to an account, anybody can import the type from the account where it was deployed to and use it in their contracts or transactions.
Again, the type must be deployed to the account where it is being imported from.
Once code is deployed, it can be used in other code and in transactions.
Types can be represented at run-time.
To create a type value, use the constructor function Type<T>()
, which accepts the static type as a type argument.
This is similar to e.g. T.self
in Swift, T::class
in Kotlin, and T.class
in Java.
For example, to represent the type Int
at run-time:
let intType: Type = Type<Int>()
This works for both built-in and user-defined types. For example, to get the type value for a resource:
resource Collectible {}
let collectibleType = Type<@Collectible>()
// `collectibleType` has type `Type`
Type values are comparable.
Type<Int>() == Type<Int>()
Type<Int>() != Type<String>()
The function fun isInstance(_ type: Type): Bool
can be used to check if a value has a certain type,
using the concrete run-time type, and considering subtyping rules,
// Declare a variable named `collectible` that has the *static* type `Collectible`
// and has a resource of type `Collectible`
//
let collectible: @Collectible <- create Collectible()
// The resource is an instance of type `Collectible`,
// because the concrete run-time type is `Collectible`
//
collectible.isInstance(Type<@Collectible>()) // is `true`
// The resource is an instance of type `AnyResource`,
// because the concrete run-time type `Collectible` is a subtype of `AnyResource`
//
collectible.isInstance(Type<@AnyResource>()) // is `true`
// The resource is *not* an instance of type `String`,
// because the concrete run-time type `Collectible` is *not* a subtype of `String`
//
collectible.isInstance(Type<String>()) // is `false`
Note that the concrete run-time type of the object is used, not the static type.
// Declare a variable named `something` that has the *static* type `AnyResource`
// and has a resource of type `Collectible`
//
let something: @AnyResource <- create Collectible()
// The resource is an instance of type `Collectible`,
// because the concrete run-time type is `Collectible`
//
something.isInstance(Type<@Collectible>()) // is `true`
// The resource is an instance of type `AnyResource`,
// because the concrete run-time type `Collectible` is a subtype of `AnyResource`
//
something.isInstance(Type<@AnyResource>()) // is `true`
// The resource is *not* an instance of type `String`,
// because the concrete run-time type `Collectible` is *not* a subtype of `String`
//
something.isInstance(Type<String>()) // is `false`
For example, this allows implementing a marketplace sale resource:
pub resource SimpleSale {
/// The resource for sale.
/// Once the resource is sold, the field becomes `nil`.
///
pub var resourceForSale: @AnyResource?
/// The price that is wanted for the purchase of the resource.
///
pub let priceForResource: UFix64
/// The type of currency that is required for the purchase.
///
pub let requiredCurrency: Type
pub let paymentReceiver: Capability<&{FungibleToken.Receiver}>
/// `paymentReceiver` is the capability that will be borrowed
/// once a valid purchase is made.
/// It is expected to target a resource that allows depositing the paid amount
/// (a vault which has the type in `requiredCurrency`).
///
init(
resourceForSale: @AnyResource,
priceForResource: UFix64,
requiredCurrency: Type,
paymentReceiver: Capability<&{FungibleToken.Receiver}>
) {
self.resourceForSale <- resourceForSale
self.priceForResource = priceForResource
self.requiredCurrency = requiredCurrency
self.paymentReceiver = paymentReceiver
}
destroy() {
// When this sale resource is destroyed,
// also destroy the resource for sale.
// Another option could be to transfer it back to the seller.
destroy self.resourceForSale
}
/// buyObject allows purchasing the resource for sale by providing
/// the required funds.
/// If the purchase succeeds, the resource for sale is returned.
/// If the purchase fails, the program aborts.
///
pub fun buyObject(with funds: @FungibleToken.Vault): @AnyResource {
pre {
// Ensure the resource is still up for sale
self.resourceForSale != nil: "The resource has already been sold"
// Ensure the paid funds have the right amount
funds.balance >= self.priceForResource: "Payment has insufficient amount"
// Ensure the paid currency is correct
funds.isInstance(self.requiredCurrency): "Incorrect payment currency"
}
// Transfer the paid funds to the payment receiver
// by borrowing the payment receiver capability of this sale resource
// and depositing the payment into it
let receiver = self.paymentReceiver.borrow()
?? panic("failed to borrow payment receiver capability")
receiver.deposit(from: <-funds)
let resourceForSale <- self.resourceForSale <- nil
return <-resourceForSale
}
}
fun panic(_ message: String): Never
Terminates the program unconditionally and reports a message which explains why the unrecoverable error occurred.
let optionalAccount: Account? = // ...
let account = optionalAccount ?? panic("missing account")
fun assert(_ condition: Bool, message: String)
Terminates the program if the given condition is false, and reports a message which explains how the condition is false. Use this function for internal sanity checks.
The message argument is optional.
fun unsafeRandom(): UInt64
Returns a pseudo-random number.
NOTE: The use of this function is unsafe if not used correctly.
Follow best practices to prevent security issues when using this function.
To get the addresses of the signers of a transaction,
use the address
field of each signing AuthAccount
that is passed to the transaction's prepare
phase.
There is currently no API that allows getting other transaction information. Please let us know if your use-case demands it by request this feature in an issue.
To get information about a block, the functions getCurrentBlock
and getBlock
can be used:
fun getCurrentBlock(): Block
Returns the current block, i.e. the block which contains the currently executed transaction.
fun getBlock(at height: UInt64): Block?
Returns the block at the given height.
If the given block does not exist the function returns nil
.
The Block
type contains the identifier, height, and timestamp:
pub struct Block {
/// The ID of the block.
///
/// It is essentially the hash of the block.
///
pub let id: [UInt8; 32]
/// The height of the block.
///
/// If the blockchain is viewed as a tree with the genesis block at the root,
// the height of a node is the number of edges between the node and the genesis block
///
pub let height: UInt64
/// The timestamp of the block.
///
/// It is the local clock time of the block proposer when it generates the block
///
pub let timestamp: UFix64
}
The built-in contract Crypto
can be used to perform cryptographic operations.
The contract can be imported using import Crypto
.
For example, to verify two signatures with equal weights for some signed data:
import Crypto
pub fun test main() {
let keyList = Crypto.KeyList()
let publicKeyA = Crypto.PublicKey(
publicKey:
"db04940e18ec414664ccfd31d5d2d4ece3985acb8cb17a2025b2f1673427267968e52e2bbf3599059649d4b2cce98fdb8a3048e68abf5abe3e710129e90696ca".decodeHex(),
signatureAlgorithm: Crypto.ECDSA_P256
)
keyList.add(
publicKeyA,
hashAlgorithm: Crypto.SHA3_256,
weight: 0.5
)
let publicKeyB = Crypto.PublicKey(
publicKey:
"df9609ee588dd4a6f7789df8d56f03f545d4516f0c99b200d73b9a3afafc14de5d21a4fc7a2a2015719dc95c9e756cfa44f2a445151aaf42479e7120d83df956".decodeHex(),
signatureAlgorithm: Crypto.ECDSA_P256
)
keyList.add(
publicKeyB,
hashAlgorithm: Crypto.SHA3_256,
weight: 0.5
)
let signatureSet = [
Crypto.KeyListSignature(
keyIndex: 0,
signature:
"8870a8cbe6f44932ba59e0d15a706214cc4ad2538deb12c0cf718d86f32c47765462a92ce2da15d4a29eb4e2b6fa05d08c7db5d5b2a2cd8c2cb98ded73da31f6".decodeHex()
),
Crypto.KeyListSignature(
keyIndex: 1,
signature:
"bbdc5591c3f937a730d4f6c0a6fde61a0a6ceaa531ccb367c3559335ab9734f4f2b9da8adbe371f1f7da913b5a3fdd96a871e04f078928ca89a83d841c72fadf".decodeHex()
)
]
// "foo", encoded as UTF-8, in hex representation
let signedData = "666f6f".decodeHex()
let isValid = keyList.isValid(
signatureSet: signatureSet,
signedData: signedData
)
}
The API of the Crypto contract is:
pub contract Crypto {
pub struct SignatureAlgorithm {
pub let name: String
}
/// ECDSA_P256 is Elliptic Curve Digital Signature Algorithm (ECDSA) on the NIST P-256 curve
pub let ECDSA_P256: SignatureAlgorithm
/// ECDSA_Secp256k1 is Elliptic Curve Digital Signature Algorithm (ECDSA) on the secp256k1 curve
pub let ECDSA_Secp256k1: SignatureAlgorithm
pub struct HashAlgorithm {
pub let name: String
}
/// SHA2_256 is Secure Hashing Algorithm 2 (SHA-2) with a 256-bit digest
pub let SHA2_256: HashAlgorithm
/// SHA3_256 is Secure Hashing Algorithm 3 (SHA-3) with a 256-bit digest
pub let SHA3_256: HashAlgorithm
pub struct PublicKey {
pub let publicKey: [UInt8]
pub let signatureAlgorithm: SignatureAlgorithm
init(publicKey: [UInt8], signatureAlgorithm: SignatureAlgorithm)
}
pub struct KeyListEntry {
pub let keyIndex: Int
pub let publicKey: PublicKey
pub let hashAlgorithm: HashAlgorithm
pub let weight: UFix64
pub let isRevoked: Bool
init(
keyIndex: Int,
publicKey: PublicKey,
hashAlgorithm: HashAlgorithm,
weight: UFix64,
isRevoked: Bool
)
}
pub struct KeyList {
init()
/// Adds a new key with the given weight
pub fun add(
_ publicKey: PublicKey,
hashAlgorithm: HashAlgorithm,
weight: UFix64
)
/// Returns the key at the given index, if it exists.
/// Revoked keys are always returned, but they have `isRevoked` field set to true
pub fun get(keyIndex: Int): KeyListEntry?
/// Marks the key at the given index revoked, but does not delete it
pub fun revoke(keyIndex: Int)
/// Returns true if the given signatures are valid for the given signed data
pub fun isValid(
signatureSet: [KeyListSignature],
signedData: [UInt8]
): Bool
}
pub struct KeyListSignature {
pub let keyIndex: Int
pub let signature: [UInt8]
pub init(keyIndex: Int, signature: [UInt8])
}
}


Man remanded for killing his mother in Ebonyi
by Edward NnachiEdward Nnachi, Abakaliki
An Ebonyi State Magistrates’ Court sitting in Abakaliki, on Monday, remanded a 38-year-old man, Simon Ozibo, in a correctional facility for murdering his mother, Mrs Felicia Ozibo.
It was gathered that the suspect committed the crime on Thursday, November 14, 2019, at Iziogo community in the Izzi Local Government Area of the state.
The accused allegedly murdered his mother in the presence of his wife with a cutlass and shovel when she came to his house to visit him.
In his confessional statement, Simon said he had always seen her as being responsible for his ugly experience in life.
He added that he was in the habit of smoking India hemp, but maintained that on the day of the incident, he was not under the influence of drugs and alcohol.
The accused was arraigned on one count of murder.
The police prosecutor, Eze Ndubuako, told the court that the offence was punishable under Section 319(1) of the Criminal Code, Cap. 33, Vol. 1, Laws of Ebonyi State of Nigeria, 2009.
The charge read, “That you, Simon Ozibo, on November 14, 2019, at the Iziogo community in the jurisdiction of this honourable court, did unlawfully caused the death of one Felicia Ozibo by cutting her into pieces with a machete, thereby committing an offence punishable under Section 319(1) of the Criminal Code, Cap. 33, Vol. 1, Laws of Ebonyi State of Nigeria, 2009.”
The Chief Magistrate, Nnenna Onuoha, did not grant the suspect bail, because the matter was beyond the jurisdiction of her court.
She directed that Simon be remanded in the Nigerian Correctional Centre, Abakaliki, and that his case file be transferred to the office of the Director of Public Prosecutions for advice.
The matter was adjourned till December 6, 2019, for the DPP’s report of compliance.
Copyright PUNCH.
All rights reserved. This material, and other digital content on this website, may not be reproduced, published, broadcast, rewritten or redistributed in whole or in part without prior express written permission from PUNCH.
Contact: theeditor@punchng.com


{% extends "form2/base.html" %} {% block form %}
| Division | Team Name | Team Members | ||
|---|---|---|---|---|
| {{team.division}} | {{team.team_name}} | {% for member in team.members %}{{member.first_name}} {{member.last_name}} | {% endfor %} {% set pad = 3 - team.members|length %} {% for i in range(pad) %}{% endfor %} |


Menu
Feedback
Sign Up
Help nearby
Login
Sign Up
First name:
Last name:
Username:
E-mail address:
Your password:
Passwords must be at least 6 characters.
Repeat password:
Passwords must match.


I recommend you to keep sources in gist.github.com.
1. Create a new gist with index.html (sample #4772996).
2. Reference it in via hash http://cmx.io/edit/#4772996
3. Publish the gist via http://cmx.io/#4772996
Note: I can't write your changes back to gist,
you have to copy&paste final work to gist yourself!
Please make sure that
Here is an example of a working gist http://cmx.io/edit/#74e3dc0e166daf1ec668 which reads https://gist.github.com/74e3dc0e166daf1ec668.
The Comix Editor was tested under Chrome. It uses some webkit-specific tricks.
It is a prototype. Currently it is broken under Firefox, Opera and IE.
Please, run it in the latest Chrome or Safari.
Interested in porting it to your favorite browser? Check out the sources.


The Future Is Blue: PUMA Launch The 5.1 Flash Pack
by SL SocialThe likes of Themba Zwane and Percy Tau will be the first players from Mzansi to rock the brand new Blue PUMA Future 5.1 Flash Pack.
The stars couldn’t hide their excitement on Instagram and showed fans glimpses of their brand new tools.
PUMA this week came out with the latest luminous blue Future.
With the most agile players in mind, the German sportswear giant added a lightweight RAPIDAGILITY outsole, which enables players to change direction at the speed of light.
Download The Soccer Laduma Social Media App & Earn Airtime for Selfies!
It’s safe to say that these are one of PUMA’s most aesthetically pleasing boots this season, with its split blue and black colour as well as the word future emblazoned on the back.
FC Barcelona’s superstar duo, Luis Suarez and Antoine Griezmann will instill fear into the hearts of defenders with the stunning new boots.
To see the new PUMA Flash Pack, scroll through the gallery above!
What are your thoughts on the new PUMA boots?


Maptcha is a web-based interface doing rough placements of historical maps on modern geography.
The first version of maptcha.org was launched by Mike Migurski in July 2011, using the 1905 Sanborn Fire Insurance Atlas as its first map series test case. The atlas contained about 700 pages of street level maps of San Francisco, and when it was launched, volunteers from around the world used the site to place each page on to a modern map of the city, all within a few days, which was a wonderful surprise!
The application was further developed in 2012 by Stamen Design in San Francisco, under a grant from The Bill Lane Center for the American West at Stanford University to support for the 2013Year of the Bay project, crowdsourcing a new history of the San Francisco Bay Area.
Lorem ipsum
Lorem ipsum
Lorem ipsum
Lorem ipsum
The Year of the Bay project code lives on Github: