--- layout: post title: Configuring Perl to run on Apache (win32) tags: [] status: publish type: post published: true meta: {} ---
This document will highlight the changes necessary to get Perl to work with your Apache web server running on Windows NT/2000. As with the configuration of any other aspect of Apache, you will need to modify the configuration files. These are located in C:\Program Files\Apache Group\Apache\conf if you choose the default installation options.
The file you need to edit is srm.conf. When the server starts up it processes the httpd.conf first and then it will look for srm.conf. You will need to specify two things here. The first is the location of your CGI scripts. Next you will need to map the perl file extensions to your server. The srm.conf file looks initially like this:
#
# This is the default file for the ResourceConfig directive in httpd.conf.
# It is processed after httpd.conf but before access.conf.
#
# To avoid confusion, it is recommended that you put all of your
# Apache server directives into the httpd.conf file and leave this
# one essentially empty.
#
To implement the changes required make sure your config file looks like this:
#
# This is the default file for the ResourceConfig directive in httpd.conf.
# It is processed after httpd.conf but before access.conf.
#
# To avoid confusion, it is recommended that you put all of your
# Apache server directives into the httpd.conf file and leave this
# one essentially empty.
#
ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache/cgi-bin/"
AddHandler cgi-script .pl
The first new line specifies the location of your cgi-bin directory (ScriptAlias) and the second line deals with the file extension mappings (AddHandler). For the changes to take effect stop and restart your server.
In order for your scripts to work you will need to specify the path of your Perl interpreter in your perl scripts. If you are running ActivePerl <IP_ADDRESS>3 (www.activestate.com) the default path should be C:\PERL\bin\perl.exe. So the opening line of all your Perl scripts should look like this:
#!C:\PERL\bin\perl.exe
Should you know wish to allow cgi-scripts to be executed from any other directories other than the cgi-bin/ directory you will have to specify an alias and the path to that alias. Again in the srm.conf file enter the following line if you wish to have an alias "Scripts" for the directory called c:PerlScripts:
Alias /Scripts/ "C:/Perl/Scripts/"
Please note the use of "/" for the path definition instead of "". You should be aware of the fact that you can also add these lines to the httpd.conf and the Apache documentation recommends this. However I find it easier to manage changes and information by keeping these modifications in a separate place. If you would like to test your installation try saving the following script in your script directory as hello.pl (please make sure that you make the appropriate changes to this script to reflect the location of your perl executable):
#!C:\PERL\bin\perl.exe
use CGI qw(:standard) ;
print header();
print "Hello, world";
You can now view this file by entering http://<IP_ADDRESS>/cgi-bin/hello.pl (or if you have been following the tutorials from this site the URL should be http://<IP_ADDRESS>:8081/cgi-bin/hello.pl). If all is working your browser should display the message Hello, world. Hope you found this quick introduction useful. All of it and much more can be found in the documentation provided with the Perl installation and these are located by default in the c:perlhtml.


{% extends 'base.html' %} {% load url from future %} {% load i18n %} {% block body %}
{% trans "Oh snap!" %} {% trans "Please enter a correct username and password. Note that both fields are case-sensitive." %}
We don't have a registration page yet, but everyone is welcome to participate. So please send an email direct to {{<EMAIL_ADDRESS>}} or get in touch through our community page.


--- layout: post permalink: 48hourprint.html Tags: Array NameOfCoupon: 48 Hour Print Cash Back Summary: See our 48 Hour Print Coupon Code, 48 Hour Print Rebate, 48 Hour Print Promo Code, 48 Hour Print Discount, 48 Hour Print Coupon Cash Back Rebate here.  We have the best 48 Hour Print Rebate anywhere. thesis_keywords: 48 Hour Print, 48 Hour Print Coupon Code, 48 Hour Print Discount, 48 Hour Print Rebate product_name: 48 Hour Print hop_url: http://www.icouponblog.com/hop.php?id=5167 ---
If you are looking for the perfect printing experience, visit www.48hourprint.com. They are one of the best in the field. Whatever your printing needs from appointment cards, business cards, banners, door hangers to brochures, leaflets, magazines, letterheads, magnets, newsletters etc, www.48hourprint.com will not only provide their best service, but they will also do it within 48 hours. They are the only printing company that provides such an offer. Use our discount coupons to get a great deal.
Visit 48hourprint.com and discover for yourself, what quality printing is all about. At amazingly lower price, get your entire prints job done within 48 hours. If you have a small business or a big one, use the trusted name in business 48hourprint.com is who you can trust, with all your valuable office print jobs. Our discount coupons will save you money. No matter what your printing job, www.48hourprint.com will provide you with the best products and services at an affordable price. All work is done by state of the art innovative equipment which will give a professional, attractive and appealing looks to your company’s brochures, leaflets and other materials. Check it out online at www.48hourprint.com.
48hourprint.com is an amazing website for all your printing needs. You can use their professional designers to help you with the pattern and design of your company’s letterhead, business cards, door hangers etc. It is a great printing place to visit. Put your faith in www.48hourprint.com and they will deliver to your satisfaction.


Bench Configurations
Existing configurations
Selected configuration communication interfaces
Create
Close


--- title: Simulating Customer Journey Prediction in a Federated Learning Setup keywords: fastai sidebar: home_sidebar nb_path: "index.ipynb" ---
%load_ext lab_black
# nb_black if running in jupyter
In this study I show that customer paths can be predicted in a federated setup. The purpose of the work is to show, that this is possible using real customer journey data. The purpose is not yet to provide optimal solutions. The goal of the work was to observe machine learning in the given setup. With these results I hope to encourage further research and innovation on federated learning for privacy preserving personalized digital services.
Federated learning (FL) is a term used for machine learning in de-centralized setups where data is distibuted across edge devices [1]. In a FL setup a shared model is learned by iteratively aggegating locally trained models. A FL setup consists of a server updating a global model averaged from aggregate distributed model parameters, and multiple clients (edge devices, for example mobile phones) that fit the global model to their data.
FL can be used for improved privacy, because instead of data, only the aggregated model parameters are shared. The raw data remains in the edge devices. The federated service provider does not rerquire a direct access to the data. However, the model update information still contains indirect information of the client data, so some privacy risks still prevail [2].
Because each local dataset is hosted by an edge device and represents a single client, FL setups typically follow a few assumpions: the data is strongly non-IID (it represents a single client), unbalanced (the users use the service differently), massively distributed (there are more clients than data points per client), and finally limited communication (federated updates require the device to be at rest, plugged to charger and connected to Wi-Fi).
A customer journey describes the service touchpoints and transitions between them as a customer goes through a service process. We can model these as states of a stochastic process, and use machine learning to predict the next state based on the previous ones, and other information about the customer. Knowing the most likely next states would allow a service provider to tailor the service for the individual customers.
Typically, each customer may only have few data points of their own, e.g. few clicks on a web page since they have entered the service. This means, that a localized machine learning model using the data of a single customer is not an option. However, customers may be unwilling to share their data for centralized processing, as they are for example with website 'cookies' [3].
With federated learning, the customers could benefit from each other without directly sharing their data. This makes customer journey prediction is an interesting field of application for federated learning, especially in the public sector & government context.
For the public sector, this opens up new means for creating novel digital services. Cities or governments can provide the citizens personal AI assistants that give them personalized recommendation and advice in various areas of life, including education, healthcare and career. These kind of services would require very sensitive data, that the citizens may be unwilling to trust the government with, and that local regulation may prohibit the officials from collecting. Federated learning can help provide these services, without the need for data share.
The results may also be applied to other next state prediction problems not involving human customers, but artificial clients insted. One such example could be predicting faults on IoT devices.
In this work I show how custom data can be used with TFF. I use the customer journey dataset by Bernard & Andritsos [4]. I use 21k data points from 3000 customers (divided into 2100 train and 900 validation clients). There are 16 state labels (including an abstract state describing end of service), 2 customer background features (age and income) and the order of the action. In the dataset, most customers only had 3-5 events recorded and the max observed was 10. I create a simple federated learning setup for next state prediction on this dataset. simulate the federated learning with TFF and compare the results against centralized computation baseline using identical NN model.
The code is presented in the wiki tabs CustomClientData and FederatedCustomerJourney and in the notebooks 00_data.ipynb and 01_model.ipynb that can be found from the root of the repository.
Train and validation accuracy in comparison to baselines. X-axis shows the federate update iterations, and y axis shows the accuracy. The federated updates are not directly comparable to progression of centralized computation, for which we only plot the result after 20 epochs.
We observe the federated learning achieves clearly better stats than random guessing, but does not perform as well as the centralized baseline. Complete reproducibility proved difficult to achieve using TFF, so the results may vary depending on the run.
View the tabs / notebooks for further info.
It should be noted that the results were achieved in an optimistic scenario. For example the issues of changing client pool, client availablity, update scheduling and malicious behaviour were not considered in practice.
The repository core structure is the following:
data/ # A folder where data is loaded (empty, run 00_data.ipynb to load data)
docs/ # HTML doc files are generated here
ml_federated_customer_journey/ # python module, functions and classes from notebooks are exported here
00_customclientdata.ipynb # Load and clean data, define related functions
01_federatedcustomerjourney.ipynb # federated simulation
index.ipynb # this notebook, the repo README and wiki main page are generated from this
settings.ini # project metadata for nbdev tool
To install and run the code:
git clone git@github.com:City-of-Helsinki/ml_federated_customer_path.git
cd ml_federated_customer_path
# (create and activate virtual environment of your choice)
pip install requirements.txt
nbdev_install_git_hooks
# run 00_customclientdata.ipynb to load and clean data
# run 01_federatedcustomerjourney.ipynb to run the federated learning simulation
# to update ml_federated_customer_journey module and docs, call:
nbdev_build_lib && nbdev_build_docs
Please note that the exact results are not reproducible due to inheritant reproducibility issues of TFF.
Feel free to try out different setups!
Drop the authors message if you are interested in further research on the topic! (firstname.lastname(at)hel.fi)
See here on how to contribute to the code.
1) McMahan et al. Communication-Efficient Learning of Deep Networks from Decentralized Data. 2021. Google Inc. https://arxiv.org/pdf/1602.05629.pdf
2) Truong et al. Privacy Preservation in Federated Learning: An insightful survey from the GDPR Perspective. 2021. https://arxiv.org/abs/2011.05411
3) Mueller, R. 76% of Users Ignore Cookie Banners: the User Behaviour After 30 Days of GDPR. 2018. Amazee Metrics (online journal). https://www.amazeemetrics.com/en/blog/76-ignore-cookie-banners-the-user-behavior-after-30-days-of-gdpr/
4) Bernard, G., & Andritsos, P. (2019). Contextual and behavioral customer journey discovery using a genetic approach. In 23rd European Conference on Advances in Databases and Information Systems (ADBIS), pages 251–266, Cham. Springer. Dataset available at: https://customer-journey.me/datasets/
This project was built using nbdev on top of the city of Helsinki ml_project_template.
%%script False
@misc{
sten2021simulating,
title = {Simulating Customer Journey Prediction in a Federated Learning Setup},
author = {Nuutti A Sten},
month = {12},
year = {2021},
howpublished = {City of Helsinki},
doi = {10.5281/zenodo.5801725},
}
Copyright 2021 City-of-Helsinki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project's files except in compliance with the License. A copy of the License is provided in the LICENSE file in this repository.
The Helsinki logo is a registered trademark owned by the city of Helsinki.


java.lang.Throwable
, either directly or indirectly.
Although exceptions usually don't depend on other classes for their implementation, they are normally not used separately. It is often a better design to locate exceptions in the same package as the classes that use them.
Available only from Code | Inspect Code or Code | Analyze Code | Run Inspection by Name and isn't reported in the editor.


Quickstart¶
The CO2 tracking tool can be used along with any computing framework. It supports both online
(with internet access) and
offline
(without internet access) modes. The tracker can be used in following ways:
Online Mode¶
When the environment has internet access, the EmissionsTracker
object or the track_emissions
decorator can be used, which has
offline
parameter set to False
by default.
Explicit Object¶
In the case of absence of a single entry and stop point for the training code base, users can instantiate a EmissionsTracker
object and
pass it as a parameter to function calls to start and stop the emissions tracking of the compute section.
from codecarbon import EmissionsTracker
tracker = EmissionsTracker()
tracker.start()
# GPU intensive training code
emissions = tracker.stop()
Decorator¶
In case the training code base is wrapped in a function, users can use the decorator @track_emissions
within the function to enable tracking
emissions of the training code.
from codecarbon import track_emissions
# Results are saved to a `emissions.csv` file
# in the same directory by default.
@track_emissions
def training_function():
# training code goes here
Offline Mode¶
An offline version is available to support restricted environments without internet access. The internal computations remain unchanged; however,
a country_iso_code
parameter, which corresponds to the 3-letter alphabet ISO Code of the country where the compute infrastructure is hosted, is required to fetch Carbon Intensity details of the regional electricity used. A complete list of country ISO codes can be found on Wikipedia.
Explicit Object¶
Developers can use the OfflineEmissionsTracker
object to track emissions as follows:
from codecarbon import OfflineEmissionsTracker
tracker = OfflineEmissionsTracker(country_iso_code="CAN")
tracker.start()
# GPU intensive training code
tracker.stop()
Decorator¶
The track_emissions
decorator in offline mode requires following two parameters:
offline
needs to be set toTrue
, which defaults toFalse
for online mode.country_iso_code
the 3-letter alphabet ISO Code of the country where the compute infrastructure is hosted
from codecarbon import track_emissions
@track_emissions(offline=True, country_iso_code="CAN")
def training_function():
# training code goes here
The Carbon emissions will be saved to a emissions.csv
file in the same directory. Please refer to the complete API for
additional parameters and configuration options.


Decomposing the Human Palate with Matrix Factorization
Summary: My classmates and I applied the matrix factorization technique for recommender systems to a data set of 120K user profiles scraped from the recipe-sharing web site AllRecipes.com and extracted 40 latent “tastes” that combine to make up all sorts of human foods.
If you understood that sentence, feel free to skip ahead to Part II of this post, Matrix Factorization and Food, where you can view the results and play around with some interactive visualizations.
  If reading the title of this blog post is causing to you go into anaphylactic shock, please know that I meant no harm.
The truth is that I didn’t pay any attention in math class either. As far as I can tell, “orthogonal” is just a fancy synonym for “unrelated”, an “eigenvector” is probably something horrible that Wernher von Braun dreamt up before he switched employers in 1945, and a “product space” is the kind of thing that a “growth hacker” gets excited about.
The good news is that understanding matrix factorization does not require any linear algebra beyond the definition of a matrix multiplication.
But before I get into the details, I want to motivate the algorithm by pointing out an application to the most heavily studied problem in computer science: how to get people to buy more things.
Recommender Systems
Suppose that I order the City Chic First Years Jet Stroller on Amazon.com. Amazon would like to sell me more items. Which items should they recommend?
One idea is to recommend items that are intrinsically similar to the City Chic First Years Jet Stroller. These might be items that also have “stroller” in the name, or items that are made by the same manufacturer, or items whose descriptions share words in common with the description of the stroller. This is called content-based recommendation.
A more interesting idea is to treat the items as black boxes and somehow learn correlations between the items from the ratings history of all users. This is called collaborative filtering. For example, I would bet that people who buy baby strollers are also likely to buy the Essential Mozart CD collection. The association between these two items could never be detected by content-based methods alone because a Mozart collection has zero properties in common with a baby stroller. An intelligent yet uninformed alien visiting Planet Earth for a day would never think, “Ah, yes, of course people with no previous discernable interest in classical music will suddenly snatch up the collected works of Wolfgang Amadeus once they are also in the market for a baby stroller.” Fortunately, thanks to collaborative filtering, Amazon can pick up on the relationship between these two very distinct items and make the right recommendation. It’s a win-win situation: Jeff Bezos will become richer and the baby won’t get left behind.
One of the most fascinating techniques for collaborative filtering is matrix factorization. It is easiest understood as a form of dimensionality reduction.
Dimensionality Reduction
As an insufferable ninth grader, I took a bunch of Facebook quizzes during the 2008 U.S. presidential election cycle. These quizzes would ask a zillion questions about my personal political opinions, and then they would show me a Cartesian plane with two dimensions—social views and economic views—with a big dot somewhere that was supposed to represent me. There were also dots for the candidates, Barack Obama and John McCain; dots for insightful thinkers like Karl Marx, William F. Buckley, and Abraham Lincoln; and even a dot for Ayn Rand.
These people had all apparently taken the quiz, and, incredibly enough, the sum total of their lives could be reduced to just two numbers: their position on the “social” axis, and their position on the “economic” axis.
This magic trick is called dimensionality reduction.
What a feat! Political platforms probably have hundreds of dimensions, like taxation, immigration, energy, national security, climate change, and whether or not the candidate believes it is acceptable to drive to Canada with an Irish Setter tied to the roof of his car. But the ideology quiz reduced every politician to just two dimensions: “social” and “economic.” Working in this simplified two-dimensional space made it a lot easier to identify the politicians whose views most closely matched my own.
The matrix factorization technique for recommender systems involves a similar kind of dimensionality reduction, except that the algorithm learns the dimensions on its own.
In other words, matrix factorization is the real deal. It’s the stuff that separates true data scientists from charlatans — the data alchemists, data phrenologists, and data astrologers of the world.
Suppose that Amazon could somehow reduce the dimensionality of every item in its inventory down to, say, 50 factors. Both items and users could then be represented as weight vectors of length 50. Ideally, the factors would have interpretable meanings. So, to continue the Mozart example from above, maybe factor 32 represents “neurotic upper-middle-class American parent.” In that case, the 32nd weight of each user’s vector would quantify the degree to which that user is a neurotic upper-middle-class American parent. Likewise, the 32nd weight of each item’s vector would quantify the degree to which that item appeals to neurotic upper-middle-class American parents. (See an example item vector on the right.)
To predict any user’s rating for any item, we can just take the dot product between the user’s vector and the item’s vector.
I still have not explained how Amazon can use its user/item ratings data to learn a 50-dimensional vector representation of each item and of each user. Intuitively, learning these vectors is an optimization problem where the goal is to maximize the agreement between the user/item ratings that these vectors predict, and the user/item ratings that have been observed. More on this later.
Nor have I explained how Amazon can specify that factor 32 should be the “neurotic upper-middle-class American parent” factor. Actually, it can’t. The intuitive meaning of each factor is derived post hoc from vector representations of items and users, rather than the other way around. After the item and user vector representations have been generated, data scientists can look at the results, observe that the items with the highest weights for that factor are baby strollers and Mozart CDs, and conclude that this must be a “neurotic upper-middle-class American parent” factor.
This style of reasoning is called “extracting actionable insights.” It is the cornerstone of the data-scientific method that sets modern data science apart from earlier, barbaric, pseudo-data sciences.
The algorithm that learns these 50-dimensional representations does discover the factors, but it doesn’t name them. This algorithm is called matrix factorization. Why? Because it turns out that this task—learning low-dimensional vector representations for each item and for each user that are consistent with observed user ratings—can be viewed from another angle as a matrix completion problem.
The Matrix Completion View
Imagine that Amazon has a big, incomplete USERS x ITEMS
matrix.
The value in the (USER, ITEM)
square is the rating (say, from 1 to 5) that USER
gave to ITEM
.
If USER
hasn’t yet rated ITEM
, then the (USER, ITEM)
square is empty.
Indeed, most squares are empty.

The matrix factorization approach is to approximate the completed USERS x ITEMS
matrix as the product of a USERS x FACTORS
matrix and a FACTORS x ITEMS
matrix.
The number of factors is fixed in advance at, say, 50.
The values in these two individual matrices are carefully chosen such that the product of the two matrices (that is, the completed USERS x ITEMS
matrix, or the predicted user/item ratings) is mostly consistent with the incomplete USERS x ITEMS
matrix (that is, the observed user/item ratings).
Each row in the USERS x FACTORS
matrix is a 1 x 50
user vector that represents a single user’s preferences for each of the 50 factors.
Each column in the FACTORS x ITEMS
matrix is a 50 x 1
item vector that represents the breakdown of a single item into each of the 50 factors.
When these two matrices are multiplied together, the value at the (USER, ITEM)
location in the completed matrix is, by definition, the dot product of USER
’s user vector and ITEM
’s item vector, which, as we have already seen, is a measure of USER
’s preference for ITEM
!
As discussed in the preceding section, factorizing the incomplete USERS x ITEMS
matrix is an optimization problem where the goal is to minimize some metric of difference between the incomplete USERS x ITEMS
matrix (the observed ratings) and the completed USERS x ITEMS
matrix (the predicted ratings).
We will also add a non-negativity constraint: every value in the multiplicand and multiplier matrices should be greater than or equal to zero.
This constraint makes the factors more interpretable.
There are a number of algorithms in the literature for non-negative matrix factorization. Below, we use the iterative method described here. The algorithm uses “multiplicative update rules” to minimize a metric called the KL divergence which measures the difference between the two matrices.
Anyway, enough about Amazon. The rest of this post will focus on an application of matrix factorization to a domain—possibly the only domain—that is more central to my life than the online purchase of consumer products.
Matrix Factorization and Food
I took an introductory machine learning course from David Blei in Spring 2014. For the final project, a few classmates and I decided to build a recommender system for foods. Our recommender system itself turned out to be pretty mediocre, but we got interesting factors to fall out of matrix factorization.
We scraped our data set from AllRecipes.com, a popular recipe-sharing web site. With tens of thousands of recipes and over a hundred thousand users, AllRecipes is a gold mine for food data. Each AllRecipes user has a recipe box where he or she can list his or her favorite recipes. It was these recipe boxes that we scraped. After throwing away all recipes that occurred in fewer than 300 recipe boxes, we were left with 9,546 recipes and 115,308 users. All users collectively had 9.6 million recipes in their recipe boxes.
We experimented with two different approaches to the problem of recipe recommendation: a content-based method using only information about the ingredients in each recipe, and a collaborative filtering method using only data about user-recipe preferences.
The content-based method was straightforward: represent each recipe as a vector of all ingredients in the “kitchen,” where the value at each element is the mass fraction that the corresponding ingredient takes up in the recipe. To measure the similarity between two recipes, take the cosine similarity between their vectors. This approach worked fine, but I’ll ignore it for the remainder of this post.
The collaborative filtering method was far more interesting because it didn’t know anything at all other than which users liked which recipes.
We represented the user-recipe preference data as a 115,308 x 9,546
user-by-recipe matrix with a 1 in every square where the corresponding user had the corresponding recipe in his/her recipe box, and a 0 everywhere else.
Then we factorized the user-by-recipe matrix, using 40 factors, into a 115,308 x 40
user-by-factor matrix and a 40 x 9,546
factor-by-recipe matrix.
We used the MATLAB NMF toolbox to perform non-negative matrix factorization. The NMF algorithm took 8 hours to complete 2,000 iterations on a machine with a 2.2GHz processor and 128 GB RAM.
Sure enough, after eight hours of compute time, the factors produced by non-negative matrix factorization really did seem to correspond to human tastes!
To clarify, each row in the user-by-factor matrix is a 1 x 40
vector that represents a single user’s preference for each of the 40 factors.
And each column in the factor-by-recipe matrix is a 40 x 1
vector that represents the decomposition of a single recipe into its constituent factors.
I will explore three different ways to play around with the data generated by the factorization:
- First, we can ask questions like: "What does factor #3 really represent?" The easiest way to find out is to look at the dishes with the highest weights in factor #3. The top ones are Quinoa and Black Beans, Baked Kale Chips, and Quinoa Side Dish. In this example, we could conclude that factor #3 represents vegan food.
- Second, we can ask questions like: "Which factors does the dish Butter Chickpea Curry consist of, and in what proportions?" Answering this question is as simple as looking up the row for Butter Chickpea Curry in the factors-by-recipe matrix produced by NMF. Use the Taste Breakdown visualization tool below to view the factor breakdown of any recipe. Apparently, Butter Chickpea Curry is 62% vegetarian, 34% Indian food, and 4% random noise.
- Third, we can ask questions like "What food would we get if we smashed together the 'vegetarian' factor and the 'cookies/brownies' factor?" To find out, we can sort all recipes in decreasing order of cosine similarity to a made-up recipe vector with `0.5` in the 'vegetarian' position and `0.5` in the 'cookies/brownies' position. The Mix 'n Match visualization tool below allows you to make such queries. The answer, in this instance, is apparently "Vegan Brownies."
The Tastes
These are the 40 tastes that came out of the matrix factorization. We describe each taste by printing the five exemplar recipes with the highest weights.
A few observations:
-
Some tastes correspond to food groups, like seafood (taste 4), bread (taste 24), salad (taste 12), and beverages, both alcoholic (taste 22) and non-alcoholic (taste 23).
-
Other tastes correspond to dietary preferences, like vegan (tastes 3, 10) and barbecue (taste 31).
-
Still others correspond to national holidays, like Thanksgiving (taste 32) and Superbowl (taste 7).
-
In a sure sign that AllRecipes users have their priorities straight, a large plurality of tastes are used to differentiate between subtly different kinds of desserts, such as cake (taste 8), cheesecake (taste 19), fruit pastries (tastes 16, 18, 25), sugary cookies (taste 9), chocolatey cookies (taste 35), confections (taste 38), scones / biscotti (taste 40), and fancifully nutritious desserts (taste 11).
-
Taste 6 is entirely devoted to slow-cooker foods, and taste 39 is nothing but casserole. I fear that AllRecipes.com may be one place, along with the Social Security budget committee, where the nation’s grandmothers hold too much influence.
-
Taste 28 corresponds to Indian / Thai food. I was faintly surprised that no other ethnic cuisines came out of the factorization, although I suppose taste 39 might qualify as Mexican, and taste 27 has a definite German flair.
-
Taste 13 comprises dishes—macaroni and cheese, meat loaf, lasagna, potato salad—that can only be described as “comfort food.” This took me by surprise. I had always assumed that the concept of “comfort food” as a distinct class of foods was a mere figment of Paula Deen’s imagination, sort of like the concept of “bacon biscuits deep fried in butter that don’t give you diabetes.”
-
Most of the remaining tastes correspond to chicken in various states of matter.
Taste Breakdown
This interactive tool gives the taste breakdown of 9,000 or so recipes from AllRecipes.com.
To pull up the taste breakdown for any food, just start typing the name of the food into the search bar, and then click on one of the recipes that will pop up in the autocomplete box.
Clicking on any of the example recipes that appear will pull up their taste breakdowns.
To share the link to a taste breakdown that catches your interest, right click the permalink icon and select “Copy Link Address” in your browser.
Here are some intuitions that were borne out by the matrix factorization:
-
Naan is a combination of Indian food (taste 28), bread (taste 24), and vegetarian food (taste 10).
-
Blueberry Waffles with Fast Blueberry Sauce is mix of fruit desserts (taste 25), breakfast foods (taste 34), and granola (taste 11).
-
Butter Chickpea Curry is a cross between vegetarian food (taste 10), and Indian food (taste 28).
-
Cedar Planked Salmon is part seafood (taste 4) and part barbecue (taste 31).
-
Coq Au Vin is popular among people who also like both alcoholic beverages (taste 22) and chicken (taste 14).
Mix ‘n Match
This interactive tool lets you mix and match tastes! Select two or three tastes from the two-column list below, and see which recipes most closely match the combined taste profile.
If you’re out of ideas, try mixing alcoholic beverages with sugar cookies, slow cooker with barbecue, or biscotti with breakfast foods.
Data
Code and data are available on Github.
Hacker News
Read the discussion on Hacker News.
Thanks for Reading
This post describes a project carried out for David Blei’s course “COS 424: Interacting with Data” in Spring 2014 at Princeton University by Rob Sami (now Google), Aaron Schild (now Berkeley), Spencer Tank (now Palantir), and me.
Thanks to Charles Guo, Charlie Marsh, Lucas Mayer, Shubhro Saha, and Jacob Simon for reading drafts of this post.


Asynchronous Server Application Boilerplate’s documentation¶
Asynchronous Server App Boilerplate (or ASAB for short) is a microservice platform for Python 3.7+ and asyncio. ASAB aims to minimize the amount of code that needs to be written when building a microservice or an application server. ASAB is fully asynchronous using async/await syntax from Python 3, making your code modern, non-blocking, speedy and hence scalable. We make every effort to build ASAB container-friendly so that you can deploy ASAB-based microservice via Docker or Kubernetes in a breeze.
ASAB is free and open-source software, available under BSD licence. It means that anyone is freely licenced to use, copy, study, and change the software in any way, and the source code is openly shared so that people could voluntarily improve the design of the software. Anyone can (and is encouraged to) use ASAB in his or her projects, for free. A current maintainer is a TeskaLabs Ltd company.
ASAB is developed on GitHub. Contributions are welcome!
ASAB is designed to be powerful yet simple¶
Here is a complete example of a fully working microservice:
import asab
class MyApplication(asab.Application):
async def main(self):
print("Hello world!")
self.stop()
if __name__ == "__main__":
app = MyApplication()
app.run()
ASAB is the right choice when¶
using Python 3.7+.
building the microservice or the application server.
utilizing asynchronous I/O (aka asyncio).


| YTD Performance | Previous Year | Current Year | |||||
| Region | Est. Market | Revenue | Volume | Market Share | Revenue | Volume | Market Share |
|---|---|---|---|---|---|---|---|
| AR | $2M | $0.80M | 5000 | 40% | $0.70M | 4000 | 35% |
| CA | $3M | $0.30M | 3000 | 17% | $0.40M | 2000 | 13% |
| CO | $2M | $1.20M | 7000 | 60% | $1.30M | 8000 | 65% |
| Promo | Net ROI | Sales Units |
|---|---|---|
| V Day | 1 | 8000 |
| Gifting Day | 1 | 8000 |
| Womens Day | 1 | 8000 |


{% extends "_summary_layout.html" %} {% block content %}
Use the "" button to reorder a task , and “” to remove a task
Inserted task are placed at the bottom of the timeline.
Drag and drop to the appropriate location after insertion.
A change to {{ sessionDoc.procedureDetails.procedure_name }} has been detected.
Save your changes back to the GitLab repository.


The following is the list of topics which our group is addressing.
The number on the right indicates the current prioritization of the given topic, with a lower number meaning a higher priority. The links will take you to the list of issues () and the page of examples () on that topic.
The "status" field gives a link to either the final recommendations page, or the draft recommendations page on the GitHub wiki.
| Priority | Topic | Description | Links | Status | See also |
|---|
Details
The data for this page comes from this YAML file. If you'd like to suggest changes, please go there and click the "edit" button.
We use the following conventions:
- Topic names are lowercase, hyphen-delimited
- GitHub issue labels that correspond to topics match the topic names exactly, and therefore begin with a lowercase letter. Those that don't (e.g. "Duplicate") begin with an uppercase letter.


This example displays a directional reference frame around the camera in Cartesian coordinates, using the EastUpSouth orientation for positive (x, y, z). A userLocation geospatial entity is created and positioned at the position of the user, and updated when the user's position changes. It uses HTML elements to put a text label at 200 meters in each of the negative/positive directions: x is west/east; y is down/up; z is north/south.


Students can eat subsidised student meals at the student cafeterias around the campus area. The state subsidises a part of the cost of each student lunch. The student lunch includes: portion of food, glass of drink, salad and bread. Students can eat subsidised student meals 2,60 euros at the student cafeterias around the campus area by showing valid student card. The state subsidises a part of the cost of each student lunch.
Students can eat subsidised student meals at the student cafeterias around the campus area. The state subsidises a part of the cost of each student lunch. The student lunch includes: portion of food, glass of drink, salad and bread. Students can eat subsidised student meals 2,60 euros at the student cafeterias around the campus area by showing valid student card
Students can eat subsidised student meals at the student cafeterias around the campus area. The state subsidises a part of the cost of each student lunch. The student lunch includes: portion of food, glass of drink, salad and bread. Students can eat subsidised student meals 2,60 euros at the student cafeterias around the campus area by showing valid student card


Last workday of the year abruptly truncated by trip to children's hospital for Asher's croup. Out now though. Home to rest up.
12/20/2013, 11:51:47 AM
Favs: 0
Retweets: 0
link--- layout: tweet ---
Last workday of the year abruptly truncated by trip to children's hospital for Asher's croup. Out now though. Home to rest up.
12/20/2013, 11:51:47 AM
Favs: 0
Retweets: 0
link


Mix Of The Day: DJ Bus Replacement Service
Recorded live at Dekmantel Selectors 2019.
by Resident AdvisorHere's two hours of DJ Bus Replacement Service playing live in Croatia. You already know it's gonna be bananas.
Here's two hours of DJ Bus Replacement Service playing live in Croatia. You already know it's gonna be bananas.


cl-uglify-js – JavaScript compressor/beautifier for Common Lisp
This is a Common Lisp version of UglifyJS. It works on data produced by parse-js to generate a “minified” version of the code. Currently it can:
- reduce variable names (usually to single letters)
- join consecutive var statements
- resolve simple binary expressions
- group most consecutive statements using the “sequence” operator (comma)
- remove unnecessary blocks
- convert IF expressions in various ways that result in smaller code
- remove some unreachable code
It's faster than YUI Compressor, Google Closure and UglifyJS, and almost as good as (and a bit safer than) Google Closure in terms of compressed code size.
See the UglifyJS page for more information.
Table of Contents
1 Dependencies
I only tested it on SBCL.
2 API
The following functions are exported:
2.1 ast-squeeze (ast &key (sequences T) (dead-code T))
Applies various compression techniques. It expects an AST (as returned by parse-js) and returns a new, compatible AST (possibly sharing structure with the original one!).
Optional keyword arguments:
-
sequences
(defaultT
) — set this toNIL
to disable grouping consecutive statements into a sequence using the “comma operator”. -
dead-code
(defaultT
) — if you passNIL
it will not attempt to remove unreachable code.
When it encounters unreachable code and dead-code
is true, this function
will warn
about it. The warnings go to *error-output*
, so rebind that
if you want to catch the messages.
2.2 ast-mangle (ast &key toplevel)
“Mangles” variable names (renames all variables to shorter version). This function is careful not to affect the semantics of the code. It will avoid renaming undeclared variables (which could possibly be defined in some other script), and avoid renaming names that are under the influence of a with block, or within the context of an eval call.
Optional keyword arguments:
-
toplevel
(defaultNIL
) — pass true here if you want to mangle the toplevel scope. By default we don't.
Note that this function returns a somewhat incompatible AST. Literal names
(which are normally strings) are replaced with lambda-s that would return
the mangled version. ast-gen-code
knows how to deal with this.
2.3 ast-gen-code (ast &key (beautify T) (indent-level 4) (indent-start 0) quote-keys)
Given an abstract syntax tree, this function returns the corresponding JavaScript code (as a string).
Optional keyword arguments:
-
beautify
(default true). By default ast-gen-code returns nicely indented code. If you want to compress, pass:beautify NIL
.
The other arguments only make sense if beautify
is true:
-
indent-level
: number of spaces to use for indentation. Note that case/default statements are indented to half of this number, so better pass an even one. -
indent-start
: the whole code will be indented by this number of spaces (default 0). -
quote-keys
: by default, we only quote keys that cannot be used otherwise (i.e. reserved words such as "while"). Pass this true to quote all keys regardless.
2.4 split-code (code &optional (maxlen (* 32 1024)))
Given `code' (a string) it will split it by adding a newline every `maxlen' (or so) characters. I found both Firefox and Chrome croak with weird errors when the whole code was on a single 680K line, so even if it adds a few more bytes this step should be done for safety. The default `maxlen' is 32K.
3 Compress one file
To compress one file, you would do something like this:
(ast-gen-code (ast-mangle (ast-squeeze (with-open-file (in "/path/to/file.js") (parse-js:parse-js in)))) :beautify nil)
Some simplified API will be available at some point, though I'm not sure it would be really useful.
4 License
Copyright 2010 (c) Mihai Bazon<EMAIL_ADDRESS>This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution.
Date: 2011-01-24 00:09:50 EET
HTML generated by org-mode 7.01trans in emacs 23


{% extends "base.html" %} {% load simple_comment_tags %} {% block content %}
Published {{ article.pub_date|timesince }} ago.
{% comment_configuration for "articles" article as "configuration" %} {% comment_list for "articles" article as "comment_list" %}No comments.
{% endfor %}
Posted by {{ comment.author_name }}, {{ comment.pub_date|timesince }} ago.


My name is Bruno Harbulot. My home page is here. I am interested in a number of topics:
This page contains RDFa markup and can be used as a foaf+ssl foaf file.


--- layout: single title: "Publications" permalink: /publications/ author_profile: true --- {% include base_path %} {% if site.author.googlescholar %} You can also find my articles on my Google Scholar profile. {% endif %}
Maxime Baudette is a PhD student in the Electric Power and Energy Systems Department at the KTH Royal Institute of Technology, Stockholm, Sweden. He received the MSc degree in Electrical Engineering from KTH (Sweden) and Supélec (France) in 2013. Maxime is a member of the Smart Transmission System Laboratory (SmarTS-Lab) research group at KTH under the supervision of Luigi Vanfretti. He has keen interest in open source software, power system modeling and simulation (also Real-Time simulation), Hardware-in-the-Loop (HIL) approach, Wide-Area Monitoring Systems (WAMS).


import uuid
from typing import Optional, Dict, List, Type
from .._errors import SpanError
[docs]class APIError(SpanError):
"""Base error returned by SpanAPI in http responses. Must have a unique code."""
http_code: int = 501
api_code: int = 1000
def __init__(
self,
message: str,
error_data: Optional[dict] = None,
error_id: Optional[uuid.UUID] = None,
send_media: bool = False,
):
"""
Base error returned by SpanAPI in http responses. Must have a unique code.
:param message: Message to be sent back to client.
:param error_data: JSON data to be encoded in headers.
:param error_id: Assigned uuid for error.
:param send_media: Whether to attempt to send a json payload in the response.
"""
super().__init__(message)
if error_id is None:
error_id = uuid.uuid4()
self.error_data: Optional[dict] = error_data
self.id: uuid.UUID = error_id
self.send_media: bool = send_media
[docs]class InvalidMethodError(APIError):
"""Invalid method requested from endpoint"""
http_code: int = 405
api_code: int = 1001
[docs]class NothingToReturnError(APIError):
"""No Data to Return"""
http_code: int = 400
api_code: int = 1002
[docs]class RequestValidationError(APIError):
"""Request Data Does not match schema"""
http_code: int = 400
api_code: int = 1003
[docs]class APILimitError(APIError):
"""Too many items for batch request"""
http_code: int = 400
api_code: int = 1004
[docs]class ResponseValidationError(APIError):
"""Server encountered error while validating response."""
http_code: int = 400
api_code: int = 1005
ERRORS_LIST: List[Type[APIError]] = [
APIError,
InvalidMethodError,
NothingToReturnError,
RequestValidationError,
APILimitError,
ResponseValidationError,
]
"""List of all APIError Classes"""
ERRORS_INDEXED: Dict[int, Type[APIError]] = {e.api_code: e for e in ERRORS_LIST}
"""All APIError exceptions indexed by their api error code."""


High innovation countries publish
3x
more scientific publications
High innovation countries spend
4x
more in R&D
Low innovation countries have mortality rate
14x
higher than high innovation countries
GDP in high innovation countries is
6x
higher than medium innovation and
34x
higher than low innovation countries
High innovation countries produce
2x
more feature films
High innvoation countries have
5x
more broadband subscriptions than medium and
175x
more than low innovation countries
30%
more people in high innovation countries are employed in cultural occupations
Literacy rate is
47%
higher in high and medium innovation countries than low innovation countries


Release of Litepaper version 1.0
lack of liquidity is a long standing issue in the Cryptocurrency trading market, this has made many investors and arbitrageurs to stay away from the crypto market.
FLUID and FLUIDGold token are FLUID PROTOCOL utility tokens utilizing the ER20 standard,FLUID act as the primary fungible token for processing of transaction while FLUIDGold token acts as a staking reward for FLUID.
$FLUID supports cross-chain capabilities and is deliberately built in a way that allows new block chains to integrate in to the system in the future.
Designed to reward it users with 4% of the user’s holdings per annum. The distribution will be done automatically 2% for every 182days. Meaning for every 182days you hodl FLUID in FLUID WALLET you receive 2% increase in the number of tokens held.
Do not send funds via exchange to avoid lost of funds.
STEP 1: Copy the token wallet address 0xbB899936E74e916571C4E4501eDDF0fc7B4725Cc to your wallet (MyEtherWallet,MetaMask,Trust Wallet etc).
STEP 2: Select the amount you want to transfer.
STEP 3: Select apppropraite gas for the transaction.
STEP 4: Add token contract address (0xaa4789f349519994a6C4D1f75Ff612dfe95A37DB) to your wallet.
Release of Litepaper version 1.0
Website Launch
Private/OTC sales
Release of Litepaper version 1.1
Wallet launch(Beta version)
Trading competition(Uniswap)
Listing on other Exchange
Official Wallet Launch


Return the English plural form for a number.
Plural forms in English are the singular with an ‘s’ appended, or the plural form.
Base class to return the plural form of a number. Sub-classed for specific languages.
Return the dual form for a number. (In this default class, it is just the singular form if a plural form isn’t specified).
Return the indefinite article for this noun (i.e. a or an).
Actually, returns ‘’ or ‘n”, as this allows format strings to be written as “a{n}”.
Return the multiple form for a number. (In this default class, it is just the dual form).
Return the appropriate singular/plural form.
Note the special case. If singular is blank, always return blank.
Return the singular form for a number.


The goal of this content is to provide A good foundational understanding of Oracle SQL for querying databases to get you at a level to perform analysis on data.
It won't cover management of data within databases, or any way to automate your scripts and code, that is beyond the scope of this content.
A free software produced by Oracle it has a basic and clean interface but more complex features for power users.
An alternative SQL IDE, a license is required for usage.
SQL is just instructions that are sent to the database, so you can edit that plain text code in any text editor, and many tools offer database connections, including VSCode, RStudio, and many more!
A comment is the most important thing in any language.
They let you write notes in and around your code that the computer ignores.
A comment is the most important thing in any language.
They let you write notes in and around your code that the computer ignores.
-- Comments in SQL are done like this
A comment is the most important thing in any language.
They let you write notes in and around your code that the computer ignores.
-- Comments in SQL are done like this
/* Or multi-line comments
are done like this */
A comment is the most important thing in any language.
They let you write notes in and around your code that the computer ignores.
-- Comments in SQL are done like this
/* Or multi-line comments
are done like this */
select * from table; -- you can comment at the end of a line
select * /* or even in the middle*/ table;
Keywords in SQL are case insensitive so you can type them however you like.
Keywords in SQL are case insensitive so you can type them however you like.
SELECT ORIGIN, DEST FROM FLIGHTS;
Keywords in SQL are case insensitive so you can type them however you like.
Whiteshape is also ignored in SQL, so you can layout your code however you like.
SELECT ORIGIN, DEST FROM FLIGHTS;
Keywords in SQL are case insensitive so you can type them however you like.
Whiteshape is also ignored in SQL, so you can layout your code however you like.
SELECT ORIGIN, DEST FROM FLIGHTS;
select
origin,
dest
from
flights;
However, being consistent and making your code easy to read is important.
SELECT ORIGIN, DEST FROM FLIGHTS;
select
origin,
dest
from
flights;
However, being consistent and making your code easy to read is important.
/* Three equivalent queries despite case and whitespace */
SELECT ORIGIN, DEST FROM FLIGHTS;
select
origin,
dest
from
flights;
SeLeCt OrIgIn,DeSt fRoM fLiGhTs;
Error messages try to tell you what you've done wrong in your code when it doesn't work.
Learning to read them and understand what they mean is invaluable, and we will see some as we go through.
Finally, empty values in SQL have a special type call null.
This isn't an empty string or 0 or NA, it is a special thing all by itself.
When you write a query, you are asking the database to produce you a table. This table need to have columns, so we need to tell the database which variables we need.
Some of these variables might already exist, some might need to be created - we'll learn how to do both.
All SQL queries take the following minimum form.
SELECT
variables
FROM
DATABASE.SCHEMA.TABLE;
All SQL queries take the following minimum form.
Every query has a FROM keyword followed by a reference to a table, this tells the database where to look for our variables.
SELECT
variables
FROM
DATABASE.SCHEMA.TABLE;
All SQL queries take the following minimum form.
Every query has a SELECT keyword followed by list of variables; these might be existing columns in the table or ones created.
SELECT
variables
FROM
DATABASE.SCHEMA.TABLE;
All SQL queries take the following minimum form.
Every query ends with a semi-colon. This is like a full stop for the database so it knows where one query stops and the next one begins.
SELECT
variables
FROM
DATABASE.SCHEMA.TABLE;
We can select every variable from our table using the * special character.
SELECT
*
FROM
schema_name.flights;
We can select every veriable from our table using the * special character.
Or we can swap out the * and list the column names ourselves, seperated by a comma
SELECT
*
FROM
schema_name.flights;
Or we can swap out the * and list the column names ourselves, seperated by a comma
SELECT
year,
month,
day,
dep_time,
sched_dep_time,
dep_delay,
arr_time,
sched_arr_time,
arr_delay,
carrier,
flight,
tailnum,
origin,
dest,
air_time,
distance,
hour,
minute,
time_hour
FROM
schema_name.flights;
Or we can just select some of them
SELECT
year,
month,
day,
dep_time,
sched_dep_time,
carrier,
flight,
tailnum,
origin,
dest
FROM
schema_name.flights;
Run some of these queries so far and see the results.
We can ask the database for variables that aren't in our table, we just need to tell it what the data is. In this case, that data is the value 123.
SELECT
year,
month,
day,
dep_time,
sched_dep_time,
carrier,
flight,
tailnum,
origin,
dest,
123
FROM
schema_name.flights;
Note that we had to add a comma to the end of the list before our new variable.
It would be nice to give this variable a name, we can do that using the as keyword and call it whatever we like (within reason). This is known as aliasing.
SELECT
year,
month,
day,
dep_time,
sched_dep_time,
carrier,
flight,
tailnum,
origin,
dest,
123 as new_column
FROM
schema_name.flights;
Column names should start with a letter, have only _ as punctuation and be less than 30 characters long. Some of these rules can but should not be broken.
Technically we don't need to use as but for column names it is good practice.
SELECT
year,
month,
day,
dep_time,
sched_dep_time,
carrier,
flight,
tailnum,
origin,
dest,
123 new_column
FROM
schema_name.flights;
We'll see in a second you can alias a table as well, but you cannot use the as word there!
Run some of these queries so far and see the results.
NOTE that we can't mix * and extra variables.
-- This code will error
SELECT
*,
123 as new_column
FROM
schema_name.flights;
NOTE that we can't mix * and extra variables.
This is because * doesn't mean everything from our table, it means EVERYTHING, and we can't ask for more than everything (it's like taking infinity+1).
-- This code will error
SELECT
*,
123 as new_column
FROM
schema_name.flights;
What we need to do it tell the database we want everything from the table and note the universe. So first, it's important to understand the following are the same query, one is shorthand for the other.
SELECT
tailnum
FROM
schema_name.flights;
SELECT
schema_name.flights.tailnum
FROM
schema_name.flights;
So if we want everything from the table, we could write the following, and this will work, but is pretty annoying to type.
SELECT
schema_name.flights.*,
123 as new_column
FROM
schema_name.flights;
So if we want everything from the table, we could write the following, and this will work, but is pretty annoying to type.
What if the same way we aliased columns we alias our table? Let's call it a
SELECT
a.*,
123 as new_column
FROM
schema_name.flights a;
SIDENOTE: You can break some of those column name rules using double quotes ("), these are used when you talk about database objects (tables, columns etc). Use single quotes (') for text data in the database.
SELECT
a.*,
123 as "new column"
FROM
schema_name.flights a;
Run some of these queries so far and see the results.
Attempt questions 1-4.
Having a column with all the same value isn't really that useful.
Let's create create some variables using existing ones next.
From now on for simplicity we will only show the relevant parts of the code, not all the variables as shown in the training file.We can start by doing some basic maths on a numeric column.
SELECT
month,
month + 1 AS next_month,
...
FROM
schema_name.flights;
We can start by doing some basic maths on a numeric column.
We don't even have to keep the original column.
SELECT
month + 1 AS next_month,
...
FROM
schema_name.flights;
We CAN'T use our new column in another calculation (we'll see way to do this later).
-- This code will error
SELECT
month + 1 AS next_month,
next_month + 1 AS next_next_month
...
FROM
schema_name.flights;
Now let's take a look at some string functions that will be useful for when we're working with text.
SELECT
carrier,
...
FROM
schema_name.flights;
lower takes a string and makes it lowercase.
SELECT
carrier,
lower(carrier),
...
FROM
schema_name.flights;
upper takes a string and makes it uppercase.
SELECT
carrier,
lower(carrier),
upper(lower(carrier)),
...
FROM
schema_name.flights;
Notice how we've nested functions here, this is a useful trick.
substr takes 3 arguments, the first 2 are required and are the string to cut and the start position. The third argument is optional and is the length of the substring.
SELECT
carrier,
lower(carrier),
upper(lower(carrier)),
tailnum,
substr(tailnum, 3),
substr(tailnum, 1, 3),
substr(tailnum, 3, 2),
...
FROM
schema_name.flights;
This is like LEFT, MID, and RIGHT from Excel all in one.
length tells you have many characters are in a string.
SELECT
carrier,
lower(carrier),
upper(lower(carrier)),
tailnum,
substr(tailnum, 3),
substr(tailnum, 1, 3),
substr(tailnum, 3, 2),
length(tailnum)
...
FROM
schema_name.flights;
Run some of these queries so far and see the results.
Attempt questions 5-7.
Sometimes we don't want to do the same thing to every record, we might want to do different calculations based on some conditions.
We do this by something called a case statement.
Case statements take this form:
CASE
WHEN condition THEN value_1
WHEN condition THEN value_2
...
WHEN condition THEN value_n
ELSE value_default
END
Case statements take this form:
CASE
WHEN condition THEN value_1
WHEN condition THEN value_2
...
WHEN condition THEN value_n
ELSE value_default
END
Case statements take this form:
CASE
WHEN condition THEN value_1
WHEN condition THEN value_2
...
WHEN condition THEN value_n
ELSE value_default
END
Case statements take this form:
CASE
WHEN condition THEN value_1
WHEN condition THEN value_2
...
WHEN condition THEN value_n
ELSE value_default
END
Case statements take this form:
CASE
WHEN condition THEN value_1
WHEN condition THEN value_2
...
WHEN condition THEN value_n
ELSE value_default
END
REMEMBER: every CASE must have an END and every WHEN must have a THEN.
CASE
WHEN condition THEN value_1
WHEN condition THEN value_2
...
WHEN condition THEN value_n
ELSE value_default
END
To write these boolean/logical tests we use comparison operators like the following:
| Symbol | Comparison |
|---|---|
| = | Equal |
| !=, <>, ^= | Unequal (not equal) |
| <, <= | Less than, Less than or equal to |
| >, >= | Greater than, Greater than or equal to |
| [NOT] IN | Set membership (is the element in the set/list provided). Set provided in ('Elem1', 'Elem2', ..., 'ElemN') format |
| [NOT] LIKE | Pattern match (is the element like the provided pattern). Uses % as 0-Inf character wildcard, _ for single character wildcard |
| [NOT] BETWEEN | Shorthand for x <= y and y <= z becomes y between x and z |
And we can combine them using the logical operators:
| Operation | Meaning |
|---|---|
| AND | |
| OR | |
| NOT | |
| () |
| A | B | A AND B | A OR B | NOT A |
|---|---|---|---|---|
| TRUE | TRUE | TRUE | TRUE | FALSE |
| TRUE | FALSE | FALSE | TRUE | - |
| FALSE | TRUE | FALSE | TRUE | TRUE |
| FALSE | FALSE | FALSE | FALSE | - |
And we can combine them using the logical operators:
| Operation | Meaning |
|---|---|
| AND | Logical AND, both statements must be TRUE |
| OR | Logical OR, at least one statement must be TRUE |
| NOT | Logical negation, converts TRUE to FALSE and vice versa |
| () | Brackets, force the evaluation of the logical statement inside before any outside, i.e. (2+7)*5 != 2+7*5 |
Let's look at some examples
CASE
WHEN sched_dep_time < 1200 THEN 'AM'
ELSE 'PM'
END AS DEP_AM_PM,
CASE
WHEN sched_dep_time BETWEEN 0 AND 0800 THEN 'Early Morning'
WHEN sched_dep_time BETWEEN 0801 AND 1159 THEN 'Morning'
WHEN sched_dep_time BETWEEN 1200 AND 1800 THEN 'Afternoon'
WHEN sched_dep_time BETWEEN 1801 AND 2100 THEN 'Evening'
WHEN sched_dep_time BETWEEN 2100 AND 2359 THEN 'Night'
END AS DEP_TIME_DETAIL, -- Notice no ELSE
CASE
WHEN length(sched_arr_time) != 4 THEN 'AM'
WHEN substr(sched_arr_time, 1, 2) < 12 THEN 'AM'
WHEN substr(sched_arr_time, 1, 2) > 12 THEN 'PM'
ELSE 'Midday'
END AS ARR_AM_PM,
...
Now examples using in
CASE
WHEN dest in ('JFK', 'LGA', 'EWR') THEN 'NYC'
ELSE 'Other'
END AS dest_nyc_check_in,
-- see how much easier it is than writing ors
CASE
WHEN dest = 'JFK' or dest = 'LGA' or dest = 'EWR' THEN 'NYC'
ELSE 'Other'
END AS dest_nyc_check_ors
...
Notice that comparisons always have to have a left and a right hand side, even when it's the same LHS
String values are case sensitive
CASE
WHEN origin in ('JFK', 'LGA', 'EWR') THEN 'NYC'
ELSE 'Other'
END AS origin_nyc_check1,
CASE
WHEN lower(origin) in ('JFK', 'LGA', 'EWR') THEN 'NYC'
ELSE 'Other'
END AS origin_nyc_check2,
CASE
WHEN origin in ('JFK', 'lga', 'ewr') THEN 'NYC'
ELSE 'Other'
END AS origin_nyc_check3
...

-- Any number of character (including 0) before, and after a 7
CASE
WHEN tailnum LIKE '%7%' THEN 1
ELSE 0
END AS contains_7,
-- Any number of characters before a capital Q
CASE
WHEN tailnum LIKE '%Q' THEN 1
ELSE 0
END AS ends_in_q,
-- A NOT acting on the output of a logical statement
CASE
WHEN NOT (tailnum LIKE '%Q') THEN 1
ELSE 0
END AS ends_in_not_q,
-- A NOT LIKE, specifically any record that doesn't match the pattern,
-- slightly different to above
CASE WHEN tailnum NOT LIKE 'N5_5%' THEN 1
ELSE 0
END AS weird_test
...
Run some of these queries so far and see the results.
Attempt questions 8-11.
Finally let's look at dates in Oracle SQL.
Date data types include both a date and a time, there is no time only value in Oracle.
There is another type called a timestamp that contains milliseconds and timezones, most functions that work on dates also work on timestamps.
Just like in Excel, dates in Oracle are just numbers - meaning a difference of 24 hours is 1, 12 hours is 0.5 etc.
However unlike excel because they are a specific datatype there's some specific functions to work with them.
| Function | Description |
|---|---|
| TO_DATE(variable, fmt) | Converts the variable (or string) into a date by giving it the format the variable is in |
| TRUNC(date [, fmt]) | Sets the time component of the date to 00:00:00 by default, or will round down to the format if provided |
| sysdate | A system variable that is the current (local) date and time |
| NEXT_DAY(date, day) | Returns the next date of the given day, after the date provided e.g. takes a Saturday at 00:00:01 to the NEXT Saturday |
| TO_CHAR(variable, fmt) | Converts the variable (usually a date or a number) into the given format. This is the method to format a date in a given way NOT substr |
| EXTRACT(value FROM date) | Returns the given value e.g. year from the date and returns it as a number. To extract units less than a day you must use a timestamp |
| TO_TIMESTAMP(variable, fmt) | Converts the variable (or string) into a timestamp by giving it the format the variable is in |
SELECT
time_hour,
time_hour + 1, -- add 1 day
time_hour + 5/24/60, -- add 5 minutes
TRUNC(time_hour), -- set time component to 0
TRUNC(time_hour, 'MM'), -- set to first of month
NEXT_DAY(time_hour, 'Saturday') - 1, -- Set to Friday inclusive for a week
TO_CHAR(time_hour, 'HH24:MI DAY DD MONTH YYYY'), -- format date in a specific format
TO_CHAR(time_hour, 'HH24:MI Day dd month yyyy'), -- notice how case changes the output
-- convert our columns into a date
TO_DATE(year||'-'||month||'-'||day||' '||hour||':'||minute, 'YYYY-MM-DD HH24:MI') -- convert our columns into a date
FROM
schema_name.flights;
Using TO_DATE every time can be annoying, so we can specify a date in another way. This is easier to read and more efficient for the database as well.
SELECT
DATE '2019-01-20' AS fixed_date
FROM
schema_name.flights;
The format is ALWAYS YYYY-MM-DD and is a string.
You should NEVER use substr on a date because the result you gets depend on how the user has their system set up.
-- Set a specific date format for your local session and sub-string our dates
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MM-YYYY HH24:MI:SS';
SELECT
time_hour,
substr(time_hour, 9, 2)
FROM
schema_name.flights;
-- returns 2 digit year
-- Change the format and check the results
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-DD-MM HH24:MI:SS';
SELECT
time_hour,
substr(time_hour, 9, 2)
FROM
schema_name.flights;
-- returns 2 digit month
Always use to_char instead.
Run some of these queries so far and see the results.
Attempt questions 12-15.
We will start by learning how to filter records, we do this using a WHERE clause, which goes after the FROM clause.
SELECT
columns
FROM
tables
WHERE
condition
;
The condition in this clause is the same type as those we saw in the CASE statements.
Let's take a look at some examples:
SELECT
*
FROM
schema_name.flights
WHERE
arr_delay = 0
AND dep_delay = 0
;
Let's take a look at some examples:
Bonus tip: You can use an always true condition to make it easier to comment out individual checks when you're still developing your code
SELECT
*
FROM
schema_name.flights
WHERE
1 = 1
--AND arr_delay = 0
AND dep_delay = 0;
;
Let's take a look at some examples:
and of course we can use our favourite boolean logic!
SELECT
*
FROM
schema_name.flights
WHERE
1 = 1
-- flights scheduled to depart in the first 10 or last 5 hours of a day
AND (hour < 10 OR hour > 19)
AND dep_delay = 0 -- left on time
;
Let's take a look at some examples:
A reminder that we can use IS [NOT] NULL as a comparison. Useful when we want to check how many records have missing (or not) data
SELECT
*
FROM
schema_name.flights
WHERE
dep_delay IS NULL
;
Just like before, we can't use a renamed column in a WHERE clause.
-- Both of these will error
SELECT
TRUNC(time_hour) AS flight_day
FROM
schema_name.flights
WHERE
flight_day > DATE '2013-06-01';
SELECT
tailnum AS tailnumber
FROM
schema_name.flights
WHERE
tailnumber LIKE 'N%';
Just like before, we can't use a renamed column in a WHERE clause.
The reason for this is because the WHERE clause runs before the SELECT does (even though it's written after).
An upside of this is that you can filter on a column that you don't actually output.
SELECT
tailnum
FROM
schema_name.flights
WHERE
origin = 'JFK'; -- only flights out of JFK airport
Run some of these queries so far and see the results.
Attempt questions 16-19.
Next let's look at how we can order our data
Ordering data is one of the most inefficient things a computer can do and databases are not designed to be fast at it, try to avoid ordering unless you have to, only do it once, or consider doing it in some other tool after exporting the data
SELECT
columns
FROM
tables
WHERE
condition
ORDER BY
columns;
We can order by a single column
SELECT
*
FROM
schema_name.flights
WHERE
dep_delay > 0
ORDER BY
dep_delay;
Or multiple columns for when there is a tie
SELECT
*
FROM
schema_name.flights
WHERE
dep_delay > 0
ORDER BY
-- sort by departure delay THEN arrival delay if there is a tie.
dep_delay,
arr_delay;
By default records are ordered in ascending order
SELECT
*
FROM
schema_name.flights
WHERE
dep_delay > 0
ORDER BY
-- Least delayed departing, ties are sorted by least delayed when arriving.
dep_delay,
arr_delay;
By default records are ordered in ascending order
but we can change that
SELECT
*
FROM
schema_name.flights
WHERE
dep_delay > 0
ORDER BY
-- MOST delayed departing, ties are sorted by least delayed when arriving.
dep_delay DESC,
arr_delay;
By default records are ordered in ascending order
but we can change that
and we have to specify it for each column.
SELECT
*
FROM
schema_name.flights
WHERE
dep_delay > 0
ORDER BY
-- MOST delayed departing, ties are sorted by MOST delayed when arriving.
dep_delay DESC,
arr_delay DESC;
Finally, we can be a bit lazy and because the ORDER BY runs after the SELECT we can actually just use numbers instead of column names.
This is also why we can use column aliases in the ORDER BY and can't use columns we didn't SELECT
SELECT
flight,
dep_delay,
arr_delay
FROM
schema_name.flights
WHERE
dep_delay > 0
ORDER BY
2 desc,
3;
Generally this is a bad idea, it's hard to read and if you change the order in your SELECT it will break.
It's rare that you want duplicates in your data. Usually it means you've done a join (next section) wrong, or your source data has an issue, or you removed too many variables.
If you are comfortable as to why you have duplicates but want to remove them you can use a SELECT DISTINCT to just get unique records.
SELECT DISTINCT
origin,
dest
FROM
schema_name.flights;
DISTINCT acts on all selected columns, not just the first one.
Run some of these queries so far and see the results.
Attempt questions 20-21.
Sometimes we want to combine our records in one way or another, if they are from the same table there is often a clever way to do this using ORs and CASE statements, but not always. Other times we might want to:
/* UNION records without duplicates */
SELECT
*
FROM
schema_name.airlines
WHERE
carrier in ('9E', 'AA', 'AS')
UNION
SELECT
*
FROM
schema_name.airlines
WHERE
carrier in ('AS', 'B6', 'DL');
/* UNION ALL records with duplicates */
SELECT
*
FROM
schema_name.airlines
WHERE
carrier in ('9E', 'AA', 'AS')
UNION ALL
SELECT
*
FROM
schema_name.airlines
WHERE
carrier in ('AS', 'B6', 'DL');
/* Find INTERESECTion of records */
SELECT
*
FROM
schema_name.airlines
WHERE
carrier in ('9E', 'AA', 'AS')
INTERSECT
SELECT
*
FROM
schema_name.airlines
WHERE
carrier in ('AS', 'B6', 'DL');
/* MINUS any matching records from the second table from the first */
SELECT
*
FROM
schema_name.airlines
WHERE
carrier in ('9E', 'AA', 'AS')
MINUS
SELECT
*
FROM
schema_name.airlines
WHERE
carrier in ('AS', 'B6', 'DL');
Though it is very rare, sometimes you might only want to return a specific number of rows.
For this we use the keyword FETCH and it's associated terms.
FETCH is the very last thing a database will run as it has to complete ordering first, so it would be any quicker to just return 5 rows instead of 500
SELECT
columns
FROM
tables
WHERE
condition
ORDER BY
columns
[OFFSET number ROWS]
FETCH NEXT number [PERCENT] ROWS ONLY/WITH TIES;
Though it is very rare, sometimes you might only want to return a specific number of rows.
For this we use the keyword FETCH and it's associated terms.
SELECT
*
FROM
schema_name.flights
ORDER BY
distance desc
OFFSET 5 ROWS
FETCH NEXT 5 ROWS WITH TIES;
This will return more than 5 records because of the option with ties.
Though it is very rare, sometimes you might only want to return a specific number of rows.
For this we use the keyword FETCH and it's associated terms.
SELECT
*
FROM
schema_name.flights
ORDER BY
distance desc
OFFSET 5 ROWS
FETCH NEXT 5 ROWS ONLY;
Run some of these queries so far and see the results.
Attempt questions 22-24
Sometimes we want to test our query or a function and don't want to query a whole table to do it.
To do this we can use a special table called dual which has a single row and a single column, with a value of 'X'.
SELECT
*
FROM
dual;
One good use for this is often to test out some date or string functions on dummy data to make sure you get it right
SELECT
--Some random date manipulation as a test
TRUNC(SYSDATE) - 5 + 1/24 + 14/24/60,
-- should return Friday
NEXT_DAY(TRUNC(SYSDATE), 'SAT') - 1 AS week_end_date
FROM
dual;
We've seen multiple times that we can't use a column we create/alias in a query within the same query (except in ordering). This was because of the order the query actualy runs in vs how we see it written.
But we know that a query returns a table, so we could use that table as the input to another query!
SELECT
columns
FROM
table
WHERE
condition;
We've seen multiple times that we can't use a column we create/alias in a query within the same query (except in ordering). This was because of the order the query actualy runs in vs how we see it written.
But we know that a query returns a table, so we could use that table as the input to another query!
SELECT
columns
FROM
(SELECT
columns
FROM
tables
WHERE
condition
)
WHERE
condition;
This is known as a nested query because the inner query is nested entirely within the outer one.
We can do this as many times as we like, but the database does have to complete an inner query before it can run the outer one, so filter as early (more nested) as possible, and order as late as possible.
SELECT
columns
FROM
(SELECT
columns
FROM
tables
WHERE
condition
)
WHERE
condition;
We need a way to refer to the attributes in the output of this inner query, we do that by aliasing the inner query - just like we would a table.
SELECT
b.*
FROM
(
SELECT
a.*,
distance * 1.60934 AS distance_km
FROM
schema_name.flights a
) b
WHERE
distance_km > 1000;
People often use a/b/c etc. for aliases - for short code this is fine but for longer code try to use a short but descriptive alias for each table instead.
Nested queries are great when the inner query is short and you only need to use it once. But what about if you want to use that inner query in multiple places, or the nesting gets very deep and complex?
The solution is Common Table Expressions (CTEs) which allow you to alias a whole query and refer to it at any later point in your code without having to write it out in full every time. These use the WITH keyboard
WITH alias AS (QUERY),
alias2 AS (QUERY),
alias3 AS (QUERY)
SELECT
columns
FROM
tables;
WITH km_table as
(
SELECT
a.*,
distance * 1.60934 AS distance_km
FROM
schema_name.flights a
)
SELECT
*
FROM
km_table
WHERE
distance_km > 1000
UNION
SELECT
*
FROM
km_table
WHERE
distance_km < 1000;
Run some of these queries so far and see the results.
Attempt questions 25-28
Finally we can keep a table for a longer period by storing it permanently in the database. To do this we use the CREATE TABLE statement.
Remember that a statement is different to a a query - a query reads the database and returns a table, a statement can interact with the database in other ways.
-- Nologging optionally turns off logs for the table creation
CREATE TABLE your_table_name [NOLOGGING] AS
query;
It is possible to use CREATE TABLE to create tables without a query by just specifying column names and types, but that is beyond the scope of this training.
Once created you can query the table like any other. Because you created it in your schema, you don't have to specify the schema name.
Remember only you can see this table, to share it with others you have to grant them access.
CREATE TABLE flights_km NOLOGGING AS
SELECT
a.*,
distance * 1.60934 AS distance_km
FROM
schema_name.flights a;
SELECT
*
FROM
flights_km;
Once we're done we want to DROP the table to delete it from the database.
DROP TABLE your_table_name [PURGE];
PURGE removes it from your recycling bin, you can leave it out but make sure to empty the bin in the case!
DROP TABLE flights_km PURGE;
SELECT
*
FROM
flights_km; -- the table no longer exist.
There are plenty of other statements in SQL that interact with tables, you can use TRUNCATE to empty a table, INSERT to add new records, DELETE to remove specific records, and UPDATE to alter existing records.
However, these are beyond the scope of this training.
Run some of these queries so far and see the results.
Attempt questions 29
We now come to one of the most powerful parts of using a relational databases, joining tables.
Joins take place in the FROM part of the query and have the following form:
SELECT
columns
FROM
table1
join_type JOIN table2
ON condition;
There are 4 types of joins you can do:
| Join type | Description |
|---|---|
| INNER JOIN | Only return records where they exist in both tables |
| LEFT/RIGHT JOIN | Return all records in the left/right table and any match in the right/left one if it exists |
| FULL OUTER JOIN | Return all records in both tables and any match if it exists |
| CROSS JOIN | Return all combinations of rows across both tables (the Cartesian product of the rows). Not often useful. |
There are 4 types of joins you can do:
When you specify a condition in your join that defines where a match is returned to the record or not, when you specify it in the WHERE this specifies whether the whole record is returned or not.
In the case of an inner join these are the same thing, but for other joins they are not.
First define your join logic, then define your filter criteria separately.
For the join examples we're going to use a slim version of the planes table so we can see how each join behaves; let's create that first.
CREATE TABLE planes_short NOLOGGING AS
SELECT
*
FROM
schema_name.planes
WHERE
tailnum = 'N108UW';
First let's look at an inner join, where only records that find a match are returned
SELECT
a.*,
b.*
FROM
schema_name.flights a
INNER JOIN planes_short b
/* In this case the columns had the same names,
but that won't always (in fact will rarely) be the case */
ON a.tailnum = b.tailnum;
Next the left join, where all records from the first table are returned, plus any matching data from the second
SELECT
a.*,
b.*
FROM
schema_name.flights a
LEFT JOIN planes_short b
ON a.tailnum = b.tailnum;
And a right join, just the other way round to the left.
SELECT
a.*,
b.*
FROM
schema_name.flights a
RIGHT JOIN planes_short b
ON a.tailnum = b.tailnum;
Despire the planes_short table having 1 row per plane, because of the join we now have multiple - we'll talk about this in a bit!
And a full outer join - we'll use a dummy table to create a fake plane to show that it returns all records from both tables regardless of if they match.
SELECT
a.*,
b.*
FROM
schema_name.flights a
FULL OUTER JOIN (SELECT 'FAKETAIL' AS tailnum_2 FROM dual) b
ON a.tailnum = b.tailnum_2
-- Defaults to nulls first for descending.
ORDER BY a.flight DESC;
Lastly the cross join - the least used of them all. We'll use 2 tables with 3 rows each to show we get all matches back in 9 rows (3x3).

The reason is if your join is not unique on at least one of the tables (i.e. the condition you give can be used to define each record and distinguish it from others) then each record in both tables will join to multiple in the other, getting out of hand very fast.
Always ask yourself; does my join link 1 row to 1/many rows in my other table? If the answer is no, you need to rethink your logic.
Run some of these queries so far and see the results.
Attempt questions 30-32
Often we want to get aggregate information of our data and group it by values in another column - this is similar to what we do in PivotTables in Excel.
To do this we use the GROUP BY clause and summary functions. This goes after WHERE but before ORDER BY.
SELECT
group_columns,
summary_columns
FROM
tables
WHERE
condition
GROUP BY
group_columns
ORDER BY
columns;
Any non-summarised variable must be listed in your GROUP BY otherwise it will error. You can group by something you don't select but it's a bad idea.
There are plenty of aggergation functions and the most common are listed below:
| Agg type | Description |
|---|---|
| COUNT(*) | The total number of records per group |
| COUNT(column) | The total number of records that are non-null in that variable |
| SUM(column) | The sum of that variable, must be numeric |
| AVG(column) | The mean of that variable, must be numeric |
| MAX(column) | The maximum of that variable |
| MIN(column) | The minimum of that variable |
Let's look at information about flights out of each airport
SELECT
origin,
COUNT(*) AS num_flights,
COUNT(dep_time) as num_departed_flights, -- doesn't count records with a null departure time
SUM(air_time) AS total_airtime,
AVG(air_time) AS mean_airtime,
MAX(dep_delay) AS latest_dep,
MIN(dep_delay) AS earliest_dep
FROM
schema_name.flights
GROUP BY
origin;
Let's look at information about flights out of each airport
AND by each destination airport.
SELECT
origin,
dest,
COUNT(*) AS num_flights,
COUNT(dep_time) as num_departed_flights,
SUM(air_time) AS total_airtime,
AVG(air_time) AS mean_airtime,
MAX(dep_delay) AS latest_dep,
MIN(dep_delay) AS earliest_dep
FROM
schema_name.flights
GROUP BY
origin,
dest;
We don't have to group by everything if we want details about the whole dataset.
SELECT
COUNT(*) AS num_flights,
MAX(dep_delay) AS latest_dep,
MIN(dep_delay) AS earliest_dep
FROM
schema_name.flights;
These aggergations becomes even more powerful when combined with a CASE statement.
SELECT
origin,
SUM( -- SUM uses 1 and 0 as the values
CASE
WHEN dep_delay = 0 AND arr_delay = 0
THEN 1
ELSE 0
END
) AS perfect_flights,
COUNT( -- COUNT uses anything and null as the values
CASE
WHEN dep_delay = 0 AND arr_delay = 0
THEN 1
ELSE null
END
) AS perfect_flights2
FROM
schema_name.flights
GROUP BY
origin;
You can filter on the results on an aggretation by using the HAVING keyword (as a WHERE filters records before they are aggregated).
SELECT
tailnum,
COUNT(*)
FROM
schema_name.flights
GROUP BY
tailnum
HAVING
-- only planes that had at least 50 flights in 2013
COUNT(*) > 50;
Run some of these queries so far and see the results.
Attempt questions 33-34
There are times we want to add aggregate information to our data but keep it at the record level. We could group and then join back on, but this is inefficient.
Instead we can use something called WINDOW FUNCTIONS (also known as ANALYTICAL FUNCTIONS).
Pretty much all of them have the same format:
WINDOW_FUNCTION(column) OVER (PARTITION BY columns ORDER BY columns)
Not all of the functions have an argument to the main function, or an ORDER BY clause, but most do.
The PARTITION BY defines your group for that record, and the ORDER BY defines the order within that group.
Most GROUP BY functions have an equivalent window function, but there are a few extras as well:
| Window Function | Description |
|---|---|
| ROW_NUMBER() | Numbers records in group from 1 to N (number in group) based on order by |
| RANK(column) | Rank value within that group, same value for ties (with gaps) |
| DENSE_RANK(column) | Rank value within that group, same value for ties (with no gaps) |
| FIRST/LAST_VALUE(column) | The first/last value within that group. |
| LEAD/LAG(column) | The next/previous value within that group. |
Let's look at an example.
SELECT
a.*,
ROW_NUMBER() OVER (
PARTITION BY year, month, day, carrier
ORDER BY sched_dep_time
) AS day_carrier_flight,
COUNT(*) OVER (
PARTITION BY year, month, day, carrier
) AS day_carrier_flight_total,
AVG(dep_delay) OVER (
PARTITION BY year, month, day, carrier
) AS day_carrier_avg_dep_delay
FROM
schema_name.flights a;
Run some of these queries so far and see the results.
Attempt questions 35-36
We have seen that often the order we write our code in is not the same order that the database runs it in. Let's quickly review the order of writing a full query, then compare it with how the database will (usually) execute it.
A crime has taken place and the detective needs your help. The detective gave you the crime scene report, but you somehow lost it. You vaguely remember that the crime was a murder that occurred sometime on Jan.15, 2018 and that it took place in SQL City. Start by retrieving the corresponding crime scene report from the police department’s database.
All the clues to this mystery are buried in a huge database, and you need to use SQL to navigate through this vast network of information. Your first step to solving the mystery is to retrieve the corresponding crime scene report from the police department’s database.


{%extends "issue_base.html"%} {%block title1%}Edit Issue Ex -{%endblock%} {%block head%}{{form.media}}{%endblock%} {%block issue_body%}


◆ create_stream()
| uvgrtp::media_stream* uvgrtp::session::create_stream |
( |
int |
src_port, |
|
|
int |
dst_port, |
|
|
rtp_format_t |
fmt, |
|
|
int |
flags |
|
) |
| |
Create a bidirectional media stream for an RTP session.
If local_addr was provided when uvgrtp::session was created, uvgRTP binds itself to local_addr:src_port, otherwise to INADDR_ANY:src_port
This object is used for both sending and receiving media, see documentation for uvgrtp::media_stream for more details.
User can enable and disable functionality of uvgRTP by OR'ing RCE_* flags together and passing them using the flags parameter
- Parameters
-
| src_port | Local port that uvgRTP listens to for incoming RTP packets |
| dst_port | Remote port where uvgRTP sends RTP packets |
| fmt | Format of the media stream. see RTP_FORMAT for more details |
| flags | RTP context enable flags, see RTP_CTX_ENABLE_FLAGS for more details |
- Returns
- RTP media stream object
- Return values
-
| uvgrtp::media_stream* | On success |
| nullptr | If src_port or dst_port is 0 |
| nullptr | If fmt is not a supported media format |
| nullptr | If socket initialization failed |
| nullptr | If ZRTP was enabled and it failed to finish handshaking |
| nullptr | If RCE_SRTP is given but uvgRTP has not been compiled with Crypto++ enabled |
| nullptr | If RCE_SRTP is given but RCE_SRTP_KMNGMNT_* flag is not given |
| nullptr | If memory allocation failed |
◆ destroy_stream()
Destroy a media stream.
- Parameters
-
| stream | Pointer to the media stream that should be destroyed |
- Returns
- RTP error code
- Return values
-
| RTP_OK | On success |
| RTP_INVALID_VALUE | If stream is nullptr |
| RTP_NOT_FOUND | If stream does not belong to this session |
The documentation for this class was generated from the following file:


We seek to translate inferences from evolutionary biology to improve human health and empower K-12 education. Click here to learn more about our research.
We offer high-throughput sequencing services on Illumina's NextSeq 500 platform.
The best way to learn and encourage excitement in young people about science is through a hands-on approach. The EvolvingSTEM program provides a ready-to-implement hands-on curriculum for high schoolers to learn evolution, microbiology, basic biotechnology, and get excited about STEM research careers.


An educational puzzle game exploring turing machines.
This was a Unity C# educational game I conceptualized way back in high school. It allows players to take simple tools and create a turing-machine-like being out of them using programming concepts and logic. With a gradual learning curve, playing the games has helped many of my friends, and thousands of other players, to learn the basics of programming in an interactive way. Special challenges that push the limits of turing machines also are provided for more experienced coders.
The game has many complex features that were fun to implement. Users are able to save and load their own levels to share and improve upon. This was done by serializing the game's state into a short string that could be copy and pasted with ease. Only the most necessary information was stored to save memory. Users are also pitted against each other in a game of efficiency by utilizing API's to keep track of a leaderboard. With this feature, players are inspired to iterate on their designs.
However, the thing that sticks with me the most about this game was the panic and emotion that I felt when I released it. It was the first time I had released one of my creations to the general public, and I quickly became bogged down trying to achieve perfection. As I expected, the game had mixed reviews. Puzzle games tend to be that way, especially challenging ones without fancy graphics. But still, seeing the feedback and constantly updating and fixing imperfections was a valuable experience that revealed troublesome spots I would have never considered myself. For instance, people generally ignored the tutorial, attempted to "fake" their way through some challenges, and other common programmer's pitfalls.
In the end, the game settled in around 3.5 stars out of 5. I was and am still very satisfied with how well the game turned out. I encourage you to try it out. I get no monetary benefit from people playing my game, but as a puzzle fanatic, I like the thought of providing a nice puzzle for someone to enjoy.
Gameplay Example
Gameplay Example
Any questions? Have anything to say? Feel free to contact me.


--- layout: 2018_default permalink: /2018/install title: Installation ---
#This will give you the latest version of go
sudo snap install go --classic
sudo apt-get update
sudo apt-get -y upgrade
curl -O https://storage.googleapis.com/golang/go1.11.2.linux-amd64.tar.gz
tar -xvf go1.11.2.linux-amd64.tar.gz
sudo mv go /usr/local
sudo nano ~/.bashrcAt the end of the file, add these lines: (Make sure you have work directory in your $HOME path)
export GOPATH=$HOME/workWith the appropriate line pasted into your bashrc, save and close the file. Next, refresh your bashrc by running:
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
source ~/.bashrc
NOTE: GOPATH must not be the same path as your Go installation.> Create folder at C:\go-work.
Find you GOPATH using command
> echo $GOPATH
Create below directory structure in your $GOPATH directory
> src/github.com/gautamrege
Change current directory to $GOPATH/src/github.com/gautamrege
> Git clone from repository
Run below commands for downloading project dependencies
> cd gochat
> go get
Find you GOPATH using command
> echo $GOPATH
Create below directory structure in your $GOPATH directory
> src/github.com/gautamrege
Copy "gochat" folder to $GOPATH/src/github.com/gautamrege directory


The Zend\Soap\Client class simplifies SOAP client development for PHP programmers.
It may be used in WSDL or non-WSDL mode.
Under the WSDL mode, the Zend\Soap\Client component uses a WSDL document to define transport layer options.
The WSDL description is usually provided by the web service the client will access. If the WSDL description is not made available, you may want to use Zend\Soap\Client in non-WSDL mode. Under this mode, all SOAP protocol options have to be set explicitly on the Zend\Soap\Client class.
The Zend\Soap\Client constructor takes two parameters:
Both of these parameters may be set later using setWsdl($wsdl) and setOptions($options) methods respectively.
Note
Important!
If you use Zend\Soap\Client component in non-WSDL mode, you must set the ‘location’ and ‘uri’ options.
The following options are recognized:
1 2 3 4 5 6 7 8 9 10 11 12 13 | // Accept response compression
$client = new Zend\Soap\Client("some.wsdl",
array('compression' => SOAP_COMPRESSION_ACCEPT));
...
// Compress requests using gzip with compression level 5
$client = new Zend\Soap\Client("some.wsdl",
array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5));
...
// Compress requests using deflate compression
$client = new Zend\Soap\Client("some.wsdl",
array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_DEFLATE));
|
After we’ve created a Zend\Soap\Client object we are ready to perform SOAP requests.
Each web service method is mapped to the virtual Zend\Soap\Client object method which takes parameters with common PHP types.
Use it like in the following example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | //****************************************************************
// Server code
//****************************************************************
// class MyClass {
// /**
// * This method takes ...
// *
// * @param integer $inputParam
// * @return string
// */
// public function method1($inputParam) {
// ...
// }
//
// /**
// * This method takes ...
// *
// * @param integer $inputParam1
// * @param string $inputParam2
// * @return float
// */
// public function method2($inputParam1, $inputParam2) {
// ...
// }
//
// ...
// }
// ...
// $server = new Zend\Soap\Server(null, $options);
// $server->setClass('MyClass');
// ...
// $server->handle();
//
//****************************************************************
// End of server code
//****************************************************************
$client = new Zend\Soap\Client("MyService.wsdl");
...
// $result1 is a string
$result1 = $client->method1(10);
...
// $result2 is a float
$result2 = $client->method2(22, 'some string');
|
The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.


---
layout: post
title: CICD Tech Talk
date: '2017-07-02T08:00:04-07:00'
tags:
- frombrett
- development
- devops
- programming
tumblr_url: http://beekley.xyz/post/162511951061/cicd-tech-talk
---
CICD Tech Talk
I talked about CI and CD at Codesmith last week. It’s super simplified – only 10 mins – but I hope it covered some of how and why it’s useful to build big things out of small things.


3.2 Optional third party libraries
We provide interfaces to the following third-party software libraries; note that these are
optional, but if you enable them some defaults for multilevel preconditioners may
change to reflect their presence.
-
UMFPACK
- [9] A sparse LU factorization package included in the SuiteSparse
library, available from faculty.cse.tamu.edu/davis/suitesparse.html;
it provides sequential factorization and triangular system solution for
double precision real and complex data. We tested version 4.5.4
of SuiteSparse. Note that for configuring SuiteSparse you should
provide the right path to the BLAS and LAPACK libraries in the
SuiteSparse_config/SuiteSparse_config.mk file.
-
MUMPS
- [1] A sparse LU factorization package available from
mumps.enseeiht.fr; it provides sequential and parallel factorizations and
triangular system solution for single and double precision, real and complex
data. We tested versions 4.10.0 and 5.0.1.
-
SuperLU
- [10] A sparse LU factorization package available from
crd.lbl.gov/~xiaoye/SuperLU/; it provides sequential factorization and
triangular system solution for single and double precision, real and complex
data. We tested versions 4.3 and 5.0. If you installed BLAS from ATLAS,
remember to define the BLASLIB variable in the make.inc file.
-
SuperLU_Dist
- [19] A sparse LU factorization package available from the same
site as SuperLU; it provides parallel factorization and triangular system
solution for double precision real and complex data. We tested versions
3.3 and 4.2. If you installed BLAS from ATLAS, remember to define the
BLASLIB variable in the make.inc file and to add the -std=c99 option to
the C compiler options. Note that this library requires the ParMETIS library
for parallel graph partitioning and fill-reducing matrix ordering, available
from glaros.dtc.umn.edu/gkhome/metis/parmetis/overview.


Generated using the
Schoenberg Institute for Manuscript Studies
Collation Modeller
Opera, including Lucidarium artis transmutationis metallorum; extracts from the Sommeta and Violetta; and Epistola, OthmerMS8
Select a Gathering
Gathering 1 (7)
Gathering 2 (16)
Gathering 3 (16)
Gathering 4 (16)
Gathering 5 (16)
Gathering 6 (16)
Gathering 2 (16)
Error: SVG file not found
8v
23r
23v
8r
Error: SVG file not found
9v
22r
22v
9r
Error: SVG file not found
10v
21r
21v
10r
Error: SVG file not found
11v
20r
20v
11r
Error: SVG file not found
12v
19r
19v
12r
Error: SVG file not found
13v
18r
18v
13r
Error: SVG file not found
14v
17r
17v
14r
Error: SVG file not found
15v
16r
16v
15r


I love graphic design because of the creativity that is required to make good design.
Graphic design, particularly Logo design, has been a passion and a creative outlet for me since 2009.
Graphic Design
Web Design
Having studied Web design and development as part of my software engineering degree,
I took up web design as a natural ally to Graphic design, and have really grown fond of the power of the web.
I took up web design as a natural ally to Graphic design, and have really grown fond of the power of the web.
Programming
My first introduction to programming was at the age of 15, studying BASIC in school.
All the career counselling in the world couldn't faze me after that, I had to be a Programmer.
All the career counselling in the world couldn't faze me after that, I had to be a Programmer.


Registration fee: Rs. 70 per head
Each participant is required to carry a pen and note pad with them.
There will be a general discussion on the film between the participants.
PRODUCT LAUNCH:-
The first round will be elimination round wherein a panel of judges will evaluate all the submitted entries. The team needs to have minimum 2 and maximum 4 participants.
For preliminary round, participants need to select a product or services which are innovative and cater to a new market need which is not met as of now.
For the selected product or services, team needs to submit PPT with maximum 20 slides.
The PPTs are required to mail by March 5, 2017 on<EMAIL_ADDRESS>.
For the elimination round, 5 minutes will be given to each team for presentation and five best teams will be selected by panel of judges for final round.
The 3 selected teams will give the final presentation and that would be of 15 minutes followed by Questions-Answer of 5 minutes.
Team can include all the creative aspects required for a new product launch like tagline, slogan, ad copy, poster etc... for the final presentation.
Registration Fees Rs.100 per team.


A Passion for Protecting the Planet Leads to Healthier Schools and Budgets
Energy Management Specialist Diane Sweeney answers some questions about HCPSS energy conservation efforts, and how they play an important role in ensuring efficient operations and a safe and healthy learning environment.