Online Marketing

Django Web App Development on the Raspberry Pi

So what is Django well Django is a web development framework that saves you time and makes web development a joy using Django. You can build and maintain high-quality web applications with minimal fuss, and we are all going to do that on the Raspberry Pi.

The Raspberry Pi is a tiny computer with enough power to run a Django development server. So here we’re going to attempt installing and deploying our first Django project on the Raspberry Pi and maybe develop a web application on later articles. You may be asking why don’t we just build a web application from scratch without a framework? Well, there will come a time when your application would be needing to connect to a database, and you would end up duplicating your database connection code to other parts of your application.

The practical way is to refactor it into a reusable function. Another problem you’ll encounter is you have to remember to close your database every time and you will end up with a lot of boilerplate code that is prone to mistakes. Your application may not be reusable in a different environment because of some environments, specific configuration. And lastly, if a web designer, who has no experience in coding, wants to redesign the page, he or she might crash the application, because, ideally the logic of the page or the retrieval of information from the database would be separate from the presentation which is the HTML Display of the page, these problems are precisely what a web framework intends to solve.

I’r sure some of you are already familiar with the MVC design pattern or Model View controller design pattern for beginners MVC, like what I mentioned earlier, is a django architecture that separates the logic, the model and the controller from the presentation. The view in django it’s more like an mtv or model template view design pattern. Don’t worry about that now, we’ll get more into that later.

In the meantime, let’s go ahead and install django on the raspberry pi. Okay, so I have here a freshly installed raspbian, which is the official operating system of the raspberry pi. What we’re going to do here is to open up a terminal and install virtual ends, which stands for a virtual environment. To put it simply, virtual environment is an isolated working copy of Python, which allows you to work on a specific project without worry of affecting other projects.

So let’s go ahead and install virtual end, but before we do that, let’s update our package lists by typing sudo. Apt-Get update and when it’s done updating we can go ahead and type in sudo, apt-get install virtual end hit enter, and in my computer, my or my raspberry pi, it’s already been installed. Now that we have our virtual environment installed. We can now create our virtual environment directory that we are going to use for our project to do that.

We just type virtual end dot. Then P, slash user, slash bin, slash Python 3. What this code does is. It makes a hidden directory called vent because in Linux beginning your directory name with the dot, makes that directory hidden and the dash B is an option. You pass virtual environment on what version of Python you want to use. In this case, we want to use Python 3 inside slash user USR, slash bin now hit enter, and when it’s done, if you type LS la you would see that it created our project directory as expected to use it.

We just type source that Ven slash bin. Slash activate you will see our prompt has changed, indicating that we are now in our isolated Python environment. We just type the activate to go back to our regular, prompt and escape our isolated Python environment. We can now install django. There are other ways to install django, but for simplicity, we’ll use pip to install the latest version of django available from PI P or the Python package index repository to do that.

We just type pip, install django and hit enter to test Jiang, the Django installation. You just start up a Python, interactive interpreter by typing Python, and if the installation was successful, we should be able to import Django and check its version. Okay. Moving on, we can now take our first step into creating our first project. A project is a collection of settings for an instance of Django, including database configuration Django, specific options and application specific settings.

So let’s exit our Python shell and type sy, Django admin, the PI or just Django admin, start project. Then the name of our project, which we’ll just name my site for now then hit enter okay. So it says that my site directory already exists just going to delete, delete it for now and make another one. So I’m just going to repeat the command Django admin that I start project my site and then hit enter.

What the start project command does is it creates a directory containing six files? Okay, there we are my site, which is the outer. My site directory is just a container for our project. It name doesn’t matter to Jango, you can rename it to anything. You like manage that PI py is a command line utility that lets you interact with this Jango project in various ways. Type Python manage that hi-oh. We just have to change into the directory first and type Python manage that py help to get a feel for what it can do.

Okay, so here are your options now you should never have to edit this file. It’s created in this directory purely for convenience. Okay, so let’s go back to files that were created. Oh now, it has added a few more files, but we’ll just go over on the basic files that we are concerned about. The next is the inner my site directory. It is the actual Python package for your project and we have our ini’ that py, it’s an empty file required for python to treat the my site directory as a package example a group of python modules – and we also have our settings that pi, which is the Settings configuration for this Django project take a look at it to get an idea of the types of settings available along with their default values.

Okay, so we’ll just skip that for now and we have our URL stat pot, the URLs that PI for this Django project is the table of contents of your jungle powered site. Next. Is we have our WSGI pi an entry point for WSGI compatible web servers to serve your project? And lastly, we have Ras GI that pipe as well as WSGI Jango also supports deploying on a SGI which is the emerging python standard for a synchronous, web servers and applications.

Now to see our barebone application in action. Let’s run the server by changing into the directory of our project, CD, my site and type the command that slash manage, that pi run server the run server launches the built-in django development server, which is a lightweight web server that we can use while developing our site. We will receive a warning message in red telling us we have unapplied migrations welljust.

We will just ignore that for now. Okay, now, if we open up our browser and go to HTTP colon, slash slash colin 8000, which is the IP address that stands for home on port 8000 and if everything goes well, then we’ll see that it works by default. The run server command starts the development server on port 8000, listening only for local connections. If you want to change the server sport, pass it a command-line argument like so so, let’s just ctrl C and run our command again run server and we want to run it on port 8080.

So that’s how you change the port? Ok! So now we will access it here on port 8080. If you want other computers on your local network to be able to view your Django site by visiting your IP address in their web browsers, then you type manage that slash manage that pie run server. 8000. Well, that’s all we have for now in this tutorial. If you have any questions or comments, please post it in the comment section below down below and I’ll do my best to answer them.

If you enjoy the article, please hit the like button and kindly support my blog by subscribing again. My name is Ryan and you are reading recurse TV see you next time.


Online Marketing

Native Go Development on GCP with the Context Package – GopherCon SG 2017

This is a talk that was originally developed by a colleague of mine and the first thing he he asks. Everybody at the beginning is the Wi-Fi working, but – and so I’m borrowing this presentation, but uh, of course, is a Wi-Fi working is a Google office. So so obviously one people who you know take advantage of the fact that the Wi-Fi is not working.

But let’s take. Let’s imagine some NGO code that we’re just going to like talk about that’s going to just ping. The Google calm within HTTP yet – and you know, return an error if, if an error happens and also check the status code right, you’ve seen a lot of code. That looks like this, but there’s a couple of issues with this like say what happens if google comm, for some reason decides that they are going to essentially accept a request and then sleep forever before giving you a response, in that case, you’re going to be kind Of left out in the cold, because this is going to just essentially hang forever so so you know we could ping Google like this, but like.

Essentially, we want to be able to do something like canceled it in the middle of it like say, I only want to wait, maybe five or ten seconds for the response to come back and if not, then I want to do something else. So how would we do that in a go program and the way to do that is to use the context package and the context package is a very important package. I believe it was added to the standard library in 1.

5 and before that it lived as a you know: semi standard package in the golang org dot expat, you know directory, but it this became a standard standard library package and actually it’s worth 1.7 in 2016. Ok, so we got that wrong uh, it’s actually a lot later than I thought, but it essentially is about 370 lines without comments. It’s fairly, you know simple package, but it’s a it’s extremely extremely important, and inside of that it only exposes like one interface and several functions so the first.

The most important is the actual context, interface, and this context interface, is what you’ll be using and kind of objects that implement this interface are things that you’ll be passing around and using most of the time. So the context interface looks something like this. You’ll have an object that has all these like kind of methods on it. That done you know, deadlines and value and error, and we’ll kind of see how to use these as we’re going to go along.

The the done method essentially gives you a way of checking to see that a particular context is done, and you know to tell you kind of take, expect back and explain what a context is in a context is essentially a context or a or a wrapper that You can use to say when you get a request or you’re handling a sort of request. You can tell whether that request is done or to kind of attach values to that context that get passed along to lots of different components within the system and we’ll kind of see how that works in practice a little bit later.

I think that it’s easier instead of explaining what it is to actually see what it, how you use it. So it also has this error method too. In case you know timeouts and things like that happen – to get the actual error and these types of deadlines down here or these errors down here. These are actually uh. I think context types or actually error different types of error within within context that you can receive.

So how do we actually cancel the ping note when we did the when we paint go Google com? So if you aren’t going to change the interface itself, you can do the ping Google inside of a go routine and then ask the error that comes back to a blog, an error, blog and then essentially select on that error blog. So you could say whenever that ping is done, then you know return that error or wait if the content check, if the context is done and if the context is done, then return the contexts to error and then we can use the context to do to set Things like timeouts and whatnot, so here we’re doing this kind of we’re kind of wrapping.

Our ping Google function with this ping, Google, with context function, and then we can give it a context that can then do things like handle, timeouts and whatnot, and so how you set the context and how you actually create this context. Value is what’s kind of important for how it handles that. So, let’s talk about how to create context values themselves. So the context package exposes a number of functions that you can use to get context values.

The first one is the one that you can use that you use pretty often is the background, and this essentially returns the background context. So you can imagine that you might have an application that that will accept the request and then make several requests in the backend. So maybe you need to ping a you know: one run application server and another application server and another application server and then kind of aggregate.

The responses back so maybe you’re a web server that has to paying several other micro services within your architecture, and you can do that, like you know, asynchronously, say and then aggregate the responses back. But if any one of those takes too long, then your hold request. Will take too long or if say the client you know times out, then you want to cancel all of the requests that you’ve done.

So you can essentially take that context and pass it throughout your application to kind of and create a different context or create a type of tree structure. That will then allow you to to manage each of the different parts of the the dependent request so say like. If individual, if one individual request times out, then it becomes done, then all of the parent ones. That of that request will then, or that are dependent on it – will then actually become done as well, and so you can cancel the whole entire request out to the client and the reason why we call the background context is because this is essentially the root of That tree so – and this is actually a when you call this background – it returns you a single instance that is essentially a global context.

That’s used inside of your go program, another one that I’ve notice the to do, one, which is essentially the same thing its background, except for the fact that this is essentially labeling. The fact that you’re, you don’t know what you’re doing or you don’t know what. What context to use in that particular scenario, so you can go back and kind of check that later to actually kind of make sure that you’re passing context around properly.

So the easiest way to do this is there like get a context background and pass pass it to the ping with context, but this essentially doesn’t really do anything. There’s no timeouts or anything like that associated with this. So this is just going to give us a kind of background of or blank context, the same thing with to do so what we want to do is be able to say like either cancel it partway through, and so in this case, what we’re going to do Is kind of cancel it instead of like setting a timeout we’re going to just say you know, add the risk cancel wrapper to this.

So if we call with cancel this is going to give us another context, but also significantly it’s going to give it to this little cancel, and this cancel is actually a function that we can use that we can call to cancel our context. So if we do this, we can say with time after func, you know past one second call cancel, and so after one second we’re actually going to cancel our context. So if Google doesn’t respond within one second, we’re actually going to cancel the context and turn out of here and we’ll end up getting this could not ping Google error? Actually, we will get a if we look back at the code.

We will get a this context. Error and will actually see that, as could not paint Google and then it will say like context canceled or something similar like that. So another thing that you can use is to you can set timeouts, which essentially do the same thing as we did here, which is, after a second or two rule, call cancel. And here what we’re going to do is called the with timeout function, which gives us just where you pass the context and a deadline, a timeout and then with the final thing that you can do with context is actually pass a value to them.

And this can be used as kind of a you know. Maybe a request. Global type of you know key value store that you can use throughout the application. I’r not going to really talk about this too much, but you can essentially add some keys and values to a particular context and then use that throughout your request. So like say, you want to set a request ID and then log the request ID throughout the application.

You can use something like that here, so these context values as I’m doing this. I mentioned that it caused, creates this key structure, so we need call it background. It creates idiot, it creates this background or it uses this background context, which is a global route context, and then, when we call with cancel or with value from the context package, it’s actually going to create us a new context that does a that creates a a Sub sub context, that is a or is it a child of the the background context, and then it as we do this.

It creates a new and newer context to form a kind of tree, so you can kind of create call on the the valid the value that got returned from with cancel. You can actually call things like with deadlines or with value on those as well, and it forms this kind of tree structure. So if any one of these like say this, one that was returned by with value at the bottom here becomes finishes, then all those contexts above it will then continue.

It will kind of propagate throughout the system back to the via to the original context. So, let’s kind of go back so the deadlines exceeded error is, is one of the errors within context that can kind of get used to that. You can kind of check when these are, when you use the this West deadline and there’s also a cancelled error as well that you can check for so this is another, so this is so when you get the son of errors back from your context, this is Something that you should actually kind of handle these type of errors, gracefully not just or don’t just check them.

You actually have to handle them, and this is actually written by was said by somebody who had believed in the audience. It kind of looks like this vaguely, but yeah he’s. This is actually a really really good thing to say or a thing to follow in that you really want to be able to handle things like handling timeouts and handling these types of things gracefully. But what happens? A lot of times is that folks, don’t actually use the context package, and so they don’t even know that there’s it’s not like an error gets passed back to them.

It’s a nice that they’re not even kind of handling something or they’re, not even understanding that there could be an error to begin with. So and that’s that’s the case with things like deadlines and timeouts. So I’m going to kind of skip over these a little bit. But essentially, what you can kind of do with the the cancel is you can do things like actually cancel it later um, but I think what I’m going to do is actually kind of go through and show you a little bit about how to actually use the Package itself and what that looks like kind of in practice right so here I’ve got a kind of application that is going to do to basically wait for a certain number of seconds and then it’s going to print a message right.

This is a very simple application, and so here I have kind of a main method that, where I’m doing getting this context and then I’m going to wrap that another with another context here with the Swiss timeout and give it. You know this four seconds. So this is kind of how we did this with the or how I show that you can use this to context package, but just this will actually show you how, within your applications, you can actually receive a context and then kind of actually make use of it.

So here the de nieve way to do it would be just to do something like time sleep. I think you could just take the duration here and then you would just say log print. You know: what’s our message here: msg right and if we do something like just run, this go run, startup go. It will essentially wait for three seconds and then print our message, hello, right and if we said that this timeout was two seconds we would.

We might expect that that we would actually timeout, but that’s actually not the case, we’re actually going to just we’re actually going to wait two three seconds and then print our message. So why is that? The reason? Why is because we have to actually check that to make sure that the context is done and we’ll do that using the Select using select to kind of check the the done the done blog on the context as well as checking when app-like will check the timer.

That will set for the original three-second. So the first thing we’ll do is handle the base case, which is to check time after our de regular duration and then we’ll just say a log print message and then our other case, which is to check. If the context is done, we’ll actually check the context, blog TX done and then we’ll just say. Actually this doesn’t return an error so we’ll just log that here as well, pretest and we’ll just say: V CT X, dot, v RR like this right.

So this should actually check to check our context so that when we, if the context actually times out, then it will return a value on this context, done blog and I’ll actually drop out here and print the error that came back from the context. So you might expect as well that if we extend this deadline here, that it will actually run through to completion and for an hour, hello message. So that’s great, that’s really interesting, but the real power.

What comes when you have like things like clients, types of applications, client-server type of applications, so I’m going to drop out to a client app and what this is going to do is just kind of ping. Our do a request to a local host, and so what we’re going to do here is create a context that we’re going to send it to our web server. That’s going to actually it’s going to wait, set a timeout for our for our web server.

So we’ll say, see: TX TX, equals context background and will actually set a context, cancel a rules, yech context with timeout TX and then we’ll set, it is to say like three seconds and then we’ll defer the cancel. So the cancel actually deferring, cancel and running cancel here is important because this actually sets up some timer or you set some some resources using to to run the timer. And so we need to actually cancel that so that make sure that those are freed and then we’re going to set the request for our HTTP server to request with context, I believe, is the right incantation.

So here we’ve created a HTTP request and then we’ve created our context and we’re setting it there with context. This should be request. My fake CTX. Let me if I remember right here, it’s going to complain about this. A little bit call to voice context. It’s you P request context, think it was that yeah, that’s right, because this is actually a method: okay, yeah! So it’s! This is actually a compiling now.

So then, we’ll actually go jump over to our server app and we’ll implement, essentially the same sort of application, but we’re going to like return our hello message from the web server. So here we can say we’ll have this sleep and talk and we’ll say, select on this and run this guy again. Essentially after time, it’s kinda after D, then we’ll say, take this writer and then write a gosh. I had this as a string, so miss a GE and then this is a case gets done and then you’ll return.

This is actually not returning error, but let’s see just log the error message: protests TX start there right so with our application. Here we should we’re going to pass it the the response writer for our for our HTTP server, so that our right to the client and then we’ll have this we’ll. Have it wait for five seconds before returning hello to the client right and I’m going to jump out here and actually run this just allow that and then, if we jump back over to our client, you should see that we have a timeout here of three seconds.

So we can expect that our client will actually timeout this time. Okay, so the client deadline exceeded is the error message that we got out here because we’re actually the client times out after three seconds, but our server is, is actually waiting five seconds before a before printing the message, so our server is taking actually five seconds to Have returned a message, so we can kind of extend this to actually make it work, but or we can go back to our server side application and go to the five seconds here and make this two instead and then, if we do that, then our client app One should actually return the hello message rate, so so this is a great way to like from the clients perspective, as well as the service perspective, so like.

If the client makes a request to a server, that’s going to take a long time, you want to be able to set timeouts so that you’re going to actually be able to to like not wait forever and on the server side as well. You don’t want to wait for clients to send their their the request forever right. You, the server, wants to timeout as well, and so it’s essential that you actually set these timeouts, but this is actually something that a lot of people don’t do so who are? Who actually, who actually write API servers or a rights web servers and go actually is checking this sort of context and setting timeouts? So what let’s? Let’s raise your hand? How many people are actually writing? Api servers are web servers and go just altogether, okay and then how many people are actually using context to check timeout? I thought Dave Cheney actually lowered his hand here.

So even Dave Cheney doesn’t even do this so, but one of the one of the actual you know you could imagine that this sort of thing is really powerful for things like client, libraries that make that connects to web servers and that sort of thing and connect To the cloud api’s or whatnot, and so one of the the libraries that actually makes kind of judicious use of the context package and make sure that it you can set timeouts and you can pass context properly, is the library from the go Club.

The Google cloud platform, the API libraries and go for Google cloud platform, so I’m going to kind of switch over here and have a Schilling talk a little bit about the about GCP and the client libraries and go. Do you have yeah yeah? My market is one all right. Alright, thanks again, for sharing is because using context is very important if you to API, otherwise you’re thousands of the routine three blocks back bogus clients or non-responsive servers.

So today I’m going to be shared. It be more about gold micro service support, whatever API app summer on the clouds. Of course, I work at Google and mr. Educator engineer, so I know other cloud provider provide relatively good go support and we do focus on Google ami all right when talking about goal. Supporting cloud, we really mean two things actually one: how do you graduate you? Have some clouds in this case, Pescador gave up gtp the otherwise how go is well supported the client API language on Google cloud.

I have prepared a short demo to show you how to use kubernetes thanks or Matthew from each ocean sharing credit. Is I’m going to shoot any reaction? How do you run the backing application according activity on creditors? Parent, so good, as you know, is the red wine. Doesn’t run everywhere if I have to compare comp, our people have only runs everywhere, yeah some even see I don’t know so in somebody.

Google’s Google out ad support many many ways: gramma collapses. As you know, so Google cloud offers fresh machine. Obviously, obviously you can compile your go into binary and create a system D. In this query, whatever deploy to a virtual machine, your Vic would go right. Alternatively, you can run in users groups. You can create docker container mounted to Google Cloud instance group or to skills as a CPU resources.

You can monitor bike ups at the R and so forth. You can also run Google App Engine flags, which is a new feature. We just release general availability. You can create a darker version, top image and develop Google Cloud specify. How do you want to run your apps English? What kind of skill the last one we offer is I discovered in this cover needs, as you know, is open source distributed scheduler for proper containers.

So there are some good and bad about all this, so virtual machine is very simple, but it is ready to manage. Instance. Group is the slip slightly better, yet is still preparatory, and there you need step office to support that happen. Deflects, the full zero ops support and you can really scale to almost unlimited skill. As you probably know, snapchat ran from App Engine, but it still prefers if you prefer not to be locked in then community system of your best option available moon cloud in terms of API support.

I have to assure you golden is the first-class season of Google cloud client language. If you look at all the APS, we provide almost all the major products we have gola if you have to work. If we don’t it’s a very, very rare case that you can go to the HTTP API level by using your own do programming language, I just think some snippet for for that, for example, if you want to use Google Cloud storage, which is the Amazon s3 equivalent, You really need to get a context, then create new clients and refer to Bucky an object.

Then you define a Twitter, you start reading the object, the simple as that. If you want to write object, you just needs change here and changes to a new writer. Then you can start ready to. The object. Is the English few lines of code? You can start writing and reading from Google Cloud Storage. The other one example is the Google cloud BigTable. This is our managed HBase version right with this example.

You really can open the client a few lines of code and the do start scanning by prefix, and you can map the rows to a function and the iteration for the rows in the few lines as well. Another example of it is a store, so this I’m not going to go through the details but is seeming somewhat similar. You just need to create a client and start writing entities and you are good to go. The last line spanner 7, is our new distributed, strong, consistent new cinco database.

So vendor is known. Nothing spencey here you just create a client issue, SQL statement with binding a parameter to a certain value. You run it. You get results back and go in a few lines of code and all this code you can easily copy and paste or go and start running in next 10 seconds or so so here I have a short demo for you. I’r going to show you the code, then I’m going to show you how to use deploy this run incriminates.

How do you scale this application? So I have pre created a spanner table on Google Cloud is very simple, is running in Taiwan data center. I create this demo is for core banking application. Imagine you are doing a banking application supports a few transactions like open account. You put the money to the accounts, Debbie money from the account and transfer money from account a July zombie. That’s all I want to do today so have two tables like the comfortable.

It’s very very simple. I have the account number and balance and have transaction table which has what’s a setting ID and when did it happen, what this attraction is about and which the account involves the amount involved with this successful, not right, that’s really simple schema. You can actually look at the table and you can look at the article. You can see it’s created using standard sequel using Create table syntax.

Alright, then I have a pre created container engine. So, if you don’t know you want to create kubernetes cluster, you don’t have to spend five 10 hours or type of stage to do is just equal to Google Cloud and create cluster and special web. How much CPU, how much RAM we need. Then, in a few minutes you have a cluster than the on cloud. I have to have this container cluster created here, as you can see, have a made 36b CPU 135 gb of ram, so you just give up scale down easily.

I just frequent this for demo purpose. Looking at the code, oh okay, yeah, look at the code. I really I really have a transaction manager here and everything else is basically obviously wrapping code which can be available through GRDC running on the cloud. So I’m going to talk about the TR transaction manager. Ladies only so have a table. I have a few operations like open accounts, supported debits credits, get a trading account information and transfer, so I’m going to skip all the rest.

I’ve spent like one minute here explaining a spinner on the context: API 8 in there yeah contact a page here, yeah, that’s very important, so so it’s better doing through the transaction. You probably you’ve already know in closing JDBC just start and second setup commit the falls to whatever you do in commit in spinner you best operation together, you run it it’s all in all successful or fail. So we all manage my strategy for you.

So what I did here is really read it combatants of account one and we kind of read the balance of a country right then I add the balance to account and debit from one account one just negative yeah I can. I can make it bigger. Unfortunately, I think it’s the resolution issues, but I hope you can see it clearly. Sorry. So it’s very simple: it’s very simple to division body. You get balance of two accounts, add to the second account and do something about it and save it together.

So ever ever demo banking application as a standalone. I just want to run it here to show you works. Ok, ok! This is banking Co. I am going to open account. Eight eight eight, eight okay, open now open okay, I read it account how much money I have of course, zero right. I have already pre opened one account. Okay, I don’t have a one one: seven, three dollars a transfer to eight eight, eight, seven dollars: okay, a transfer successfully already a’muslim value is 7 right, at least one one, one, each one, six six, so you worked as a task right.

How do I run in cloud right now, so I have to go to the cloud console. I already have a machine running in cloud, so I’m going to attach it in there and show you how to deploy a cloud and how simple it is. Do we have Wi-Fi yes sure, so, I’m going to build and deploy for simplicity authority to have damage in the single shell script. I probably have to use the line work, what slope, but maybe later so I export a good path.

I basically compile the soft code right. I copy the docker file to the binary, folder and start building dirges in the docker field and their tag it and the cloud. I push you to Google Cloud as a one version of the of the code, so I’m going to build it. You finish you in second, because the code hasn’t been changed. Yet. Oh someone changed it. Okay, we will push into Google Cloud. This done. Okay, so in seconds I push this kota-kun cloud now I want to push to the kubernetes cluster.

I want to run five copy of the company’s rotation of the scheduling, at least if Michael, had ballet crashed after three days community of star one immediately mini seconds. So in kubernetes I really create a replication controller. So really really what does it? Do? You really say: okay, I’m a replication, solar disk sure I have a certain number of replicas running on the cloud. The number of radicals – five, the name of the replicas starting with banking RTC and had some labels there and, most importantly, the image image here – is actually the image I deployed at now.

So with this I can use overcooks it here to deploy the cloud yeah guess what is running by parties. Now, it’s not happy. I own around ten copies, because that we need a skill in the few minutes. In a few seconds you can see. 10 cops are running one still creating I’ll do again. You’ll see they’re all running you all wired behind load balancer. I have free creative equal to a bunch of takes like three minutes.

Okay, now I’m going to run the demo on untested listing out I’m going to use ten threats, a factors rent end transaction on a new server. Then I’m going to use finder stress, 100. Thousands of transactions, four beckons all right. That’s about a little bit close to 3,000 clip yet and with 3,000, keep us in, for we can handle 260 million per second per day, and that’s probably enough for China and you wan na spend find a dollar same amount on this.

Thank you very much. Oh. We don’t hold you back for lunch, but apparently I’m happy to wear happier to answer. We are yeah. Let’s just go too much. Yes,


Online Marketing

Hitchhikers Guide to Web Standards

This is my first time using a clicker, so bear with me here. The talk is called Hitchhiker’s Guide to web standards and to kick things off, I’d like to introduce myself, my name is DOM fairly. No, yes, I’m named after the platform that we all know and love, I’m a senior at the University of Cincinnati in Ohio, and previously I’ve held internships at Microsoft and Mozilla working out in Firefox, and I’m going to be doing a final internship at Google in Japan.

Actually, working on chromium in the web platform, so currently I’m a chromium committer, which is basically fancy speak for someone who has write access and you can approve certain stuff and I’m also what working group standards editor. So if you don’t know what that last one is, that’s that’s primarily we’re going to be talking about. Today. I said from that you can follow me on Twitter and check out my work on github and feel free to email.

Me anytime. You know, during or after the talk, Dom a crummy org, there’s any questions about getting involved in the web platform at web standards and browsers stuff in general. So I want to talk about what this talk actually is. I kind of have three overarching goals that I wanted to reach when working on this talk and the first one is just provide a background in history and to web standards and some of the organizations that are responsible for their governance and their authorship.

This could really be an its own talk, but I know we didn’t come here for a history lesson, so I’m just going to give a brief, a brief history on this to kind of set the stage. Next I want to talk about. You know as a web developer, how can you actually make use of a web standard right? A lot of us go to mdn or Google some API and figure out how it works. But I kind of want to talk about the technical bits of web standards and show how you can make use of them and how to read them and how to navigate that space.

Finally, I want to talk about how you can get involved. I want to share a bit about my own story of getting involved with web standards and working on the web platform and hopefully encourage some of you to do the same so to kind of set the stage for the talk I’d like to propose. You know the idea that we need a definition of a standard. Now largely this depends on context. If we’re going to define you know a new word, and so I’d like to propose my own definition for the purposes of this talk, it’s a little bit wordy so bear with me a document specifying observable effects of technology with multiple independent implementations.

Now it’s kind of wordy, like I said so, let’s just focus on some key points right we care about the observable effects of technology. What are the side effects of it? How if I run something, what does it do, how does it look and feel? How can I actually use it, and, and does it change depending on you know where I’m where I’m using it from, and this last part is multiple independent implementations technology with multiple independent implementations? I think this is really important and it’s it’s far from a new concept.

In technology you know, we’ve seen this with like UNIX operating systems, for example, I can kind of make my own version of you know my own of Linux distribution. You can have your own Linux, distribution and, and you get one and you get one and everybody can have their own. You know separate distribution with sugar on top of it, but what I really care about as a desktop app developer. If I were one is you know, can I write an application that works once everywhere and no matter what operating system I’m using for you know, that’s in the UNIX family of os is that it’s going to work uniformly so to kind of make that environment conducive To that you know: interoperable behavior among the different operating systems we’ve had the set of plastic standards developed to kind of unify this observable behavior.

The same thing goes for web tech, and this is primarily what I’m going to talk about today. Those these are not actually to scale, though, but I happen to know for a fact that you can’t go to the store and you buy one HTTP. You know it’s a protocol, it’s just it’s just an idea and it’s something that you can implement to kind of make it compatible with other versions of this. This protocol and the same basically goes for JavaScript as well right.

We can run JavaScript in a bunch of different places, unlike maybe Python, it’s kind of like we have one Python. We get from the Python people and that’s kind of it, but with JavaScript I can run it in chrome. I can run it in an edge on the chakra engine and I can run it a node in all kinds of different places and the same goes for kind of the star of the talk today, which is the web platform API.

So I’ve gone through a career change, I’m now no longer a UNIX app developer, but I’m a web developer. And so I need to know that the same api’s that exists in chrome also we’re going to be there in Firefox and, more importantly, that they’re all going to work the same and kind of function uniformly. That’s really important, probably the biggest thing I learned when making this slide is, though, that keynote is really cool and has a bunch of different goofy symbols that you can use.

So I thought that that little dude look like a face, so I dressed him up getting some underwear and a hat and stuff like that. So let’s talk about where web api’s come from right. This is important. We are. We are web developers and we kind of want know where the stuff comes from and how we can make more of them. I personally think the logical answer probably is JavaScript right. We use Web API when we’re using JavaScript.

For example, here’s a snapshot of the chrome dev tools and when I’m you know right, I can write things like a for loop and a while loop, but I can also fetch you know super prominent websites on the internet like that one and I can use set Timeout and all kinds of stuff like that, so it stands the reason that this kind of stuff is part of the language. Now we have to talk about what is the language or what does JavaScript I’m just going to fly through this slide, because we all know the big story of Brendan Eich and he created it in 10 days and whatever, but it’s just a general-purpose programming language.

That is created for the purposes of the web. I was plopped into netscape 2.0 and that made it a really interesting thing. It made it a candidate for Standardization because there was going to be multiple independent implementations of it, and so we needed some group that could come by and pick up. The task of standardizing and Ekman did this. They stand for the European computer Manufacturers Association and they created ACMA script and we’ve had some success with this with the various engines.

For example, there’s a bunch of different implementations of the same sort of technology, and you probably have seen this list or something similar to it before the standard looks something like this. It’s really big, it’s really hard to read, but it’s on github and it’s hosted under the tc39 s. Github page tc39 just stands for technical committee 39. So when we’re writing the standard writing atma script, how does it work right? What are we going to put in the standard we’re making a new language, so we have to make them make it really general.

So we need a really strict separation of concerns between all the contents in the standards in the standard. We just need to be dealing with the language syntax in the semantics and then some of the constructs and the primitives and that’s the true scripting language. It should be able to be plopped into any host environment, but the language itself shouldn’t actually have to know anything explicit about that environment.

Now we’re really used to using that language in a web browser, so we’re used to web api’s and stuff like that, but the language itself doesn’t actually know about those things. So web apos are not part of the ACMA script language or the jour JavaScript language they’re. Effectively, mix-ins and they’re baked into browsers and browsers, can support, basically, a version of echo script as their JavaScript engine and a bunch of web api is that we can use that kind of tag along alongside this version.

Rackham script, that kind of interplay with it, and so we have hakama right there responsible for and tc39 are responsible for standardizing ACMA script and javascript that we all know and love so who’s responsible for standardizing the web api. So we’ve kind of heard a little bit about this today from some of the talks. There’s two big groups right now that are responsible for this primarily you’ve, probably seen at least one of these logos before we have the w3c and the what working group and the what working group denoted by the question mark on the right is what I’m going to Be talking about primarily today, this is the organization.

I told you all that I was a part of at the beginning. So the what working group stands, it’s just an acronym. Unfortunately, so it stands for a long string of text that kind of summarizes what we do. It was formed in 2004 after a w3c workshop. Basically, they decided to kind of branch off from the w3c and create their own canonical standards that specified the web platform. So they have an HTML standard, which kind of defines HTML language and the parser and the event loop and a lot of the it’s.

Basically, the kitchen sink of the web platform is actually what it calls itself to, and they have. You know they specified the Dom API is the interface that we use to talk to the web and and some networking primitives like fetch and streams, and a lot of really cool things like notifications and primitives. But how are these things actually written right if we’re going to write a browser and we want to write ACMA script? You know we start with the JavaScript engine.

Okay. Now, if we read the ACMA scripts back, there’s a lot of stuff in there, but there’s also a bunch of exposed objects that would get for free and JavaScript. We get things like the array, constructor and you know date, objects and week, maps and all kinds of data structures that are natively exposed through ACMA scripts, but we want our browser to be a little more powerful. You know we want it to have me the Dom.

So we give it, you know a document object. We can add a couple more paragraphs onto the end and give it a query. Selector method and we’ve kind of extended our language a little bit more, the documents getting bigger, but it’s getting more powerful. So we also would love to to you know, contact the network as well, so we’ll give it some networking primitives things like fetch things like request and it’d, be really cool.

If we could do ourselves a good service and debug our code, so we’ll maybe give it a console object as well a bunch of methods. On top of that, this is one way to write. It just keep appending text onto the same to the same massive documents, but it’s going to get pretty lengthy and unmaintainable. So the what working group maintains separate standards for each of these kind of ideas that have a separation of concerns and each standard is responsible for talking about how they enter leave with the other specifications and the web as well as that can script and things like That and as a result, we get web api is alongside ACMA script and java script.

Now, if we want to read these web api’s as web developers as web developers, we want to make use of them. We need to kind of know the anatomy of a standard. We need to know what is actually in these documents, because it’s kind of a mystical thing in mystical process and and it’s actually really – you know not too difficult to get involved and it’s it’s all very open and happening right under right under our noses.

So I was thinking about this a lot for this talk, and I kind of came to the conclusion that there are two big parts of standards to kind of be aware of. The first is algorithms, so I don’t know about you guys. I love algorithms spend many. An evening as it were working on leet code and hacker ranked stuff – and I really like algorithms and data structures stuff, I think that kind of theory of computation is really really cool.

Algorithms are really just a set of steps to perform a task. So let’s go ahead and take a look at an algorithm inside a web standard right. We have the console standard and there’s a bunch of different methods on there. If you haven’t heard of it, there’s one called console dot count and here’s the algorithm specified in the standard. There’s five steps that run every time you invoke console dot, count, there’s a couple that we really care about.

For the purposes of this talk, though, you can see we’re given something called a label, and basically the idea of this algorithm is, if we’ve seen this label before, when we’ve called this in this function, then you know increment some number that we have that we have Associated with label, otherwise we can set it to one. This is the algorithm and then eventually we want to just print it to the screen.

This logger thing is just abstract text for saying, hey browser, you know show this to the user in whatever way you see fit. This is nice because I kiss a web developer. I could come in here check out the algorithm and it answers a couple questions for me. Like you know, what is the initial value of the number that is associated with a label and what happens every time? I call it and what can I expect, and so we can read the algorithm and kind of understand what’s going on now.

The second important thing about specifying and using web api is understanding the look in the so I think that’s really important. What’s it mean for an API to have a look and feel so I thought of this, and I think it’s kind of like you know: what’s it mean to to use the API as a developer? What’s it called? Where is it hanging off of some other object? Is it just globally exposed? Does it take anything? These are you know a bunch of parameters? How many parameters does it return? Anything? This stuff is really important for us to know, and a lot of us here are used to going to mdn and then maybe googling.

This kind of stuff to find it, but I also want to show that you can just go to the standard. So here’s another part of the console standard that the what working group maintains it’s a big scary block of text. But let’s focus on the bit. That’s complementary to what we were talking about before the count method, so we have this right. This kind of can tell you a little bit about it right, okay, so it’s called count.

It exists under the console, namespace, so console that count that kind of make sense. How I would use it it’s of type void, so I probably shouldn’t expect to get anything from it, just not going to really return anything, but I might do stuff and it takes in a single parameter called label it’s optional and its type is Dom string. So we don’t know what Dom string is right now, but let’s just assume it’s just a regular string.

That gives us some some cool information. It’s pretty expressive, but it’s not JavaScript, because we care about types and and it’s not C++, because we see other invalid things going on around here. So what exactly is this language? It’s called web IDL in a sense for web interface. Definition, language and you’ll see it in a lot of specifications and it kind of forms a contract for this. Basically, the signature of web api is that you use and that contract protects the algorithm, because when I go into the algorithm and I’m running these steps, I want to be able to know what label is I need to you know, maybe I’m making some assumptions that It’s a string and I’m operating it on on that accordingly, and that’s really important for me to know – and so I want to talk about how web IDL actually works in practice.

Okay, so you’re a while ejs dev, you got your Viking hat on and you really care about types right, so you’re going to call you’re going to mash in your keyboard and called console count and you’re going to just give it whatever you want. You can give it a symbol right, you can give it an object, seeing it whatever, but the second you do that the web IDL Sheriff is going to stick in it’s going to come in and it’s basically going to be like hold up.

Hold up, hold up. Hold up, you called console dot count and you could give it whatever you want right symbol if you wanted to be so inclined to do so, you give it a number whatever, but I’m going to make sure that you know this contract is obeyed, I’m expecting a Dom string and I’m going to make sure that whatever you give me can pass as a Dom string and if it does that’s cool, we go to the algorithm, continue with a hopefully successful call and and keep going, but just like a sheriff can throw someone in Jail, the web, buddy el sheriff so to speak, can throw a type error, resulting you in with you in code jail, it’s probably the worst place to be right, you’re staring at the terminal or sorry the dev tools, and you got all this red scary text around You don’t know what’s going on, so we want to stay away from that now.

Real sheriffs in the real world know who to arrest who not to arrest stuff like that. That’s that’s really important something part of their job, so they kind of basically have a rule book of things to follow here and just like they’re the real sheriffs of a rule book the web, IDL sheriff has a rule book in the form of the web. Idl standard and it basically defines a lot of the stuff that that it’s supposed to be enforcing, so we saw an example of conversion.

Here’s a snippet from the web IDL standard that basically is responsible for converting a Tekamah script value to what is called a Dom string, something that the web IDL has defined. Basically, the meat of this algorithm is just to kind of delegate to step two and call this two string thing. This is an abstract operation defined in the ACMA script standard, so we’re just kind of passing through right to the ActionScript spec, and we could of course, write to string everywhere we needed to instead of using web IDL but yeah.

This is really nice, because it’s pretty expressive, it tells us tells us how things should work in a really normative clear way, and if your techs are algorithms, when I get to here, I can know that I’m working on a string and that things have been accepted And the sheriff is okay with it. So why are we using this thing called web IDL anyways right? What exactly is it? So it’s it’s just an abstraction of arachno script text, as you saw all step two was we just kind of delegate to the echo script standard? It’s two string thing.

It does a lot of things for us, so it helps us write a lot with just a few words. Potentially, it takes care of a lot of like type conversions. We saw a really simple example of a type conversion, but you can imagine, perhaps potentially a much more complicated one and we would want to repeat all those steps to you know. It’s convert things and then kind of make our assumptions everywhere, where you need it to.

In the spec, so we can use web be able to kind of just abstract that stuff away. It also takes care of things like property initialization for us and other stuff, like that. It also helps us define where our interfaces are exposed in a really expressive way. It like we like we saw, but I think the most important thing about web IDL personally, is that you don’t actually have to use it. It’s as line1 suggests just an abstraction over action scripts over the ACMA script text and that’s really important, because we have some standards that are written without web IDL and that’s totally valid.

It just kind of speaks within the same language of the echo script. A standard space in that uses the same verbage and the same sort of stuff, but web by DL is just a nice way to be succinct and kind of foster interoperability on the platform, so you can always feel free to you know, hopefully that that little foray Into web by DL makes you a little bit more comfortable reading some of the standards that they that they come with in.

So. Finally, I want to talk about how I got involved in this and how and how you can do the same and hopefully motivate you to do the same as well. So who knows this logo? Let’s it raise show of hands right, hey a lot of people cool, so this is the angular logo, this flat designer believe this is new since angular 2 and basically, a couple years ago, I was like yeah, I’m going to start like giving more stuff with web Applications so I better learn a big heavy framework that can bog me down and figure out how to write all this stuff, and so angular 2 at the time was an alpha.

There’s a basically mess right. Things were always moving around and I would always hear people say yeah, you know, angular angular is getting uh, you know a new, router or angular is getting a new object or new this kind of stuff, and it was really easy to track the progress of this. It was happening on github. I knew some of the people working on it, so you could always just kind of dig around. At the same time, I heard another camp of people kind of talking about JavaScript there they were saying you know, hey javascript is getting.

You know async iterators or you know, did you know about custom elements? Can you figure out how to use this, and I was like? Well, that’s interesting, cuz! That’s not really angular specific, so I was really interested in digging around figuring out who’s deciding this stuff because, like like, how does this work? I want kind of wan na be a part of it seems pretty cool we’re evolving the platform.

So eventually it came across this guy’s profile. His name is Dominic Nicola and I just learned recently that he was actually a speaker at the first Cascadia j/s in 2012. It’s true that we both have the same name, that’s pretty cool, and so I reached out to him. I was like hey. I see you, you know you’re working on, you know the what working groups bit standards and all a lot of stuff like that big contributor to the tc39 proposals, and so I had reached out.

I was like hey. What do you do really, and how can I do it? It seems kind of cool. Are you actually paid to work on this stuff? It’s it’s pretty cool, and so he was basically like hey. You know. We both have the same name, we’re both Dom’s right and then working on the platform. So I’ll. Let you in on some secrets and the biggest the biggest piece of advice here, is probably to dig around on some of the what working group standards and actually just take a look at some issues.

There’s a lot of issue labels that the issues are kind of fixed if one of them is good first issue and basically, as the name implies, they are good first issues for people to get involved in and a lot of them are low-hanging fruit or some of Them are editorial in nature that you can just kind of go in and dig around in a web standard and figure out how to work with them. I want to cut away, though, from keynote and probably screw a lot of things that up in the process, but let’s see if I can just show what the what working groups page looks like hey.

Do we have it? Yes, okay. Now, if I can figure out where my mouse is, I would also be cool one. Second, all right cool. So so here’s here’s the what working groups github page, basically just to kind of show you you know it’s all open. It’s all happening right in front of you and it’s a very welcoming area you’re allowed inside. Basically, this is this was basically just a list of all the specifications that we maintains giant list of the HTML standard, the fetch standard and stuff like that, and so we can always just go to the one of these repositories and see what’s inside right.

There must be some sort of source code that the standard is you know existent and that it’s written in and a lot of times. This will take form in a take in the form of a BS file. So bs does not stand for we’re. Actually, very serious people here we’re working on standards right we’re on the platform so bs, since our bike shed and it’s basically this language that we kind of mix in with with HTML and pre process.

Before we build a standard kind of helps us with cross-linking and some other fancy things, it’s pretty easy to get the hang of. We could check out the source they’re, all the standards exist at spec or you know something dot, spec org and basically they look like this they’re, the ones with the green logos that the browser is actually trust, and so we go in yeah. We can check out the standard, all kinds of stuff like that and, more importantly, if you’re looking to get involved, you can go under the issues section here and we have a bunch of different labels that we use.

That’s not where I’d want to go so yeah. If we want to check out these issues, this, for example, this is the fetch standard. Where things like the fetch, your method exist and the request, object and stuff. We could go in and try to find the good first issues. You’re like oh yeah. This is really cool right. I can, I can dig around here and maybe help out on some issues, and so now we’re kind of on to evolving the web platform right.

We’re working with a standards body to help fix some of the problems that they’ve identified and the platform is so. This kind of this kind of goes back to interfacing with the community and the community groups online. So I want to talk a little bit about this when dealing with the what working group there’s a bunch of different ways to communicate with us we’re always on get up. Of course you can.

You know chime in on an issue and be like hey. I really want to work on this. This this looks really cool. I think it’s interesting. We’re always super super happy to provide mentoring, mentorship for people that are looking to get involved, also we’re on the really big bad scary place that is IRC we’re in the free. No under free node on the web working group blog, I’m always logged in a lot of us a lot of the others always logged in so always available to you also help with questions and stuff like that.

There’s a lot of information here that have thrown at you and things like that and at the very end of the presentation, I’ll kind of give you with a well one web page that you can go to kind of get a lot of this stuff from. But I want to talk about why to do this. Anyways right, there’s a lot of cool ways to read it, to learn reasons to learn angular until I react and to work on the web, but I think what’s really cool is, is you know? I know we’re in Seattle and Microsoft land basically, but if you have a problem with some Windows api’s, basically you kind of have to work in Microsoft to get them fixed or changed, or do something like that.

But what the web platform all this stuff is happening. Right in front of your face: it’s all in github, it’s all free to participate, and you know anybody. Anybody can do it and just go on and start working on stuff, and I think that’s really really. Cool web developers are in a really unique position of being able to influence and modify the platform that we all develop on every single day and that’s really exciting.

To me, and one of the reasons that I got involved, so I want to leave you with a repository that I just kind of started the other day. Now is the time to take pictures of the slides if you’re interested in getting involved. There’s a lot of information, there’s a lot more information beyond just what I’ve covered in this talk so check out the Cascadia j/s repository that I maintain on github. It’s just kind of got some getting started information and so the links to other talks that people have done on similar stuff and how to get involved in the web community and modify web standards and stuff like that.

Finally, I want to leave you with some of the things that I’ve worked on to hopefully, hopefully provide some motivation to show that you guys that you all can do the same. Recently. I’ve changed helfet works. The fetch API. I’ve worked on Chrome to basically modify when we said credential when we send credentials when we make a request stuff like that. Basically did the same for for module scripts and took part in some of the standardization work for there.

So that required, of course, talking to a bunch of the browsers and saying hey, you know we’re thinking about making this change. It kind of makes sense. What do you guys think and can I do it? I also standardized and implemented the referrer policy attribute. This is security, even private security privacy attribute and HTML. So I did this on the script Elementary simply so I like resource loading and then security privacy kind of stuff.

I’ve also implemented a bunch of console API eyes, so the console standard I mentioned is a really really good one to start getting involved with. So I encourage you to check it out. It’s what I started with and I also started working on Chrome partially. As a result of that, finally, I’ve been working on something called priority hints, which is just a new resource living API. That kind of lets developers tell the browser what priority they would like to be associated with a request.

It’s a new standard and so we’re digging through that I did the implementation work in Chrome and so we’re just kind of doing some experimentation to see if it’s going to be able to pull its own weight, but other than that. I hope I’ve left you with a good taste in your mouth and when it comes to web standards – and I hope that you all you know, feel motivated to get involved and contribute back to the platform thanks a lot.

That’s it