Let's just get started. Welcome to this afternoon's session. I'd like to start this talk by by a simple greetings from our language. Como está? Say it with me. Como está? How are you? So it means in my language, it means how are you? So at least I'll tell you more about myself later or where I'm from. So we're enjoying the work come so far and we appreciate you guys. Thank you for joining us on this event today. So before anything else, I'd like to introduce myself. My name is, my name is Doreb. I am a senior web engineer at a fully distributed company called TenUp. I also help out, I also help out organize speed ups in my hometown in Davao. As we also have like growing WordPress community groups in there. And I'm also trying to support the WordPress user groups in the Philippines. And also I've been partly involved with the global community team of the open source WordPress project. This afternoon, okay, wait, are you ready? So this afternoon I'd like to talk about a very important process in our workflow. That is, that is aside from sleeping. Also, right, sometimes you deploy code. So I'd like to talk about a very important process in our workflow and should be for everyone when shipping and launching secured, clean and perform at WordPress power sites. And this process is called, you guessed it, it's code review. You would probably start asking now, what is the code review and why should you care about code review process? Let's simply look at it this way. Building a WordPress site may run smoothly on a few visits. But what if you have a site or what if you are building a site for enterprise level of sites or sites that gets thousands or millions of visits a day? Maybe sites like CNN or New York Times or TechCrunch or even Vogue, you can name. So this type of sites don't, they cannot afford to go down even for a few seconds. So how are we making sure as their partner in delivering the best experience to their readers that you and other engineers or developers working on a project have written code that can scale and are ready for high traffic situations. That is what code review comes in. And that is the end goal of why it is very important to have a code review process in place before you ship or deploy code. Mario Pesche, CEO of Demerix, it is also an agency that's similar to TANN that builds and maintains large scale WordPress platforms. He made a statement that what makes a $500 project different from a $20,000 code quality? When I read it, I could not agree more to it. I could not agree more to his statement because being a partner to your client, that would mean that we would have to go extra miles to make sure that their business stays online and running, which actually we need extra time and effort and resources as needed. There is no better way to make sure than to check each other's work, okay? But still, why do you code review? And what are you code reviewing on? So there are a couple of factors that you take into consideration when or every time you send your code into your live site. You can't, there are certain cases when you overlook certain pieces of your code to go against these factors. And that's perfectly normal. Like we are human too and we make mistakes, right? So code review is meant to be your backup and allows us to less likely, if not at all, chip unwanted code. So let's start first for security. You code review because you would want to make sure your code is secured. It is very essential to keep the web safe since the web is free. Just like how free it is to everyone, some people are also free to use web for their evil doings. We have some preventive measures on your site. These type of sites would be the easy prey for these hackers and their nefarious activities. As a way to, for example, verify that each new code that you push to your site would it cost or doesn't put your site at risk? You would want to check if data are sanitized, output or escape, data gets validated correctly, nonces are in place, and you pay extra attention to areas where you could possibly do SQL injections. Oh wait, actually, I just gave you the whole summary of what to look for when you think about security. Okay, so let me back up and let's start with sanitizing and speaking your data. That's the first item there. So during your review, you would check if inputs, these are the data that you take in from the users, they should be sanitized and outputs, these are all the data that you would display back to the browser or to your client browser, they should all escape. WordPress provides a number of APIs. Depends on the type of data that you are trying to sanitize or escape, such as sanitize text field for your regular text field needs and sanitize email for email. While we have my very favorite one, escape HTML for generally removing extra special characters from a string before you display it to the browser. And you have escape URL in the escape section, you have escape URL that you can use to sort of escape whatever unnecessary characters that you would expect to have in that URL string. During code review, during code review, I would also flag code that I haven't validated. In cases where, for example, we need to call, we gotta make sure that the data that we supply to the WPMAid call is actually indeed an email. So WordPress has this function is underscore email that you can use to validate that. Use it, then done. The good old PHP, such as in the list below, the good old PHP has a number of validation functions too, such as ESET, MT, in array or cap. We are not in short supply of these validation helpers, so feel free to use them. As a rule of thumb, it is very much preferable to over validate than to under validate. So move on to the next. Okay, so I see a form or an action that would allow a user to process a certain piece of code that you are introducing. Well, I would go straight into looking what would be the necessary requirements to allow them to process the action. My friend, if you don't have a nonce in there, I would not let that code deploy because nonce would basically be a security guard in order for something to pass you, then you have to have something that would allow you the request. So in the WordPress language, I'm not sure if you can see that clearly, but in the WordPress language, you use WP nonce field or WP create nonce. So I'll go back here. So that's the WP nonce field and the WP create nonce. So these are the API that you can use that will generate a token. And then the other one is WP verify nonce. That is the API, or that is what you can use to verify the token. That generated from the two API above. So in my example here, I'm not sure if you can see this. So it's not readable enough, sorry guys, but. So for example, the above example is an unsafe way of like processing something which doesn't have like a checkpoint. And then here I've highlighted in red, there is a WP verifying nonce. So meaning, if you don't get the token or the pass, then the whole thing here, so the whole thing is gonna be skipped. So you don't allow this right here to be processed. It feels here. So I call this area here, the security guard. So if you don't have the token, if you don't have the pass, then you have no right to pass, to go or to enter, right? So that would be an extra layer of security in your code. And lastly, we pay extra attention to when things get into our database. So WPDB prepare would be a very useful matter when there's a need to run a custom database query. And yes, so I, screenshot, okay, go ahead. One, two, three, four, five, okay, good. But don't worry. So info about security, data sanitization and escaping and validation. And they are very much available in WordPress.org, theme security handbook. It says theme there, but this also applies to plugin development. So I'll give you the link later as well as the slide, the copy of the slide. Next, performance. You code your view because you care about performance. So you code your view because you would want to make sure your code is designed with performance in mind. Is your code optimized enough to endure and could scale when your site hits the busiest time of the day? If not, I would take a step back and fly out the affected code. I would start checking if you are using any un-cached functions or requesting un-cached queries. Keep an eye for these several functions. Get posts, term exists, get page by title, and especially the last one, current user posts, as I've experienced that firsthand how it could really hurt your site. If you spot them in the code, these functions should not go un-cached. So if you really need to use them, make sure you cache them in your code. So the next request, it would just pull the copy from the cache. All right, so, I hope you can see this one. How do you know, how do you know they are cached? Well, if you spec the source code of the API, you can see that, for example, the get page by title is running a database query that git underscore bar, git underscore bar is basically going to run a SQL command. So meaning that whenever you get page by title, it's going to request directly to your database. And that is not scalable, my friend. So another thing to look is if you're running more queries than what you need for. In case of a new WP query instance, bypassing some queries, such as sending no found rows to true, yeah, no found rows to true, that would skip the queries that basically run to calculate the pagination. And setting the update post meta cache and update post turn cache to false would basically skip priming the cache of the term and the meta of a certain post. Those themes, although they look small, but they would go a long way when it comes to thinking about the performance of your site. And yep, I wouldn't let you get away with that request from a third party API without a cache in place. Certainly not under my watch. And lastly, so where we've gone through the security of readability. The code review because you would want to make sure that code is formatted in a way that engineers and developers would able to understand it. And engineers that will inherit a project would be able to carry on without much friction. Making it developer friendly as we is making you're basically for the use of space over tabs or not keeping your markup balance with PHP blocks. Okay, I know you feel me too when I say that who would want to work on with a code page like this? Okay, I can create a crazy number of hours for me to read that. What if you have very much documented, right? So this is the good thing about the core is because this is an example from core, so. So that feeling when you have this kind of existing project, and it's so easy to understand. Rather than this project, it will take me a day just to maybe understand a few lines of code. This one, okay, sorry, this is really small, but this one right here are comments of the API and then some arguments down below, but they are structured and formatted in a way that's very readable from a developer's perspective. Thankfully we have many generous people from the community who put together coding standards that we can all agree on. This is our own version of a Pixel Perfect code base. So imagine if we don't have coding standard in place in WordPress, it's likely that people would contribute more in core. So, how do you code review? I mean, what can you use and in what ways? So there's two ways in how we can do code review. The first one, automatic, as in one T and manual with other tools, PHP code sniffer is very popular out there for automating this process. PHP code sniffer, so anyone familiar with PHP code sniffer? We help detect violation of a defined set of coding standards and good news, there's even a collection of PHP code sniffer standards for WordPress. So you can download and read the doc in GitHub repo and it's open source, as always. So yeah, I'll give you the link as well later. A trend you can see, but it's just WordPress coding standards. WordPress coding standards, if you search that, Google will lead you the way. So when running PHP code sniffer with WordPress standard, okay, I'm gonna run this, this is a video. All right, so this is an example. So when running PHP code sniffer with WordPress standards, it scans the code, cache common security issues like missing input sanitization, output escaping, missing nonce checkpoints, et cetera. And actually, even validating that everything's well documented, for example, you miss use tags or you miss a couple of tags. So in the example I see here, there are issues like expected one space before closing a bracket. So it's also some sort of formatting issues. So processing form data without nonce verification and there's the line, as you see to the left, far left of that, there's the line of the code. So you can inspect and go and find a file and do the desired changes. Okay, you can also leverage continuous integrations or known as CI that could run PHP code sniffer in the background or any custom script or however you are connected it, so long as it allows you to automate the process of code reviewing. WP enforcer uses PHP code sniffer too, but it's more of like a plug-in. Another way is manual review, but most of the time you would want an automatic plus manual combo code review set up because in that way that would be very, very effective. So there are tools that would allow you to conveniently code review or review the code changes such as we have GitHub, we have GitLab, Bitstock and Bitbucket, who have used this or have been using GitLab, GitHub, Bitbucket. What are other tools you're using in your workflow or in code reviewing if you guys have already used? GitLab, okay, perfect. We also use GitLab, okay. High five. Okay, so for instance, it has this very beautiful UI and it allows you to comment on the line of code wherein you can provide feedback or even suggest a better way that's more in line with the voice of code review. For example, I spot a user input and then you process that and then store it in database. But you didn't have any standardization in place. Then I would point the, for example, I would point the line of code, then there would be a pop up on that that will allow you to drop comments. I'm not sure if you can see it here, no. That review is also known as peer code reviewing as it goes in two ways. Review code that either, number two, when your team and the best thing is your master's. There is no better and fastest way to grow than to learn from your past mistakes and you'll learn and you'll have tons of experience about this in the code review phase. And of course, you can definitely do self-review as well. And if you're using Git, I know a lot of speakers are talking about Git and I hope Git, which I think the case, that would make it even more easier for you to self-code review. So we have source tree, I use source tree, I have source tree too in my working machine, as well as GitHub for desktop. Or you can install a deep purifier if you're using sublambtext editor. So even in our WordPress ecosystem, code review plays a very vital role in keeping us safe and healthy platform for everyone. Worker standards, what process goes into reviewing at the end, if you did, there will be a replay at the WordPress.tv. So as standards philosophy goes, we should not take shortcuts that compromise the end experience for the user. That being said, we have to make sure we review our code and that we follow as an engineer on the site, we follow the WordPress coding standards and the engineering best practices that the community have helped curate over the years. So here, the TANAP has an engineering best practices and we always check the code against these practices and make sure that the new changes follows whatever is in here along with the WordPress coding standards. We are well on our way to dominate the web. Actually, we are 33% of what you see in the internet. Let's help build web to be a better place to making sure we ship well engineered code and doing that is to make code review part of your engineer's DNA or developer DNA or better yet, our team culture. Thank you very much.


Now on stage here, using the InfoChimp State BI, it's just gonna be a data-driven app that just kinda shows you how to use the InfoChimp State BI and how to use APIs and do cool things with them. And we're gonna do it in Rails. I wanna show you what the app is called at the end. We're gonna build something like this, and it doesn't look like much right now, but this is actually really cool. We've got a list of users over here, and we can sort by count and wait. This is a list of a network, a network, that's something that currently can't do on Twitter very easily. Oops, didn't have my control key. Okay, so, so a little bit about me. I'm a product manager at InfoChimp's. I started on Rails 0.9, actually I think 0.8, but my first app was 0.9. Then I got sucked away from that, and I started doing enterprise-y stuff. I worked for a bunch of big, scary, evil companies that made me a lot of money, so now I can actually go back to the startup world, and now I'm back in the Ruby world, working with InfoChimp's. We are a data marketplace with InfoChimp's. I'm a product manager. I'm also the dev evangelist. I also do a lot of code, so I do a lot of Ruby coding, but I'm not necessarily our best co-owner at any means. One other thing, yeah, I worked, I did enterprise content management, so things like interwoven, SharePoint, and then you have content management, document, so Drupal, because we're related to Drupal at least. It's like an open source one on Fresco, maybe. So that's pretty cool. They made it funny, and now I'm back in InfoChimp's. A little bit about us. We're at the amazon.com for data. We are a data marketplace. Anyone can buy and sell data online through our website. That doesn't matter how big or how small we happen to do with a lot of big data, but we also have a lot of small data as well. We also do really cool things with huge data, such as Twitter data, MySpace, and we also have an API, or sorry, IP census. The Twitter data is just a collection of tweets that we've collected since 2006, and when we're talking about big data, we're talking terabyte scale, so this isn't something that you deal with on your laptop. This is like cluster computing, that sort of thing. So anyone familiar with cluster computing? You guys do that? A couple of people. So to give you an idea of what kind of shop we are, these are some of the technologies we use, and you'll notice a lot of them are very Ruby based. We use Rails and MySQL for InfoChimp support, and all these other things for all our other stuff. So not sure we've got like a few small apps. A lot of the stuff on here that you probably don't recognize is you, Pig, Chef, Cassandra, Flamingo, Tokyo, Tyrant, Bukong, these are for big data compute. We use Amazon EC2 for our API. It's a little bit scalable. Rack is the front end for that. Our two co-founders are like really technical guys, so that's why we have so many Ruby things. We're like a completely Ruby shop. We don't have any Java or anything at all. Like it's 100% Ruby. The only thing that's really not Ruby that we coded is Pig, which is like SQL for big, giant data, and it's just as ugly as SQL. Okay, so here's a picture of what we're gonna build today. So this is what is really cool because we have, my time down, we've got, right now you can only, most apps, you can only view the Twitter space with a very finite area, right? Like it's very user-centric. Like you can view that user and that user's network, and you can view that user's content. So like their tweets, their friends, blah, blah, blah. You can't really expand out of that well, and you can't examine it very well. And the Appertrims API allows you to do that because you've done the huge data compute on this stuff. So right now, like the brown circle and the blue circle is like all you can view. Appertrims has expanded it to be like the green and outward. So what we're actually going to build is something to do with our API called strong links. And strong links shows the interactions between users and how strong those are. So if you query strong links, it will tell you the top 100 people you interact with most on Twitter. And I'll show you the API call for that right here. And this is, you can actually do the API calls to get requests from the browser. I don't know if you guys can read that if you can't. Just go to api.infochamps.com and it will tell you how. These are, actually you can't do it very well there. So this is the entire string that you get back. So I query on username.infochamps and it's returning the user IDs and the weight of that link. And what the weight is representative of is replies, retweets, and mentions. So this actually tells you just how interactive you've been with the ex-user. So like the first user, you know, this is going to be your most interactive user. Last user is going to be the least active. You see like 0.5 link here. Does that make sense? Okay, so we're going to build the app. So the reason this is so cool is because you can examine outside of your network. So say you're following all these people, right? And they're your strongest link. So these brown circles represent your strong links. They might also follow some other people that you might be interested in. So like the screen guy on the left here, he's just like one friend of one friend. So like he's a friend of a friend. You might want to know him, he's kind of important, but I don't really care. This other dude over here though, he's connected to five of your friends. So he's a friend of five friends. So this is significant because he's not just a friend of five friends, but he's a friend of five strong links. So these are the people that you interact with most and then the people that he interacts with most. And this is like really cool because you probably want to know this guy. He's someone you should probably follow because he's probably either really interesting or like really close to your circle of friends. So we're going to find him. So what we're going to do is, and this is really high level, we're going to loop through your user's all 10 strong links. If the query call returns 100 of them, we're only going to go through 10 because 100 strong links times 100 strong links, that's like two hops out of your network is 10,000 and that's a lot of API calls. So we're only going to do 10 out of 10, which is 100. We're going to count number of times that user shows up and this is cool because that's the number of times that it's a friend of a friend. So if he shows up one time, he's a friend of one friend. If he shows up 10 times, he's a friend of 10 friends. We're also going to, and it's not just a friend, but because it's strong links, he's like the strong link of a friend. So he's the one that they interact with most. We're going to find the total weight and this is how much interaction they've had. So retreats again, replies and mentions and we're going to find all their trust ranks. This is another metric that InfoChimp puts out to the API and it's based on Google PageRank. Are you guys familiar with Google PageRank? Yes? Okay. It's a really awesome algorithm for measuring the global importance of pages. So like Google and Facebook have like PageRank nine or 10 and everybody else doesn't have a good PageRank. But this is to measure overall influence in the Twitterverse. So for example, Mashable has like a huge PageRank or Lady Gaga would have a huge PageRank and I have like a PageRank one, something. And then we're going to sort them by using SQL and that's going to be really cool because it's not SQL and you don't have to do sort in your Ruby app. Okay, so I'm going to go ahead and build it. If you guys want to follow along, here's the GitHub URL. You can also find an API here to use to demo here. If you just want to play around with the InfoChimp's API. And you can also check out my tag as I'm going along because I'm just going to code. I'm going to check out my tag too. It's just the command is get check out and then the tag name, their progress dash, whatever. Okay. You guys are ready to build. Let's go. Okay, so we got to start our app. We're going to just do, so the dependencies are going to be Cedar Gem install. We've got chimps, which is the InfoChimp's library that you guys can use for any Ruby app. You need Rails if you don't have already have it. And friendly ID. And I'm actually not going to install this because I already have them. So I'm going to make a Rails app called SpringLynx L-S-R-C. And I also need a single controller. And we're going to have one view called show. Oops. Oh, I guess I need to see it there. We've got it. And it says J, I guess. This is like, this is TexMake before TexMake existed. You can see I practiced it a few times. Okay, so I've got all my files in my file tree here. So I'm going to go through how to set up an environment for your Rails app if you wanted to do the InfoChimp API. First, we're going to configure chimps, let's say, from the ID. We also need chimps. That just goes into your environment rd file. This is the really important part here. So in environments, you can actually specify this elsewhere. I prefer to do it here. We actually have to go through and specify our, I'm just going to copy this one. Get hope, it's easier. That was my connection. I did. Are you guys also connected? Yes. Have you moved to the con connector? Connect the con right here when you're actually online. Okay, so this is online. And this is just configing. I'm going to switch this now just so I don't forget. We're going to cache later. And I actually work on virtual machines. I'm going to change into fonts. You guys don't have to be that far. This is a really important line. And this just pulls the environment variable for the ID. And you can set this pretty easily in things like the review. And we'll set it in just a minute here. And then we need to set up our rd file. And in here, you're basically just going to map resources. It's going to be something to do. And then we'll start building in the controller. So we've only got one controller. And we've got the show, and we've got the tweaked controller. So it's really simplistic. Okay, so we've got that. Okay, so what we're going to do is we're actually looping through strong links twice. So everyone definitely understands what strong links is. It's your most important people that you interact with. So it's your most important people, top 100. And then they're most important people. So we have to loop through all of your guys. And then I have to loop through all of those guys, which can be a total of 10,000. Or I'm going to do 100. So in order to do that, I'm going to actually just build a method here that just loops through it. So we're going to do it twice. So we have to repeat. Then we can do a little bit of drawing, right? So we're just going to call it strong links for user. I'm going to pass two arguments, which are going to be ID and ID type. This is going to be the actual things that you would add into your API call. So if we look at the API call itself, this is everything that's after the question mark. So you've got the API key. So this is the screen name. So this is going to be the type. So you can call screen name or you can call Twitter ID. So if you know your Twitter ID, you can actually call by that instead. This is actually really common and big data that they only return the Twitter ID. Is anyone familiar with the Twitter API? I think you guys actually mess with Twitter. Okay, so like you guys know that you actually get the Twitter ID back a lot more than you get the Twitter screen name. It's kind of annoying, but that's how Twitter works. So you can query by both. You can query by screen name or user ID. And we're just going to specify which type that is there. Okay, so we have to loop through both. So I'm just going to do a really simple for loop. Let's see here. So we actually have to do the query first. Here's the important part. Here's how you do the query. The first argument is the path to the query. So strong links. And you can find this in the inputchamps.API.com documentation. And here's all the stuff that we pass at the end of the string. So we're actually going to say, here we want to say ID type. And I'm also going to say version number. And you can specify this and this helps you stay just current with whatever version that you're working on. And then we're going to say .get. And that actually does the get request on these. Then we're actually going to return them. So we have to say query, strong links. And that's what you have to get out of the query. And we're going to reject all the nils. This is actually an inputchamps bug at the moment. And we have to work around it. And then we're also going to say query, strong links. And this is a Ruby term. That's how you do just the ones that you want. So we only want to do one through 10. And I think you can actually say one dot dot dot 10 if you want to, if you want to. I don't really like doing it that way. I'm going to throw in some arrow handling here. And this is so that when we throw things through there, if we get back a blank request, we actually don't have to worry about anything. We're just going to pass it a blank string. So the inputchamps API gives you back errors in JSON. So if you query for something and it doesn't have it, it'll say, it'll give you a little JSON hash and it'll say error and it'll give you the actual error. So if we have one that's present, we're just going to say blank. That's all we need. That's our entire thing there. So I'm going to go ahead and skip. I think we're, I really don't want to run this much. So I'm actually just going to check out what we have here. Okay, so if anyone just walked in the room and kept up here. Okay, so this is the big method built out. Okay, so as you can see, this is just a little bit prettier than how I read it and how I write it as well.  Actually not a helper, but a library problem. And here's how we actually do it in the show. So the first thing that we're doing up here, this is really cool and this is something I should pay attention to. This is auto-vivifying. Is anyone familiar with auto-vivifying? Any parole writers here either? Auto-vivify is a feature of parole. It's actually a really cool thing. Imagine it is, I like to imagine it in a way. It's like an initializer for a hash. So you can actually call a data structure without actually creating it. This kind of just auto-populates in a way. And this is something that we actually need to do in order to go through the API keys because if we come back with one that's empty, it's not gonna work right. So the next line down, we're just looping through the first bit of strong links and then this one, we're looping through the next bit. So like if these didn't have the 10 out of 10, we'd be making 10,000 calls, but in this case, we're only making 100. We're passing the third program of whatever your ID was that you asked for and it's gonna be a screening and then since strong links returns a user ID, we're gonna call it that. So here's a part that does all the work, everything in here. So the things that we're getting again are count, weight, and trust drive. And this is the count of the number of times that user serves up in your strong links, of your strong links, and then the weight, and that's the total weight that you accumulate as we tally through them. And then we're also gonna query the input change API again here and that's what this little block is. And we're gonna add that to the hash, just as trust. I just did it as a symbol. I think I actually put this up there, make it shorter. And trust drive again is like page on per Twitter. Then we're gonna sort through all of them and this is just like really simple Ruby sort. I assume you guys all know how to do this, but this is a really cool way to deal with data that you don't have SQL database to deal with. You can actually go in and say, deliver by descending or whatever. So you can actually sort by this, we can sort by count, we can sort by weight, we can sort by trust drive whatever you want here. And then we do the respond to format. And this should run. So the way to do this on the API or on the command line is you actually have to declare your API key in the command line because we declared the environment variable. You can actually put this in a config file if you really want to, but I like to do it on the command line because it's easier and keeps the stuff out of my code. And I can also do it on my code very easily. So the first thing here is just declare your variable and you guys can grab this key from the GitHub repo. Anyone need that URL again? Okay. That's just an API key. If you sign up on api.imperchamps.com, you can get your own. Don't use this one over because it's going to be limited after today. And then I write a unicorn just because I like unicorn but it's my bird because I want to have it with me. You guys can use a script server if you want. So I also need to know where I am. Okay, here we go. So now we're going to call tweeters, which is our controller and we've got friendly ID so I can just call the username. So I'm going to call it in perchamps. And so now is a good time to talk about performance because as you can see, we're still making a request and we actually didn't have a database. So the performance issue here is that we are making 100 API calls for strong links because we've moved through all your API users, right? And then we're making 100 more API calls because we're moving through trust right. So that's 200 API calls that you can figure for about 30 milliseconds a piece and then you have a few time after that. So here's a list. And I didn't show you guys the show template yet, but first column is username, second column is count, third column is weight, and fourth column is their trust right. So this is really, really cool here, right? Because this is a list of your second hot out and it tells you just how connected you are to all these people. Are you guys familiar with LinkedIn? Yes, all LinkedIn. So are you guys familiar also with LinkedIn's little blue circles that they put next to the names when they say first and second? This is essentially developing LinkedIn's second thing, but it's even cooler because it shows people by weight and there's various metrics along with them. So we're actually building something that's cooler than LinkedIn for the Twitterverse. So you can see like some of the people that input changes, I can't really see them. There. Most connected whether these folks, anyone on this list? Anyone in the top? I think James here. I think we're in the right space. There's Damon and Michelle Greer from black space. Yeah. Yeah, those guys are cool. Okay, so I'm gonna keep on going. I'm just gonna check out the next iteration of this. So now our other goal was to be able to sort, right? And do something really cool here. So what I've done is I've created a layout and this is really simplistic. Can you all read that? It's jQuery and then there's a jQuery plugin for a table sorter. It's this line. And then we have actually grabbed Twitter's anywhere API, which is weird, but it works cool. And then I got the idea to put him CSS just to make things pretty. And then we're gonna yield it all right here. And I'll show you how to do the JavaScript in here. Let me just run it so you guys can see what goes on. So refresh that one. Again, continuing the performance. So when you make an API call, you have to figure for network latency as well as compute time on each one of those things. So we need to go there and back. So you have to figure for at least 30 milliseconds if you're making 288 API calls that's 6,000 milliseconds to six seconds. Then you have to figure for the compute time on each of those calls. So that's actually a really long time. It's not the most performable thing that we can do, but this is the simplest thing. Okay, so now we've got it pretty. And we've got it sortable. And can you guys see what's going on here? I can sort the columns and we didn't use SQL at all.  And the only thing that I actually did was drop some JavaScript in. And I'll show you what it looks like. This is the extent of the JavaScript right there. And this is just, everyone familiar with jQuery? Yes, jQuery. So jQuery, if you aren't familiar, allows you to do really cool things in JavaScript very easily. This is a selector for jQuery. It selects the user ID. So if we have an ID element in our HTML called users, it'll select it. And the jQuery table sort function knows where to find t-head and t-body and it knows where all these table headers are. And it says, hey, there's a column. I need to sort by it. And that's the entire extent of everything that you have to do in order to sort. So all you have to do is actually declare these table columns and then say this. So we magically made this sort of goal. And now I can go through and see who's most important more easily. So we actually just sort of count the same people at the top here. You can sort by weight. So this is the number of interactions. So you can see that this list is a little bit different than how. So say, for example, if you go, are you guys familiar with Justin Bieber? Oh yeah. So he's kind of semi-famous within Memcuchamps. He's the top-tweeted-at person. So while a lot of people believe that people like Barack Obama and such are like the top users because they have the most number of followers, Justin Bieber is followed as far as actual interaction goes, is by far the most powerful user on Twitter. So he's kind of interesting, especially considering he just popped up and we have data back all the way to 2006, he's still number one. So he's pretty interesting. So someone like him, if you have a friend say, who's really into Justin Bieber, might show up there really high-weighted because he or she just treats Justin Bieber all day and it's like, I love you Justin Bieber, blah, blah, blah. So that's why you may not want to sort by weight and it may not be as accurate. Trust right, again, really cool. First person on here is ReadWriteWeb. We added the hover card thing with the Twitter API and you can pull this up really easily. It gives you a little bit of information about them. ReadWriteWeb is rated really high because they're followed by a lot of people who are very well followed as well. I don't know what's the other people on top here. Generally anyone, so this is logarithmic, to 10, zero to 10 scale. So anyone, so imagine like on the web, Facebook, Google, Myspace, Twitter are all gonna be like in the eight, nine, 10 range.  I can show you real quick on Trust Me. This is our public exposure website for Trust Ring. And as you can see, Justin Bieber's our top guy. A plus K is Ashton Kusher. I'm Diddy, John C. Mayer. These are all the top people. So I'm sure you guys probably know who most of these guys are. Amazingly, I didn't. There are a lot of people on Twitter who, and I don't really follow the popular culture very well, so I didn't know who was it. This girl, Kim Kardashian, I didn't know who she was. But this is just an example of like, these are like the most influential people on Twitter, as far as Trust Ring goes. You get kind of nosy, take it, Perry. Okay, let's go back to the app. Oops, what time do we get out of here? 40. What's that for? No, not at all. Okay, so I'm gonna go actually back to the slides here. Okay, so again, if you guys wanna follow along with the example, you can do this and you can just check out the whole thing. I got it in some performances at the end. If you wanna check out app progress dash four, that's where, sorry, progress dash two, that's where we are right now. Okay, takeaways. So it's freaking easy. Everything that we did with this is right here, and this is the Equishms query API call. We're eventually gonna make these easier, but right now it's basically just telling the path and then some query parameters. This is all you have to do to get like, that massive for kid string that I showed you guys earlier, and this is an incredible amount of data right here. We do all the big data compute on it so you don't guys don't have to. All of them are fine. Again, this is really cool. You should read about it more in your spare time. Wikipedia's article is okay. Look on the rest of the web, just like Google for it, and you'll find some interesting resources. Again, it's something that's native to Perl, and you can do it really easily in Ruby just by doing something like this. It's just the beginning of this actually, and then after it, it's basically whatever you wanna put it there. And again, this is like to kind of auto-populate or hash. And this was really cool. We did everything that I just showed you without a database. So we did sorting in Ruby one time, and then we did sorting again in JavaScript the other time. We never used any SQL. Everything's entirely Ruby and JavaScript, sorry, JavaScript based. So I wanna talk a little bit about performance.  The network is being hammered to this here. Yeah, the network's slow here too as well. The FHM's API is actually very performant. So like if you guys are querying for a poem, I think most of our response times are pretty much instant and network latency to us is we're in, we're on Amazon, so we've got like actually distributed. We're not CDN, but we've got load balancing and that sort of thing. So the different ways that we can deal with this, the way I dealt with it in my app, if you download the GitHub app, the full one, I did it with page caching, and this is like a really, really simplistic way to go about it, right? Because you can actually just go in and say, hey, I just want to cache or anything that actually gets viewed. And you can, am I too close to that thing? No, okay. You can cache or anything that gets viewed and that it never has to load again. It's a really cheap and hackish way of doing it. The other way is to limit number of requests and we actually did that as well. And the way we did that was by saying the zero dot dot nine and not only to 10 of the 10, so we only had to make 200 API calls instead of 2000, or sorry, 20,000. Cache in the local database.  Yes, super API hackers, awesome. Follow up with when another one's presentation, he's gonna do one, I think later today or tomorrow, Jason and the Argonauts, and he's gonna talk a little bit more about caching in local database. This is probably one of the, this is probably the next step that you should take. It's one of the easier things to do. The other thing that is easy in concept to do is concurrent requests. Are you guys familiar with like concurrency and parallel versus serial sort of thing? Yes, okay. If you're not, I will explain it very shortly here. And that's kind of small. So the way that we're actually making the calls right now is like serial. So we make one call and we wait for it to return, we'll make another call, wait for it to return and we'll make another call. So every 20 milliseconds we have to wait and it's all in a line, it's just a bit cute, right? The better way to do it would be in parallel. And this is so that we can say, hey, I wanna make a hundred API calls. The original take 20 milliseconds, but the thing is we're gonna do it all at once and if the infotainment API can handle it, which it can, we can do it a lot faster. And the one way to do this would be with something like Event Machine. And I think, I think Event Machine's C-base, I can't remember, but this allows you to do concurrent requests more easily. The other way to do it is with JavaScript. And that's a really hacking way to do it. So actually if you end up with a page and you wanna do all your code in the JavaScript, you can actually kinda cheat around making those requests by just looping in your JavaScript with Ajax. Then this allows you to do concurrency without having to actually do concurrency in your Ruby code. Now does your API allow you to batch requests? Not currently, we're working on that. It's gonna be something that's gonna come out really soon here, so that should limit your, or sorry, decrease your load time quite a bit. Okay, so some other cool stuff. 10 minutes, okay. Some other cool stuff. Scaling data, this is an example from our wordbag column. So this is something that you probably wanna do in data a lot. If you guys aren't familiar with logarithms, it's basically making big numbers more understandable. So for example, the Richter scale, the one that measures earthquakes, is on a logarithmic scale. So instead of having numbers like zero to 20,000, we have zero to 10, which makes it somewhat more understandable. The interesting side effect of that is that like a, not a Richter scale of nine earthquake, is 10 times as powerful as a Richter eight scale earthquake. So even though it's only one number up, it's 10 times as much. So it's somewhat misleading, but it actually makes things a lot more easy to deal with. This is a quick way to do it in Ruby. It's just the math library.  If you guys are just building Twitter apps, and you just wanna build a really quick app and put an avatar on, I promise you, if you try to enter basically the Twitter API, you will be really pissed off. I rented this the first time that I did something, but there's this really cool thing. Are these guys here between images guy? Anyone? I think they're PHP guys. But it's a really simple API call. You don't even need an API key. You just call this and I shoved in an ERB thing there. You just put the username inside and it'll return you a nice, and you can have like five different sized avatars.  This right here is event tracking. There are two ways to do this. There's event tracking and there's also, you can change this to like an outgoing thing. Are you guys all familiar with Google Analytics? Do you guys do work with Google Analytics? So you can either do event tracking, which is kind of okay. I prefer the other way, which is actually doing it through an outgoing link and you can say, hey, this traffic was outgoing and you have to specify it in JavaScript. It's just like this. It's very simple to do though. Just look at that. More cool stuff. Consent, this took me forever to find. Probably like a week before I was very close to writing it myself. And it's a really, really cool plugin that allows, it's like a firewall for your Rails app. So it allows you to rate limit people. And this is cool for Rails in general, but this is even better for your API because you just let your API just sit there. You're like, sorry, your app just sit there. People can use your app kind of straight to the push-ins API, which is gonna run up your bill instead of theirs. So you can do that based on IP. It's really, really simple to use. It's really cool. This is probably the coolest plugin I've ever ran into in my entire life. This is Cacheable Flash. Typical came up with this, I think. At least they don't get a repo for it. It allows you to cache whatever you want. So you can do page caching and not have to worry about anything.  Page caching will let you just be really fast. It'll actually put in the plugin unless you put stuff in JavaScript. So you don't have to worry about your caches getting like captured inside the flash and then like not caching for certain pictures. Okay, I'm gonna end. I guess I'm early. You can find me on Twitter and you can email me, feel free. And you can find me on the web, too. Any questions? Oh, yeah. Yeah. How hard would it be to adapt this to Facebook? I know their API is kind of harder than Twitter's. So most of this is with the InfoChimp's API. The only thing that we made with the Twitter API was the Twitter anywhere thing. Facebook currently doesn't have anything like that, mainly because it's so much more private than Twitter is. As far as the data for Facebook, we have just begun collecting that data and we actually haven't done any big data compute on it yet. We have MySpace and Twitter only right now. So as far as making an app like this, you could not do it unless you were willing to do the big data compute yourself. But we will get around to it very shortly here. Facebook is our big step. Yes? What, if anything, do we need, in terms of business for you? Do we have to pay you money to get access to this stuff or what's the story? Yeah, so I'll show you the InfoChimp's API site. It's free for your first 100,000 calls about the levels that's written here. All you have to do is sign up. It's just like a simple sign up page on the InfoChimp's.org website. We get 100,000 calls, so this is like so you can build your basic app. Our next level up is really cheap. It's $20 a month. It's really simple. As you go up, this is like if you're making lots and lots and lots of calls, you're one of the big guys. So we're back and we're going to make pretty much more expensive. But yeah, if you want to just start out, it's completely free. And when you sign up, you get an API key so basically you can start playing right now. Anybody else? Okay, I'll let you guys keep lunch. Thanks for coming. Bye-bye.


Hello and welcome to the session. My name is Mansi and I am going to help you with the following question. The question says from the prices of shares X and Y below, find out which is more stable in value. So in the table given below in the first row we have the prices of share X, in the second row we have prices of shares Y. So let us start with the solution to this question. Now for determining which share is more stable in value, we have to find both their variance from the variance which ever is lesser value of variance is said to be more stable. So let us see how to find out the variance. Step one is calculate the mean of a data denoted by X bar that is X bar is equal to 1 divided by n into submission X i where i goes from 1 to n where n is the number of observations.  Step three is to find X 1 minus X bar the whole square X 2 minus X bar the whole square and so on till X n minus X bar the whole square. Step four is we find their sum that is we find submission X i minus X bar the whole square i goes from 1 to n then step five is to find out the variance that is sigma square equal to submission i goes from 1 to n of X i minus X bar the whole square divided by n. So now like this we make a table this is for shares X and this is for shares Y they are the X i's given to us in the question they are the Y i's given to us in the question we have to find out X i minus mod X or X bar and similarly we find Y i minus Y bar then we find X i minus X bar the whole square and here also we find out Y i minus Y bar the whole square. So let us find out X bar we know that X bar that is the mean of the data is equal to into submission X i where i goes from 1 to n this is the standard formula for the mean. So let us sum up all these X i's and similarly we mean of Y will be equal to 1 by n submission Y i where i goes from 1 to n. Here also we sum up all the Y i's we see that submission of X i's is 510 and submission of Y i's is 1050. Now we have to find out X i minus mean of X. Now we see that we have to find of mean of X that will be equal to 510 divided by now number of observations that is n is equal to 10 so mean of X is equal to 51 similarly here we see that we get 1050 divided by 10 and that is equal to 1005 this is 105 so mean of X is 51 and mean of Y i's is 105 minus 10 minus 2 we find out their square is 9 square of 1 is 1 here then 0 X bar the whole square and Y i minus Y bar the whole square. So we have summed them up we see that this sums up to 150 and this sums up to 40 finding their sums that is this we find out the variance that for shares X variance sigma square is equal to submission i goes from 1 to n X i minus whole square divided by n we simply put in the values here and we get 350 divided by 10 that is equal to 35 so variance for shares X is 35 only for shares Y variance that the sigma square is equal to submission Y i minus Y bar the whole square i goes from 1 to n divided by n that is equal to 40 divided by 10 and that is equal to 4 now we see that to compare the variability we have to calculate their coefficients of variation now coefficient of variation for X is X divided by X bar multiplied by 100 we see that sigma sigma square is equal to 35 so this implies that sigma is equal to square root of 35 divided by that was 51 multiplied by 100 now this is equal to by 100 divided by 51 i 100 and 90 divided by 51 7.6 so coefficient of variation for X is 11.6 now we find out coefficient of variation for shares Y that is again sigma for Y divided by mean of Y that is Y bar multiplied by 100 will be since sigma square equals to 4 so sigma will be 2 so here we have divided by now mean for Y is 105 so this multiplied by 100 that is 200 written 5 this is 2 by 105 into 100 because sigma Y is 2 mean of Y i's is 105 multiplied by 100 so we have 200 divided by 105 that is approximately equal to 1.9 we see that coefficient of variation shares Y coefficient of variation answer to this question is Y so I hope that you understood the question and enjoyed the session have a good day


Alrighty, so we have one of the most underestimated additions to 2019. We have a construction update from Dollywood today from Dirk Diggler 1992 on Instagram. You gotta go check him out. His photos are absolutely amazing. He's been covering carowinds and Dollywood so far. And just his pictures in general during the regular season of operation are absolutely stunning as well. Look at these stunning photos from even a distance. So just to let you guys know, the coaster is not fully complete yet. We are getting close to fully complete on the coaster layout. And oh my goodness, I was not expecting it to look this amazing. This thing looks absolutely stunning. I'm looking at the height difference of the drop to that first like kind of like banked curve and then the rest of the coaster. This is going to maintain some pretty good speed throughout it. So that's really exciting. I can't wait to see this with its surrounding area, the theming and the other rides too. For those of you that are watching this video, so if you're Canadian or just don't necessarily say that update with the coaster community, at the end, I put the actual announcement video so you'll be able to see exactly what I'm talking about that Dollywood has announced for 2019. It's a quick like one minute video with some awesome cinematic footage of what Dollywood is getting for 2019. So if you don't know, definitely stay tuned at the end of the video for that. But this is stunning. That underground portion into that banked curve looks amazing. I really like that green color on the track and I like the green on dark green. I don't know why, but it really stands out and seeing this actually in person compared to that like little color drying definitely makes this coaster pop. I am so excited for Dollywood in 2019 and hopefully you guys are as well. Hope you enjoy this construction update. I have a feeling you'll see some more up close and personal construction construction updates at a Dollywood very shortly. So stay tuned for that. Thanks for watching, guys. Hit that like button, subscribe if you haven't and share this video for others to enjoy. Have a good one, guys. Bye. It all started with a song on the wind. And a young girl answering the call of a hidden land. So began the legend of Wildwood Grove crossed through an ancient fallen log and step into Dollywood's newest land of discovery and adventure. Here in Wildwood Grove, the natural beauty of the Smokies combines with the power of pure imagination. Listen, the song on the wind really does exist. It's the sound of live music drawing you in toward the towering Wildwood tree. From here, the heart of the land, excitement branches out in all directions, go one way and suddenly you're in bear territory. But don't worry, the residents of Black Bear Trail couldn't be friendly. In fact, they're happy to provide a ride while introducing visitors to the Bear Basics. Go another way and the exciting adventures continue in Wildwood Creek, a splash pad positively overflowing with aquatic family fun. And just around the bend, the sounds of pure euphoria, the rides of Wildwood Grove deliver thrills for adventurers of all ages. Take an exhilarating flight on Dragonfly, a suspended family coaster that twists turns and soars. As the sun sets, friends and family gather under the great Wildwood tree for a stunning display that lights up the night. From one irresistible moment to the next, the spirit of this place calls out for you to come, explore, play and imagine together at Wildwood Grove.