BREAKING: Drop support for Node 0.10, 0.12, and io.js.
Remove undocumented passParsingErrors option.
Added EOL override option to writeFile when using spaces. #89
3.0.1 / 2017-07-05
Fixed bug in writeFile when there was a serialization error & no callback was passed. In previous versions, an empty file would be written; now no file is written.
3.0.0 / 2017-04-25
Changed behavior of throws option for readFileSync; now does not throw filesystem errors when throws is false
add support for any arbitrary fs module. Useful with mock-fs
2.2.3 / 2015-10-14
include file name in parse error. See: https://github.com/jprichardson/node-jsonfile/pull/34
2.2.2 / 2015-09-16
split out tests into separate files
fixed throws when set to true in readFileSync(). See: https://github.com/jprichardson/node-jsonfile/pull/33
2.2.1 / 2015-06-25
fixed regression when passing in string as encoding for options in writeFile() and writeFileSync(). See: https://github.com/jprichardson/node-jsonfile/issues/28
2.2.0 / 2015-06-25
added options.spaces to writeFile() and writeFileSync()
2.1.2 / 2015-06-22
fixed if passed readFileSync(file, 'utf8'). See: https://github.com/jprichardson/node-jsonfile/issues/25
2.1.1 / 2015-06-19
fixed regressions if null is passed for options. See: https://github.com/jprichardson/node-jsonfile/issues/24
2.1.0 / 2015-06-19
cleanup: JavaScript Standard Style, rename files, dropped terst for assert


In the last lesson, I mislead you. Here’s the code we ended with:
class RepairedRobot(UsedRobot):
def turn_right(self):
for i in range(3):
self.turn_left()
The robot is not repaired: it still accomplishes right turns by turning left three times. We really need to fix this. However, in order to do so, we will need to learn a bit more about the actual program that controls the robot. This is going to be a bit long, but very worthwhile in the end. Along the way, you will learn new Python concepts … and you will even see some and understand some Javascript code!
Open Reeborg’s Diary. If you want, you can also hide the world by clicking on the “World” button.
Enter and execute the following code and look at the result in the Diary:
r = UsedRobot()
dir_js(r)
dir_js is a Javascript function, understood by Python/Brython, that I wrote to enable you to see an object’s methods and attributes. Right now, it does not tell us much. Here is what I get when I do this:
__class__
body
Note
I use a single letter r for the robot name as this is a very short program and I don’t need a descriptive name.
We do not know if they are methods or attributes. __call__ starts and ends with two underscore characters; this is a convention in the Python world to denote some internal Python code that is mostly reserved for advanced programmers. The other is body. So, we know that r.body is something. Run the following code:
r = UsedRobot()
dir_js(r.body)
Note
Python programmers use a convention where variable names that start with an underscore, like _prev_x are meant to indicate that they are “private” and should normally not be changed by another programmer.
You should see something like:
x
y
objects
orientation
_is_leaky
_prev_x
_prev_y
_prev_orientation
You might have guessed that objects refers to the various objects (tokens, etc.) carried by Reeborg. Also, various challenges told you that Reeborg is at the correct x position, and similarly for y. So it would seem likely that x and y refer to Reeborg’s position. As a programmer, your first reflex should be write a program and see if this is the case.
Try this!
Select the world Empty, turn off the highlighting, and execute the following code:
jumper = UsedRobot() # mutant robot that teleports itself
jumper.body.x = 8
jumper.body.y = 10
All you should see is a robot created at x=1, y=1 … which might not be what you have expected. If you turn on the highlighting and run the program again, you will get the expected result.
Try this!
Turn off the highlighting and add the following instruction:
jumper.turn_left()
at the end of your program and run it again.
You may recall from previous tutorials that Reeborg’s actions are recorded (like a movie) and played back one “frame” at a time. The recording of a given state happens when some special instructions are given. By changing the value of the attribute x or y of the jumper.body object, you do not trigger a frame recording. However, by adding a turn_left() instruction at the end, we do make a recording of the situation, which shows us that the previous instructions did indeed change the robot’s position. Alternatively, the code highlighing utility triggers a frame recording so that the line of code about to be executed can be shown with the more recent state of the world.
So, assuming we want to have the program work perfectly, whether or not the code highlighting is on or not, how can we trigger a frame recording without using an existing method which could cause the robot to not end up in our desired position or orientation? The answer will be provided by looking at the Javascript code powering most of Reeborg’s World.
If we are going to look at some Javascript code and you are reading this tutorial with Python as your first (and only) programming language, you might be wondering if you made a mistake in choosing Python over Javascript.
Don’t worry, you did not.
You already know about libraries; chances are there are some functions defined in yours on Reeborg’s World. Libraries are sometimes written in a different language than the main programming one. For numerical work, Fortran has long been the language of choice and most numerical libraries have been written in Fortran. Many other libraries have been written in the C language.
Python is sometimes described as a glue language. You can write Python programs that make use of functions found in Fortran and C libraries. Usually, to make use of such libraries, one refers to documentation written that indicates what functions can be called and how.
You can think of the Javascript code powering most of Reeborg’s world as a special library. However, no documentation on that library exists. The way to find out about the functions existing in this library are to look at the code itself, which is what we are about to do. However, before we do this, you should take a quick crash course on Javascript.
Do this!
Read the one page tutorial on Converting Python code into Javascript. By doing the reverse steps, you could convert Javascript into Python. The quick tutorial will teach you enough to be able to get all the information you need from the Javascript code inside Reeborg’s World. Make sure to come back to this page when you are done, so that you can continue with this tutorial.
Now that you have read the quick tutorial on converting Python code into Javascript, it is time to read some Javascript code.


{% extends "base.html" %} {% block title %}Help{% endblock %} {% block head %} {{ super() }} {% endblock %} {% block data %}
{{_('In the eve client, go to the Ship Fitting Window.
On the bottom right side is a Save button, click it.
A Fitting Management window will open, that has a Copy to Clipboard button at the bottom, click it.
Now you are ready to switch to the Waitlist Website.
At the top there is a link X-UP, open the link.
In the big text field, below Fittings, press Ctrl+V or right click and select Paste.
Now at the bottom, if you are flying one of these ships: Rokh, Rattlesnake, Scorpion Navy Issue, please select your Caldari Battleship Level.
If you are flying a Logistics Ship, namely Basilisk or Scimitar, please select your Logistics Cruiser Level too.
Now you can press Enter on Waitlist.
Your Fittings will now be queued up for review by a Waitlist Manager before you are put on the Waitlist.
You will be send back to the index page, where you can see who is on the Waitlist, and/or in the queue, to be review by a Waitlist Manager.')}}
{{ _('For expression evaluation expr-eval is used.
The variables, open, xup, logi, dps, sniper, other
are provided, open being a boolean(true/false) while the others are numbers.
You can have one expression per Waitlist Group, there is no need for more then one, because using (expression) or (expression) would be the same as using two expression for one group.') }}
{{ _('To explain how the expressions work, first we are introducing the word operator. An operator is something that takes input values, and does something witht them, then providing an output value.') }}
{{ _('For our usage we only need to look at unary and binary operators. Binary operators, take two arguments. Unary ones only take one. Now that we have established this we are going to move on to an example.') }}
{{ _('Our placeholder expression is (xup == 0 and logi < 2) or (xup == 2 and dps <= 5)
.
This expression is split on two subexpressions, made by ()
, a grouping operator, which are (1)(xup == 0 and logi < 2)
and (2)(xup == 2 and dps <= 5)
.') }}
{{ _('These two expressions are connected by the operator or
which is a binary operator.
The or
operator works like this: It takes the two given arguments, and if either is true, it solves to true in all other cases (both are false) it solves to false.') }}
{{ _('Now taking a look at subexpression (1)(xup == 0 and logi < 2)
we see our placeholder variables xup
and logi
.
They will be replaced with our values from the table, on every update and following evaluation of the expressions.') }}
{{ _('So here again we have two subexpressions inside this subexpression. (xup == 0)
and (logi < 2)
.') }}
{{ _('We know these two are subexpressions like this because of association.
You really don\'t need to care about this, if you don\'t know what it is.
Just put all your expressions in ()
and you don\'t need to know what it is.') }}
{{ _('Taking the first one (xup == 0)
it uses the binary operator ==
which means "equals".
And so check if both arguments xup
and 0
are equal.
If this is the case the operator ==
resolves to true, otherwise false.') }}
{{ _('(logi < 2)
uses the binary operator <
"lesser then", with logi
and 2
as arguments.
And so evaluates to true
, if logi
(the replacement value) is less then 2
.') }}
{{ _('The common operators are: ==
equals, !=
does not equal, >=
bigger or equal, <=
less then or equal
>
greater then, <
less then
And to connect these expressions, the operators:
and
and or
. Keep in mind the "or" is a "true or", not the way it often is used in language, it is not an "either or". On this "or" both can be true.
There are other also useful operators, that can be used you can find them under expr-eval.
But the ones introduced here, should be enough to write decent notification logic and should cover most use cases.') }}


org.apache.axis.transport.http
Classes
AdminServlet
AxisHttpSession
AxisServlet
HTTPConstants
HTTPSender
HTTPTransport
NonBlockingBufferedInputStream
SimpleAxisServer


rotten > Library > Death > Execution > Firing Squad
Firing Squad
- Photos of the Mexican doctor
- Gary Gilmore, the last person executed in the US by firing squad.
Timeline
| 11 Mar 1972 |
A firing squad composed of South Korean airmen executes all four members of Unit 684 at Oryu-dong, Seoul. Unit 684 were assassins trained to kill North Korean dictator Kim Il Sung. |
Pornopolis |
Rotten |
Faces of Death |
Famous Nudes
|


In a world where Kubernetes has become the de facto standard to build application services that span multiple containers, running a cloud-native distributed database represents an important part of the experience of using Kubernetes. In this connection, TiDB, a cloud-native, open-source NewSQL database that supports Hybrid Transactional and Analytical Processing (HTAP) workloads, meets those needs admirably. Its architecture is suitable for Kubernetes, and it is MySQL compatible. TiDB also features horizontal scalability, strong consistency, and high availability.
In addition to TiDB, I am also using KubeSphere, an open-source distributed operating system that manages cloud-native applications with Kubernetes as its kernel. It provides a plug-and-play architecture for the seamless integration of third-party applications to boost its ecosystem. KubeSphere can be run anywhere as it is highly pluggable without any hacking into Kubernetes.
By combining TiDB with KubeSphere, we can have Kubernetes-powered TiDB clusters, and manage the clusters using a developer-friendly wizard web UI. In this post, I will demonstrate how to deploy TiDB on KubeSphere from scratch.
Preparing Environments
As you can imagine, the very first thing to consider is to have a Kubernetes cluster so that you can deploy TiDB. Well, in this regard, the installation of Kubernetes may have haunted a large number of neophytes, especially the preparation of working machines, either physical or virtual. Besides, you also need to configure different network rules so that traffic can move smoothly among instances. Fortunately, QingCloud, the sponsor of KubeSphere, provides users with a highly functional platform that enables them to quickly deploy Kubernetes and KubeSphere at the same time (you can choose to deploy Kubernetes only). Namely, you only need to click few buttons and the platform will do the rest.
Therefore, I select QingCloud Kubernetes Engine (QKE) to prepare the environment. In fact, you can also use instances on the platform directly and deploy a highly-available Kubernetes cluster with KubeSphere installed. Here is how I deploy the cluster and TiDB:
-
Log in the web console of QingCloud. Simply select KubeSphere (QKE) from the menu and create a Kubernetes cluster with KubeSphere installed. The platform allows you to install different components of KubeSphere. Here, we need to enable OpenPitrix, which powers the app management feature in KubeSphere.
Note
KubeSphere can be installed on any infrastructure. I just use QingCloud Platform as an example. See KubeSphere Documentation for more details. -
The cluster will be up and running in around 10 minutes. In this example, I select 3 working nodes to make sure I have enough resources for the deployment later. You can also customize configurations based on your needs. When the cluster is ready, log in the web console of KubeSphere with the default account and password (
admin/P@88w0rd
). Here is the cluster Overview page: -
Use the built-in Web Kubectl from the Toolkit in the bottom right corner to execute the following command to install TiDB Operator CRD:
kubectl apply -f https://raw.githubusercontent.com/pingcap/tidb-operator/v1.1.6/manifests/crd.yaml
-
You can see the expected output as below:
customresourcedefinition.apiextensions.k8s.io/tidbclusters.pingcap.com created customresourcedefinition.apiextensions.k8s.io/backups.pingcap.com created customresourcedefinition.apiextensions.k8s.io/restores.pingcap.com created customresourcedefinition.apiextensions.k8s.io/backupschedules.pingcap.com created customresourcedefinition.apiextensions.k8s.io/tidbmonitors.pingcap.com created customresourcedefinition.apiextensions.k8s.io/tidbinitializers.pingcap.com created customresourcedefinition.apiextensions.k8s.io/tidbclusterautoscalers.pingcap.com created
-
Now, let’s get back to the Access Control page where all the workspaces are listed. Before I proceed, first I need to create a new workspace (e.g.
dev-workspace
).In a workspace, different users have different permissions to perform varied tasks in projects. Usually, a department-wide project requires a multi-tenant system so that everyone is responsible for their own part. For demonstration purposes, I use the account
admin
in this example. You can see the official documentation of KubeSphere to know more about how the multi-tenant system works. -
Go to a workspace, and you can see that KubeSphere provides two methods to add Helm charts. This article only talks about the first one, which is adding an app repository in KubeSphere. Alternatively, you can also upload your own app templates and submit them to the KubeSphere App Store, which will be talked about in my next blog. Here, follow the images below to add the Helm repository of PingCap (https://charts.pingcap.org) in App Repos.
Deploying TiDB Operator
TiDB Operator is an automatic operation system for TiDB clusters in Kubernetes. It provides a full management life-cycle for TiDB, including deployment, upgrades, scaling, backup, fail-over, and configuration changes. With TiDB Operator, TiDB can run seamlessly in Kubernetes clusters deployed on public or private clouds. You need to first deploy TiDB Operator on KubeSphere.
-
Like I mentioned above, we need to create a project (i.e. namespace) first to run TiDB Operator.
-
After the project is created, navigate to Applications and click Deploy New Application.
-
Select From App Templates.
-
Switch to the PingCAP repository that stores multiple Helm charts. This article only demonstrates how to deploy TiDB Operator and TiDB clusters. You can also deploy other tools based on your needs.
-
Click tidb-operator and select Chart Files. You can view the configuration from the console directly or download the default
values.yaml
file. From the drop-down menu on the right, you can also select the version you want to install. -
Confirm your app name, version and deployment location.
-
You can edit the
values.yaml
file in this step, or click Deploy directly with the default configurations. -
In Applications, wait for TiDB Operator to be up and running.
-
In Workloads, you can see two Deployments created for TiDB Operator.
Deploying a TiDB Cluster
The process of deploying a TiDB cluster is similar to deploying TiDB Operator.
-
Also from the PingCAP repository, select tidb-cluster.
-
Switch to Chart Files and download the values.yaml file.
-
Some TiDB components require persistent volumes. In this regard, QingCloud Platform provides users with the following storage classes.
/ # kubectl get sc NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE csi-high-capacity-legacy csi-qingcloud Delete Immediate true 71m csi-high-perf csi-qingcloud Delete Immediate true 71m csi-ssd-enterprise csi-qingcloud Delete Immediate true 71m csi-standard (default) csi-qingcloud Delete Immediate true 71m csi-super-high-perf csi-qingcloud Delete Immediate true 71m
-
As I installed KubeSphere through QingCloud Kubernetes Engine (QKE), all of these storage components were deployed automatically by default. The QingCloud CSI plugin implements an interface between CSI-enabled Container Orchestrator (CO) and the storage of QingCloud. If you are interested in QingCloud CSI, have a look at their GitHub repository. Select csi-standard here by replacing the default value
local-storage
of the fieldstorageClassName
withcsi-standard
invalues.yaml
. In the downloaded file, you can replace all of them directly and copy and paste it to thevalues.yaml
file.Note
Only the fieldstorageClassName
is changed to provide external persistent storage. If you want to deploy each TiDB component, such as TiKV and Placement Driver, to individual nodes, specify the fieldnodeAffinity
. -
Click Deploy and you can see two apps in the list as shown below:
Viewing TiDB Cluster Status
Now that we have our apps ready, we may need to focus more on observability. KubeSphere gives users a straightforward view of how apps are doing during their whole lifecycle with different metrics available on the dashboard.
-
Verify that all TiDB cluster Deployments are up and running in Workloads.
-
TiDB, TiKV and PD are all stateful applications, which can be found in StatefulSets. Note that TiKV and TiDB will be created automatically and it may take a while before they display in the list.
-
Click a single StatefulSet to display its detail page. This page shows metrics in line charts over a period of time. The following is an example of TiDB metrics:
-
View TiKV loads:
-
Relevant Pods are also listed. As you can see, your TiDB cluster contains three PD Pods, two TiDB Pods and three TiKV Pods.
-
Go to the Storage section, and you can see TiKV and PD are using persistent storage.
-
Volume usage is also monitored. Here is an example of TiKV:
-
On the Overview page, you can see a list of resource usage in the current project.
Accessing TiDB Cluster
These services just created can be accessed easily as KubeSphere tells you how a service is being exposed on which port.
-
In Services, you can see detailed information of all services.
-
As the service type is set to
NodePort
, you can access it through the Node IP address outside the cluster. -
Here is a test of the connection to the database through MySQL client.
[root@k8s-master1 ~]# docker run -it --rm mysql bash [root@0d7cf9d2173e:/# mysql -h <IP_ADDRESS> -P 32682 -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 201 Server version: 5.7.25-TiDB-v4.0.6 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | INFORMATION_SCHEMA | | METRICS_SCHEMA | | PERFORMANCE_SCHEMA | | mysql | | test | +--------------------+ 5 rows in set (0.01 sec) mysql>
-
Besides, TiDB integrates Prometheus and Grafana to monitor performance of the database cluster. As we can see above, Grafana is being exposed through
NodePort
. After you configure necessary port forwarding rules and open its port in security groups on QingCloud Platform, you can access the Grafana UI to view metrics.
Summary
I hope you guys all have successfully deployed TiDB. Both TiDB and KubeSphere are powerful tools for cloud-native applications, so in fact, I cannot showcase every aspect of them all in this post. For example, the app deployment function has much to offer for cloud-native enthusiasts like me. I will post another article on how to deploy TiDB by uploading Helm charts to the KubeSphere App Store.
If you have any questions, don’t hesitate to contact us in Slack or GitHub.
References
KubeSphere GitHub: https://github.com/kubesphere/kubesphere
TiDB GitHub: https://github.com/pingcap/TiDB
TiDB Operator Documentation: https://docs.pingcap.com/tidb-in-kubernetes/stable/tidb-operator-overview
KubeSphere Introduction: https://kubesphere.io/docs/introduction/what-is-kubesphere/
KubeSphere Documentation: https://kubesphere.io/docs/


# Footer
Footers in Cirrus are responsive and easy to implement in any page. It can contain pretty much any element including extra divs, columns, lists, and more. Below is a recreation of what this page uses as a footer.
Footers in Cirrus are responsive and easy to implement in any page. It can contain pretty much any element including extra divs, columns, lists, and more. Below is a recreation of what this page uses as a footer.
The footer itself does not come with too many complicated components, but rather a very minimalistic set of modifiers to allow for greater flexibility.
footer
serves as the main base component of the *drum roll...* footer. By default, it comes with equal padding at the top and bottom of 6rem
and a margin top of 5rem
to create a separation between the main content and the footer.footer
, but there are a few footer specific components worth mentioning.footer-list-title
is a standard list title in the footer with a bottom border.footer-list-item
provides default stylings for list items. These can be used in combination with Cirrus's columns to create a clean site map.Static footers are designed to stick to the bottom of a page. To make a static footer, add the footer-fixed
class to the footer.
Tired of dark gray? Easily add or change anything in the footer to your liking.
The footer style used above.
footer {
width: 100%;
background-color: #fff;
background: linear-gradient(rgba(0,0,0,.5),rgba(0,0,0,.5)),url("https://images.unsplash.com/photo-1514227765494-1bbd6ba05916?auto=format&fit=crop&w=1600&q=100") no-repeat;
background-size: cover;
will-change: transform;
}
Below are a couple of examples of different footer designs with Cirrus to help you get started.
A minimal footer for a clean website. Only having the copyright, logo, and social links can be sufficient. Simple, clean, and to the point.
A simple way to allow users to navigate to all the different pages on your site.
Make your footer standout with a simple contact or sign up form. This is great for blogs and other media sites.
Refer users to other social networks from the main site for greater user engagement.


Kpop Girl Group Songs with the Highest Digital Index Per Month of 2019 Based on Gaon Scores
by HelloAnonHere are the songs by Kpop girl groups that dominated 2019 so far and the songs with the highest digital index per month (until October 2019) based on updated data released by GAON Chart:
Top 3 songs released by Kpop female groups with the most overall digital points on GAON in 2019 (latest update: 1st week of November):
1. ITZY's Dalla Dalla - 748,651,262
2. TWICE's Fancy - 527,587,246
3. BLACKPINK's Kill this Love - 496,881,519
Data aggregators: KChartMaster, SerieTV46


The Ninjas
Dhvanil | Dipendra | Ritesh | Rohan | Vysak
Project Video
Final video detailing the entire concept
High Fidelity Prototype
Final mock-up designs
Scenario Buliding
Examining the user scenarios
Qualitative Analysis
In depth Qualitative Analysis
Quantitative Analysis
Analysis of Quantitative Evaluation
Secondary Research
Analysis of food printers available in the market
\
Mini Challenge 1
Responses to first Mini Challenge
Team Poster
Our supercool poster designed by Dipendra.


Police seek witnesses following Opotiki fatal crash
by New Zealand PolicePolice are asking for the public's help following a fatal crash yesterday near Opotiki.
The crash involved a utility vehicle and an SUV, and occurred at the intersection of State Highway 2 and Paerata Ridge Road about 10.10am.
Sadly, two people - the occupants of the utility vehicle - died at the scene.
Police are appealing for anyone who witnessed the crash to come forward and speak to us.
Anyone who can help should call Whakatane Police on 105.
ENDS


This is the first article in a series of articles about three.js. Three.js is a 3D library that tries to make it as easy as possible to get 3D content on a webpage.
Three.js is often confused with WebGL since more often than not, but not always, three.js uses WebGL to draw 3D. WebGL is a very low-level system that only draws points, lines, and triangles. To do anything useful with WebGL generally requires quite a bit of code and that is where three.js comes in. It handles stuff like scenes, lights, shadows, materials, textures, 3d math, all things that you'd have to write yourself if you were to use WebGL directly.
These tutorials assume you already know JavaScript and, for the most part they will use ES6 style. See here for a terse list of things you're expected to already know. Most browsers that support three.js are auto-updated so most users should be able to run this code. If you'd like to make this code run on really old browsers look into a transpiler like Babel. Of course users running really old browsers probably have machines that can't run three.js.
When learning most programming languages the first thing people
do is make the computer print "Hello World!"
. For 3D one
of the most common first things to do is to make a 3D cube.
So let's start with "Hello Cube!"
Before we get started let's try to give you an idea of the structure of a three.js app.  Here's a diagram that represents a small three.js app
Things to notice about the diagram above.
There is a Renderer
. This is arguably the main object of three.js. You pass a
Scene
and a Camera
to a Renderer
and it renders (draws) the portion of
the 3D scene that is inside the frustum of the camera as a 2D image to a
canvas.
There is a scenegraph which is a tree like
structure, consisting of various objects like a Scene
object, multiple
Mesh
objects, Light
objects, Group
, Object3D
, and Camera
objects. A
Scene
object defines the root of the scenegraph and contains properties like
the background color and fog. These objects define a hierarchical parent/child
tree like structure and represent where objects appear and how they are
oriented. Children are positioned and oriented relative to their parent. For
example the wheels on a car might be children of the car so that moving and
orienting the car's object automatically moves the wheels. You can read more
about this in the article on scenegraphs.
Note in the diagram Camera
is half in half out of the scenegraph. This is to
represent that in three.js, unlike the other objects, a Camera
does not have
to be in the scenegraph to function. Just like other objects, a Camera
, as a
child of some other object, will move and orient relative to its parent object.
There is an example of putting multiple Camera
objects in a scenegraph at
the end of the article on scenegraphs.
Mesh
objects represent drawing a specific Geometry
with a specific
Material
. Both Material
objects and Geometry
objects can be used by
multiple Mesh
objects. For example to draw two blue cubes in different
locations we could need two Mesh
objects to represent the position and
orientation of each cube. We would only need one Geometry
to hold the vertex
data for a cube and we would only need one Material
to specify the color
blue. Both Mesh
objects could reference the same Geometry
object and the
same Material
object.
Geometry
objects represent the vertex data of some piece of geometry like
a sphere, cube, plane, dog, cat, human, tree, building, etc...
Three.js provides many kinds of built in
geometry primitives. You can also
create custom geometry as well as
load geometry from files.
Material
objects represent
the surface properties used to draw geometry
including things like the color to use and how shiny it is. A Material
can also
reference one or more Texture
objects which can be used, for example,
to wrap an image onto the surface of a geometry.
Texture
objects generally represent images either loaded from image files,
generated from a canvas or rendered from another scene.
Light
objects represent different kinds of lights.
Given all of that we're going to make the smallest "Hello Cube" setup that looks like this
First let's load three.js
<script type="module"> import * as THREE from 'three'; </script>
It's important you put type="module"
in the script tag. This enables
us to use the import
keyword to load three.js. As of r147, this is the
only way to load three.js properly. Modules have the advantage that they can easily import other modules
they need. That saves us from having to manually load extra scripts
they are dependent on.
Next we need is a <canvas>
tag so...
<body> <canvas id="c"></canvas> </body>
We will ask three.js to draw into that canvas so we need to look it up.
<script type="module"> import * as THREE from 'three'; +function main() { + const canvas = document.querySelector('#c'); + const renderer = new THREE.WebGLRenderer({antialias: true, canvas}); + ... </script>
After we look up the canvas we create a WebGLRenderer
. The renderer
is the thing responsible for actually taking all the data you provide
and rendering it to the canvas.
Note there are some esoteric details here. If you don't pass a canvas into three.js it will create one for you but then you have to add it to your document. Where to add it may change depending on your use case and you'll have to change your code so I find that passing a canvas to three.js feels a little more flexible. I can put the canvas anywhere and the code will find it whereas if I had code to insert the canvas into to the document I'd likely have to change that code if my use case changed.
Next up we need a camera. We'll create a PerspectiveCamera
.
const fov = 75; const aspect = 2; // the canvas default const near = 0.1; const far = 5; const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
fov
is short for field of view
. In this case 75 degrees in the vertical
dimension. Note that most angles in three.js are in radians but for some
reason the perspective camera takes degrees.
aspect
is the display aspect of the canvas. We'll go over the details
in another article but by default a canvas is
300x150 pixels which makes the aspect 300/150 or 2.
near
and far
represent the space in front of the camera
that will be rendered. Anything before that range or after that range
will be clipped (not drawn).
Those four settings define a "frustum".  In other words think of the word "frustum" as another 3D shape like sphere, cube, prism, frustum.
The height of the near and far planes are determined by the field of view. The width of both planes is determined by the field of view and the aspect.
Anything inside the defined frustum will be drawn. Anything outside will not.
The camera defaults to looking down the -Z axis with +Y up. We'll put our cube at the origin so we need to move the camera back a little from the origin in order to see anything.
camera.position.z = 2;
Here's what we're aiming for.
In the diagram above we can see our camera is at z = 2
. It's looking
down the -Z axis. Our frustum starts 0.1 units from the front of the camera
and goes to 5 units in front of the camera. Because in this diagram we are looking down,
the field of view is affected by the aspect. Our canvas is twice as wide
as it is tall so across the canvas the field of view will be much wider than
our specified 75 degrees which is the vertical field of view.
Next we make a Scene
. A Scene
in three.js is the root of a form of scene graph.
Anything you want three.js to draw needs to be added to the scene. We'll
cover more details of how scenes work in a future article.
const scene = new THREE.Scene();
Next up we create a BoxGeometry
which contains the data for a box.
Almost anything we want to display in Three.js needs geometry which defines
the vertices that make up our 3D object.
const boxWidth = 1; const boxHeight = 1; const boxDepth = 1; const geometry = new THREE.BoxGeometry(boxWidth, boxHeight, boxDepth);
We then create a basic material and set its color. Colors can be specified using standard CSS style 6 digit hex color values.
const material = new THREE.MeshBasicMaterial({color: 0x44aa88});
We then create a Mesh
. A Mesh
in three represents the combination
of three things
Geometry
(the shape of the object)Material
(how to draw the object, shiny or flat, what color, what texture(s) to apply. Etc.)const cube = new THREE.Mesh(geometry, material);
And finally we add that mesh to the scene
scene.add(cube);
We can then render the scene by calling the renderer's render function and passing it the scene and the camera
renderer.render(scene, camera);
Here's a working example
It's kind of hard to tell that is a 3D cube since we're viewing it directly down the -Z axis and the cube itself is axis aligned so we're only seeing a single face.
Let's animate it spinning and hopefully that will make
it clear it's being drawn in 3D. To animate it we'll render inside a render loop using
requestAnimationFrame
.
Here's our loop
function render(time) { time *= 0.001; // convert time to seconds cube.rotation.x = time; cube.rotation.y = time; renderer.render(scene, camera); requestAnimationFrame(render); } requestAnimationFrame(render);
requestAnimationFrame
is a request to the browser that you want to animate something.
You pass it a function to be called. In our case that function is render
. The browser
will call your function and if you update anything related to the display of the
page the browser will re-render the page. In our case we are calling three's
renderer.render
function which will draw our scene.
requestAnimationFrame
passes the time since the page loaded to
our function. That time is passed in milliseconds. I find it's much
easier to work with seconds so here we're converting that to seconds.
We then set the cube's X and Y rotation to the current time. These rotations are in radians. There are 2 pi radians in a circle so our cube should turn around once on each axis in about 6.28 seconds.
We then render the scene and request another animation frame to continue our loop.
Outside the loop we call requestAnimationFrame
one time to start the loop.
It's a little better but it's still hard to see the 3d. What would help is to add some lighting so let's add a light. There are many kinds of lights in three.js which we'll go over in a future article. For now let's create a directional light.
{ const color = 0xFFFFFF; const intensity = 3; const light = new THREE.DirectionalLight(color, intensity); light.position.set(-1, 2, 4); scene.add(light); }
Directional lights have a position and a target. Both default to 0, 0, 0. In our case we're setting the light's position to -1, 2, 4 so it's slightly on the left, above, and behind our camera. The target is still 0, 0, 0 so it will shine toward the origin.
We also need to change the material. The MeshBasicMaterial
is not affected by
lights. Let's change it to a MeshPhongMaterial
which is affected by lights.
-const material = new THREE.MeshBasicMaterial({color: 0x44aa88}); // greenish blue +const material = new THREE.MeshPhongMaterial({color: 0x44aa88}); // greenish blue
Here is our new program structure
And here it is working.
It should now be pretty clearly 3D.
Just for the fun of it let's add 2 more cubes.
We'll use the same geometry for each cube but make a different material so each cube can be a different color.
First we'll make a function that creates a new material with the specified color. Then it creates a mesh using the specified geometry and adds it to the scene and sets its X position.
function makeInstance(geometry, color, x) { const material = new THREE.MeshPhongMaterial({color}); const cube = new THREE.Mesh(geometry, material); scene.add(cube); cube.position.x = x; return cube; }
Then we'll call it 3 times with 3 different colors and X positions
saving the Mesh
instances in an array.
const cubes = [ makeInstance(geometry, 0x44aa88, 0), makeInstance(geometry, 0x8844aa, -2), makeInstance(geometry, 0xaa8844, 2), ];
Finally we'll spin all 3 cubes in our render function. We compute a slightly different rotation for each one.
function render(time) { time *= 0.001; // convert time to seconds cubes.forEach((cube, ndx) => { const speed = 1 + ndx * .1; const rot = time * speed; cube.rotation.x = rot; cube.rotation.y = rot; }); ...
and here's that.
If you compare it to the top down diagram above you can see it matches our expectations. With cubes at X = -2 and X = +2 they are partially outside our frustum. They are also somewhat exaggeratedly warped since the field of view across the canvas is so extreme.
Our program now has this structure
As you can see we have 3 Mesh
objects each referencing the same BoxGeometry
.
Each Mesh
references a unique MeshPhongMaterial
so that each cube can have
a different color.
I hope this short intro helps to get things started. Next up we'll cover making our code responsive so it is adaptable to multiple situations.


Ruby Classes
In Ruby, classes are a way to expand one's program beyond individual methods. Classes allow developers to assign attributes (attr_) and pass specific methods to these attributes. Classes also allow us to pass variables between methods of these classes through the use of instance variables (@variable). Here's an example:
What you see above is a new class called Bicycle. In line 1, I defined the class. In lines 3 through 5, I gave my new Bicycle class 3 attributes: an owner, a type, and a rider. Attribute methods allow for the decreasing of repetitiveness in defining instance variables in code. The attribute reader method is a concise way of creating a method that reads and returns the value of the instance variable with the same name as the method. Like the reader method, the writer method allows one to write or set instance variables in a more concise way. An attr_accessor method combines the functionality of both the reader and the writer method into one, and is thus even more concise. In lines 7 through 11, I defined a method which allows me to assign values to my bicycles attributes.
Once I've finished creating and defining the parameters of my new class, I went ahead and tested my new class in lines 19 through 21. I made my rider ride and this was the result:
Ruby classes are great ways to simulate real world objects within Ruby. This is just a very simple application of the concept. Why don't you try making your own Ruby class?


Alice's Birthday
The film "Alice's Birthday" tells about the extraordinary adventures of the girl Alice and her friend - the little archeologist Rrrr in the past of the distant alien planet Koleida. Alice and Rrrr show courage, ingenuity and endurance, learn not to lose heart in the most hopeless situations, and learn what real friendship is. As a result, they managed to change the course of history and bring the whole planet back to life!


{% extends "iadmin/nojs/index.html" %}
{% block content %}
Ooops!
|
|
It looks like you have Javascript disabled or NoScript plugin. In order to keep the content of
this website free we must display advertisements on it that require Javascript. If you want to
view the content of this website the author wishes that you to turn Javascript back on or turn
off NoScript. This message will go away once Javascript is enabled and you press the "Back"
button.
How to re-enable Javascript:
Chrome:
Preferences -> Security Tab -> Make sure "Enable JavaScript" is checked.
|
|
|
{% endblock content %}


2016-06-22
Brand-new web site desing was revealed.
2016-02-09
2008 academic year (11th students; including 38 people) got started to take part in lectures.


500 benefit from JBDC employee engagement conference
THE Jamaica Business Development Corporation (JBDC) is hailing its recently staged employee engagement conference as a success, with more than 500 participants from local and regional public-and private-sector entities benefiting from the two-day event.
The conference was held at the Jamaica Conference Centre in downtown Kingston under the theme 'Employee Experience 3D – Design. Develop. Deliver'.
JBDC's assistant manager, project management and research development, Sasha McCalla said the conference received high scores from the attendees.
“Both keynote and conference sessions were high-energy and filled with actionable tools that our attendees could take back to organisations. We were able to engage practitioners who are experienced, who have developed and implemented strategies and walked away with success stories,” she said.
McCalla said that the presence of JBDC clients at the conference was a highlight.
“We wanted to create a platform for our clients to showcase their products so we had a few of our clients – Bella Day Spa, Your True Shade Cosmetics, Bresheh and Senior Accounting Services.
“We were able to give our clients an opportunity to meet new people and maintain linkages with large corporations because we had a lot of private- and public-sector entities,” she noted.
As the planning for next year's conference begins, McCalla is encouraging employers to implement the various strategies discussed at this year's event in order to increase employee engagement.
“Without a staff that is engaged, without a team that feels fully committed to the purpose, you cannot drive business results, and that was one of the key takeaways. As leaders, we have to ensure that we are providing tools and strategies to cultivate and sustain an engaged workforce,” she said.
The two-day conference had more than 30 presenters, including three keynote speakers. Topics included Employee Engagement Policy Creation; Health and Wellness, and Brain-based Formula for Emotional Engagement.
– JIS


|
ActiveTcl User Guide
|
||
Tcl_TraceVar, Tcl_TraceVar2, Tcl_UntraceVar, Tcl_UntraceVar2, Tcl_VarTraceInfo, Tcl_VarTraceInfo2 - monitor accesses to a variable
#include <tcl.h>
int
Tcl_TraceVar(interp, varName, flags, proc,
clientData)
int
Tcl_TraceVar2(interp, name1, name2, flags, proc,
clientData)
Tcl_UntraceVar(interp, varName, flags, proc,
clientData)
Tcl_UntraceVar2(interp, name1, name2, flags, proc,
clientData)
ClientData
Tcl_VarTraceInfo(interp, varName, flags, proc,
prevClientData)
ClientData
Tcl_VarTraceInfo2(interp, name1, name2, flags, proc,
prevClientData)
Tcl_TraceVar allows a C procedure to monitor and control access to a Tcl variable, so that the C procedure is invoked whenever the variable is read or written or unset. If the trace is created successfully then Tcl_TraceVar returns TCL_OK. If an error occurred (e.g. varName specifies an element of an array, but the actual variable isn't an array) then TCL_ERROR is returned and an error message is left in the interpreter's result.
The flags argument to Tcl_TraceVar indicates when the trace procedure is to be invoked and provides information for setting up the trace. It consists of an OR-ed combination of any of the following values:
Whenever one of the specified operations occurs on the variable, proc will be invoked. It should have arguments and result that match the type Tcl_VarTraceProc:
typedef char *Tcl_VarTraceProc( ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags);
The clientData and interp parameters will have the same values as those passed to Tcl_TraceVar when the trace was created. ClientData typically points to an application-specific data structure that describes what to do when proc is invoked. Name1 and name2 give the name of the traced variable in the normal two-part form (see the description of Tcl_TraceVar2 below for details). Flags is an OR-ed combination of bits providing several pieces of information. One of the bits TCL_TRACE_READS, TCL_TRACE_WRITES, TCL_TRACE_ARRAY, or TCL_TRACE_UNSETS will be set in flags to indicate which operation is being performed on the variable. The bit TCL_GLOBAL_ONLY will be set whenever the variable being accessed is a global one not accessible from the current level of procedure call: the trace procedure will need to pass this flag back to variable-related procedures like Tcl_GetVar if it attempts to access the variable. The bit TCL_NAMESPACE_ONLY will be set whenever the variable being accessed is a namespace one not accessible from the current level of procedure call: the trace procedure will need to pass this flag back to variable-related procedures like Tcl_GetVar if it attempts to access the variable. The bit TCL_TRACE_DESTROYED will be set in flags if the trace is about to be destroyed; this information may be useful to proc so that it can clean up its own internal data structures (see the section TCL_TRACE_DESTROYED below for more details). Lastly, the bit TCL_INTERP_DESTROYED will be set if the entire interpreter is being destroyed. When this bit is set, proc must be especially careful in the things it does (see the section TCL_INTERP_DESTROYED below). The trace procedure's return value should normally be NULL; see ERROR RETURNS below for information on other possibilities.
Tcl_UntraceVar may be used to remove a trace. If the variable specified by interp, varName, and flags has a trace set with flags, proc, and clientData, then the corresponding trace is removed. If no such trace exists, then the call to Tcl_UntraceVar has no effect. The same bits are valid for flags as for calls to Tcl_TraceVar.
Tcl_VarTraceInfo may be used to retrieve information about traces set on a given variable. The return value from Tcl_VarTraceInfo is the clientData associated with a particular trace. The trace must be on the variable specified by the interp, varName, and flags arguments (only the TCL_GLOBAL_ONLY and TCL_NAMESPACE_ONLY bits from flags is used; other bits are ignored) and its trace procedure must the same as the proc argument. If the prevClientData argument is NULL then the return value corresponds to the first (most recently created) matching trace, or NULL if there are no matching traces. If the prevClientData argument isn't NULL, then it should be the return value from a previous call to Tcl_VarTraceInfo. In this case, the new return value will correspond to the next matching trace after the one whose clientData matches prevClientData, or NULL if no trace matches prevClientData or if there are no more matching traces after it. This mechanism makes it possible to step through all of the traces for a given variable that have the same proc.
The procedures Tcl_TraceVar2, Tcl_UntraceVar2, and Tcl_VarTraceInfo2 are identical to Tcl_TraceVar, Tcl_UntraceVar, and Tcl_VarTraceInfo, respectively, except that the name of the variable consists of two parts. Name1 gives the name of a scalar variable or array, and name2 gives the name of an element within an array. When name2 is NULL, name1 may contain both an array and an element name: if the name contains an open parenthesis and ends with a close parenthesis, then the value between the parentheses is treated as an element name (which can have any string value) and the characters before the first open parenthesis are treated as the name of an array variable. If name2 is NULL and name1 does not refer to an array element it means that either the variable is a scalar or the trace is to be set on the entire array rather than an individual element (see WHOLE-ARRAY TRACES below for more information).
During read, write, and array traces, the trace procedure can read, write, or unset the traced variable using Tcl_GetVar2, Tcl_SetVar2, and other procedures. While proc is executing, traces are temporarily disabled for the variable, so that calls to Tcl_GetVar2 and Tcl_SetVar2 will not cause proc or other trace procedures to be invoked again. Disabling only occurs for the variable whose trace procedure is active; accesses to other variables will still be traced. However, if a variable is unset during a read or write trace then unset traces will be invoked.
During unset traces the variable has already been completely expunged. It is possible for the trace procedure to read or write the variable, but this will be a new version of the variable. Traces are not disabled during unset traces as they are for read and write traces, but existing traces have been removed from the variable before any trace procedures are invoked. If new traces are set by unset trace procedures, these traces will be invoked on accesses to the variable by the trace procedures.
When read tracing has been specified for a variable, the trace procedure will be invoked whenever the variable's value is read. This includes set Tcl commands, $-notation in Tcl commands, and invocations of the Tcl_GetVar and Tcl_GetVar2 procedures. Proc is invoked just before the variable's value is returned. It may modify the value of the variable to affect what is returned by the traced access. If it unsets the variable then the access will return an error just as if the variable never existed.
When write tracing has been specified for a variable, the trace procedure will be invoked whenever the variable's value is modified. This includes set commands, commands that modify variables as side effects (such as catch and scan), and calls to the Tcl_SetVar and Tcl_SetVar2 procedures). Proc will be invoked after the variable's value has been modified, but before the new value of the variable has been returned. It may modify the value of the variable to override the change and to determine the value actually returned by the traced access. If it deletes the variable then the traced access will return an empty string.
When array tracing has been specified, the trace procedure will be invoked at the beginning of the array command implementation, before any of the operations like get, set, or names have been invoked. The trace procedure can modify the array elements with Tcl_SetVar and Tcl_SetVar2.
When unset tracing has been specified, the trace procedure will be invoked whenever the variable is destroyed. The traces will be called after the variable has been completely unset.
If a call to Tcl_TraceVar or Tcl_TraceVar2 specifies the name of an array variable without an index into the array, then the trace will be set on the array as a whole. This means that proc will be invoked whenever any element of the array is accessed in the ways specified by flags. When an array is unset, a whole-array trace will be invoked just once, with name1 equal to the name of the array and name2 NULL; it will not be invoked once for each element.
It is possible for multiple traces to exist on the same variable. When this happens, all of the trace procedures will be invoked on each access, in order from most-recently-created to least-recently-created. When there exist whole-array traces for an array as well as traces on individual elements, the whole-array traces are invoked before the individual-element traces. If a read or write trace unsets the variable then all of the unset traces will be invoked but the remainder of the read and write traces will be skipped.
Under normal conditions trace procedures should return NULL, indicating successful completion. If proc returns a non-NULL value it signifies that an error occurred. The return value must be a pointer to a static character string containing an error message, unless (exactly one of) the TCL_TRACE_RESULT_DYNAMIC and TCL_TRACE_RESULT_OBJECT flags is set, which specify that the result is either a dynamic string (to be released with ckfree) or a Tcl_Obj* (cast to char* and to be released with Tcl_DecrRefCount) containing the error message. If a trace procedure returns an error, no further traces are invoked for the access and the traced access aborts with the given message. Trace procedures can use this facility to make variables read-only, for example (but note that the value of the variable will already have been modified before the trace procedure is called, so the trace procedure will have to restore the correct value).
The return value from proc is only used during read and write tracing. During unset traces, the return value is ignored and all relevant trace procedures will always be invoked.
A trace procedure can be called at any time, even when there is a partially-formed result in the interpreter's result area. If the trace procedure does anything that could damage this result (such as calling Tcl_Eval) then it must save the original values of the interpreter's result and freeProc fields and restore them before it returns.
It is legal to set a trace on an undefined variable. The variable will still appear to be undefined until the first time its value is set. If an undefined variable is traced and then unset, the unset will fail with an error (``no such variable''), but the trace procedure will still be invoked.
In an unset callback to proc, the TCL_TRACE_DESTROYED bit is set in flags if the trace is being removed as part of the deletion. Traces on a variable are always removed whenever the variable is deleted; the only time TCL_TRACE_DESTROYED isn't set is for a whole-array trace invoked when only a single element of an array is unset.
When an interpreter is destroyed, unset traces are called for all of its variables. The TCL_INTERP_DESTROYED bit will be set in the flags argument passed to the trace procedures. Trace procedures must be extremely careful in what they do if the TCL_INTERP_DESTROYED bit is set. It is not safe for the procedures to invoke any Tcl procedures on the interpreter, since its state is partially deleted. All that trace procedures should do under these circumstances is to clean up and free their own internal data structures.
Tcl doesn't do any error checking to prevent trace procedures from misusing the interpreter during traces with TCL_INTERP_DESTROYED set.
Array traces are not yet integrated with the Tcl "info exists" command, nor is there Tcl-level access to array traces.
Copyright © 1989-1993 The Regents of the University of California. Copyright © 1994-1996 Sun Microsystems, Inc. Copyright © 1995-1997 Roger E. Critchlow Jr.


--- layout: archive title: Zulip Chat Archive permalink: /stream/113488-general/topic/what.20does.20parsing.20mean.3F.html ---
Does parsing include typeclass resolution?
If I see parsing took 22.8s
does that mean there are a lot of mega typeclass resolutions?
I don't think it does
I think typeclass resolution is part of elaboration
What about coercions?
so it's mainly the tactics?
has the slow tactics parsing been solved in Lean 3.8?
can I make Lean tell me how much time it uses to parse each tactic?
I think you already know all the profiling tricks
you can try to incrementally add tactics to get a sense of the time of each
{% endraw %}Last updated: Apr 24 2020 at 19:02 UTC


Antioch
About the server
Transactions in Antioch
Working with Resources
Working with Annotations
Working with Provenance
Searching in Antioch
Nederlab scenarios
Diagnostics
Java Client
W3C Web Annotations


hh
:
mm
Current
Tokyo
London
New York
Date:
Get month fridays
-
Is month long?
-
Days of shortest week in month
-
Full weeks in month
-


About Me
First Name
This is required.
Last Name
This is required.
Theatre/Company Name
This is required.
Additional Media
Please upload any additional documents (e.g. resume, video, headshots)
Choose Files
Submit


Download App
Update
Logout
classmates
Last registered:
Preferences
Update your Preferences to stay connected with other classmates!
Slack Username -
It will be shared with other Students!
Track
Nanodegree Tracks
Current Project
Current Project
First Language
Preferred Language #1
Second Language
Preferred Language #2
Save
Find a Classmate!


To the most pious and outstanding and in every respect most worthy lord, King David, Flaccus Alcuin wishes the eternal salvation of true blessedness in Christ.
Indeed I, your servant Flaccus, following your encouragement and good will, am busy supplying to some throughout the houses of Saint Martin the sweet honey of the sacred scriptures. I yearn to intoxicate others with the pure old wine of ancient teachings. I will undertake to nurture others with the fruit of grammatical subtlety. And I am eager to illuminate some in the order of the stars, just as some painter does to the ceiling of a great house.
I have been many things to many people, in order to instruct many for the profit of God's holy church and for the decorum of your imperial kingdom, that the grace of all-powerful God not be empty in me, and that the generosity of your kindness not be in vain.
But to some extent it seems to me, your humble servant, that there is a lack of the better books of scholastic education that I had in my homeland through my teacher's good and devoted industry, and even through my own hard labor, such as it was.
For that reason I tell your excellency my plan, in hopes that it might perchance please you, that I send some of our lads back to Britain, to remove from there whatever is needful for us, and bring the flowers of Britain back to France. Then there could be an enclosed garden not only in York but in Tours as well - flowers of Paradise with fruit-laden trees - so that the South Wind might come and blow over the gardens of the Loire, letting their sweet odors flow and at last allowing to happen what follows in the Song of Songs, from which I took this metaphor: "Let my beloved come into his garden and eat the fruit of his trees. And let him say to his young men: 'Eat, my friends, drink and be merry, dear ones.' I am asleep, but my heart is awake."
Or that maxim of the prophet Isaiah, urging one to learn wisdom: "All you who thirst, come to the waters; and you who do not have silver, be quick, buy and eat; come, buy wine and milk without silver and without any exchange."
These are the things that your most noble purpose is not unaware of, how we are encouraged to learn wisdom in all the pages of holy scripture.
There is nothing loftier for securing a blessed life, nothing more pleasant for practice, nothing more powerful against sin, nothing more praiseworthy in any lofty station and also, according to the words of philosophers, nothing more necessary for ruling a people, nothing better for arranging a life in the best morals than the honor of wisdom, the praise of discipline and the virtue of learning.
Whence even the most wise Solomon exclaims about the glory of wisdom: "Wisdom is better than every precious thing, and everything desired can not be compared to it. This wisdom is what exalts the humble, what honors the exalted. It is what allows kings to reign and lawgivers to ordain justice. It allows princes to rule and the powerful to decree justice. Blessed are they who guard its ways, and blessed those who watch at its doors every day."
My lord king, encourage all the youths in your excellency's palace to learn this with all zeal and to master it in daily practice, however much they might accomplish in it in their blooming age, so that they might be held to pass their old age in honor of worth and through it they may prevail to arrive at everlasting blessedness.
Indeed, I, according to the measure of my natural capacity, won't be slow in planting the seeds of wisdom among your subjects in these regions, mindful of this statement: "Sow your seed in the morning and don't let your hand rest in the evening; for you don't know which will grow better, this one or that one. And if both are the same, it is better." In the morning I sowed in Britain. with studies that have flourished for a generation. Now however, with my blood growing cold, as if in the evening, I do not rest from sowing in France, hoping that both, God's grace granting, will grow.
Though my body is broken, I have for solace the pronouncement of Saint Jerome, who said in a letter to Nepotianus: "Nearly all the strengths of the body are altered in the old and, while only wisdom increases, the others decline." And a little later: "Truly, the old age of those who prepared their youth in noble accomplishments and pondered on the Lord's law day and night, becomes more learned with age, more familiar with experience, wiser with the advance of time; and reaps the sweetest fruits of their long-standing studies." And in this letter whoever wishes can read and understand much about the glory of wisdom and the studies of old times, and how much the ancients strove to flourish in the splendor of wisdom.


So my darling husband is in the habit of dropping me off in a foreign country and then leaving two or three days later. Which is once again the case as he’s been in DC all week on business. (Yes, I understand that I’m getting to live in Paris, so pity will be hard to come by.) The good news is we found an apartment and hope to move in on Monday before Mike leaves, again, this time for Ottawa. It will be such a relief to no longer be living out of a suitcase. The apartment is super cute and very Parisian – with an an office and a guest room. We’ll have to become far more stylish just to live in it, but it’s Paris, so anything is possible, right?
As for Mike, he’s seen more of DC in the past week, and even more of the inside of a Boeing 767 and is generally confused about what time zone he’s in.
On my end, one of the first orders of business is to try to learn the language. At least enough to make it look like I’m trying. Because the French love Americans who can’t talk French. ESPECIALLY Parisians.
My intention is to learn a new word or phrase daily and test it out in a real world setting. Today’s modest goal - feeding myself.
The cutest little bakery, Paul Pâtissier, is only a few blocks from where we’ve been staying in the second arrondissement. It’s cruel how Paul taunts you with beautiful tartlettes aux pommes in the window and the smell of croissants au chocolat wafting halfway down the block. Mercifully, I have yet to learn the phrase, “I’ll take one of everything.”
I’m happy to report I SUCCESSFULLY ordered a chicken salad and canelé – in FRENCH!  I uttered a few phrases that maybe, possibly sounded French, pointed at items behind the window counter and the nice man handed me my dinner. Victory!
Thinking I’d add some additional protein to the meal, I set out to find sardines at the Franprix down the street. Apparently, the French can squeeze an impressive number of canned items into one tiny city market. I found one that looked like sardines, but there’s a 50-50 chance I’m now eating cat food. Surely French cats eat well, no?
comments powered by Disqus


A GDB stub consists of two parts, support for the exception handler, and the exception handler itself. The exception handler needs to communicate to GDB on the host whenever there is a breakpoint exception. When GDB starts a program running on the target, it's polling the serial port during execution looking for any debug packets. So when a breakpoint occurs, the exception handler needs to save state, and send a GDB remote protocol packet to GDB on the host. GDB takes any output that isn't a debug command packet and displays it in the command window.
Support for the exception handler varies between processors, but the minimum supported functions are those needed by GDB. These are functions to support the reading and writing of registers, the reading and writing of memory, start execution at an address, single step, and last signal. Sometimes other functions for adjusting the baud rate, or resetting the hardware are implemented.
Once GDB gets the command packet from the breakpoint, it will read a few
registers and memory locations an then wait for the user. When the user
types run
or continue
a continue
command is issued
to the backend, and control returns from the breakpoint routine to the
application.


Bug {{bugNumber}}:
This bug is from a file called {{_bugInfoObject.fileName}}.java
You should focus your attention on this method:
Here is a brief description of the bug that may help you:
Out of time!
You are out of time to work on this problem. Press OK to move on to the next one.


* Source files may not contain third-party content (e.g. icons, images)
Color Palette
Click the color to copy code.


wal-telegram
Generates themes for Telegram based the colors generated by pywal/wal.
More information: home page
- Generate with wal's palette and the current wallpaper (feh only):
wal-telegram
- Generate with wal's palette and a specified background image:
wal-telegram --background=path/to/image
- Generate with wal's palette and a colored background based on the palette:
wal-telegram --tiled
- Apply a gaussian blur on the background image:
wal-telegram -g
- Specify a location for the generated theme (default is `$XDG_CACHE_HOME/wal-telegram` or `~/.cache/wal-telegram`):
wal-telegram --destination=path/to/destination
- Restart the telegram app after generation:
wal-telegram --restart


UX Limitations¶
torch.func, like JAX, has restrictions around what can be transformed. In general, JAX’s limitations are that transforms only work with pure functions: that is, functions where the output is completely determined by the input and that do not involve side effects (like mutation).
We have a similar guarantee: our transforms work well with pure functions. However, we do support certain in-place operations. On one hand, writing code compatible with function transforms may involve changing how you write PyTorch code, on the other hand, you may find that our transforms let you express things that were previously difficult to express in PyTorch.
General limitations¶
All torch.func transforms share a limitation in that a function should not assign to global variables. Instead, all outputs to a function must be returned from the function. This restriction comes from how torch.func is implemented: each transform wraps Tensor inputs in special torch.func Tensor subclasses that facilitate the transform.
So, instead of the following:
import torch
from torch.func import grad
# Don't do this
intermediate = None
def f(x):
global intermediate
intermediate = x.sin()
z = intermediate.sin()
return z
x = torch.randn([])
grad_x = grad(f)(x)
Please rewrite f
to return intermediate
:
def f(x):
intermediate = x.sin()
z = intermediate.sin()
return z, intermediate
grad_x, intermediate = grad(f, has_aux=True)(x)
torch.autograd APIs¶
If you are trying to use a torch.autograd
API like torch.autograd.grad
or torch.autograd.backward
inside of a function being transformed by
vmap()
or one of torch.func’s AD transforms (vjp()
, jvp()
,
jacrev()
, jacfwd()
), the transform may not be able to transform over it.
If it is unable to do so, you’ll receive an error message.
This is a fundamental design limitation in how PyTorch’s AD support is implemented
and the reason why we designed the torch.func library. Please instead use the torch.func
equivalents of the torch.autograd
APIs:
- torch.autograd.grad
, Tensor.backward
-> torch.func.vjp
or torch.func.grad
- torch.autograd.functional.jvp
-> torch.func.jvp
- torch.autograd.functional.jacobian
-> torch.func.jacrev
or torch.func.jacfwd
- torch.autograd.functional.hessian
-> torch.func.hessian
vmap limitations¶
Note
vmap()
is our most restrictive transform.
The grad-related transforms (grad()
, vjp()
, jvp()
) do not
have these limitations. jacfwd()
(and hessian()
, which is
implemented with jacfwd()
) is a composition of vmap()
and
jvp()
so it also has these limitations.
vmap(func)
is a transform that returns a function that maps func
over
some new dimension of each input Tensor. The mental model for vmap is that it is
like running a for-loop: for pure functions (i.e. in the absence of side
effects), vmap(f)(x)
is equivalent to:
torch.stack([f(x_i) for x_i in x.unbind(0)])
Mutation: Arbitrary mutation of Python data structures¶
In the presence of side effects, vmap()
no longer acts like it is running
a for-loop. For example, the following function:
def f(x, list):
list.pop()
print("hello!")
return x.sum(0)
x = torch.randn(3, 1)
lst = [0, 1, 2, 3]
result = vmap(f, in_dims=(0, None))(x, lst)
will print “hello!” once and pop only one element from lst
.
vmap()
executes f
a single time, so all side effects only happen once.
This is a consequence of how vmap is implemented. torch.func has a special,
internal BatchedTensor class. vmap(f)(*inputs)
takes all Tensor inputs,
turns them into BatchedTensors, and calls f(*batched_tensor_inputs)
.
BatchedTensor overrides the PyTorch API to produce batched (i.e. vectorized)
behavior for each PyTorch operator.
Mutation: in-place PyTorch Operations¶
You might be here due to receiving an error about vmap-incompatible in-place
operations. vmap()
will raise an error if it encounters an unsupported PyTorch
in-place operation and it will succeed otherwise. Unsupported operations
are those that would cause a Tensor with more elements to be written to a
Tensor with fewer elements. Here’s an example of how this can occur:
def f(x, y):
x.add_(y)
return x
x = torch.randn(1)
y = torch.randn(3, 1) # When vmapped over, looks like it has shape [1]
# Raises an error because `x` has fewer elements than `y`.
vmap(f, in_dims=(None, 0))(x, y)
x
is a Tensor with one element, y
is a Tensor with three elements.
x + y
has three elements (due to broadcasting), but attempting to write
three elements back into x
, which only has one element, raises an error
due to attempting to write three elements into a Tensor with a single element.
There is no problem if the Tensor being written to is batched under
vmap()
(i.e. it is being vmapped over).
def f(x, y):
x.add_(y)
return x
x = torch.randn(3, 1)
y = torch.randn(3, 1)
expected = x + y
# Does not raise an error because x is being vmapped over.
vmap(f, in_dims=(0, 0))(x, y)
assert torch.allclose(x, expected)
One common fix for this is to replace calls to factory functions with their “new_*” equivalent. For example:
Replace
torch.zeros()
withTensor.new_zeros()
Replace
torch.empty()
withTensor.new_empty()
To see why this helps, consider the following.
def diag_embed(vec):
assert vec.dim() == 1
result = torch.zeros(vec.shape[0], vec.shape[0])
result.diagonal().copy_(vec)
return result
vecs = torch.tensor([[0., 1, 2], [3., 4, 5]])
# RuntimeError: vmap: inplace arithmetic(self, *extra_args) is not possible ...
vmap(diag_embed)(vecs)
Inside of vmap()
, result
is a Tensor of shape [3, 3].
However, although vec
looks like it has shape [3], vec
actually has
underlying shape [2, 3].
It is not possible to copy vec
into result.diagonal()
, which has
shape [3], because it has too many elements.
def diag_embed(vec):
assert vec.dim() == 1
result = vec.new_zeros(vec.shape[0], vec.shape[0])
result.diagonal().copy_(vec)
return result
vecs = torch.tensor([[0., 1, 2], [3., 4, 5]])
vmap(diag_embed)(vecs)
Replacing torch.zeros()
with Tensor.new_zeros()
makes it so that
result
has an underlying Tensor of shape [2, 3, 3], so it is now possible
to copy vec
, which has underlying shape [2, 3], into result.diagonal()
.
Mutation: out= PyTorch Operations¶
vmap()
doesn’t support the out=
keyword argument in PyTorch operations.
It will error out gracefully if it encounters that in your code.
This is not a fundamental limitation; we could theoretically support this in the future but we have chosen not to for now.
Data-dependent Python control flow¶
We don’t yet support vmap
over data-dependent control flow. Data-dependent
control flow is when the condition of an if-statement, while-loop, or
for-loop is a Tensor that is being vmap
’ed over. For example, the
following will raise an error message:
def relu(x):
if x > 0:
return x
return 0
x = torch.randn(3)
vmap(relu)(x)
However, any control flow that is not dependent on the values in vmap
’ed
tensors will work:
def custom_dot(x):
if x.dim() == 1:
return torch.dot(x, x)
return (x * x).sum()
x = torch.randn(3)
vmap(custom_dot)(x)
JAX supports transforming over
data-dependent control flow
using special control flow operators (e.g. jax.lax.cond
, jax.lax.while_loop
).
We’re investigating adding equivalents of those to PyTorch.
Data-dependent operations (.item())¶
We do not (and will not) support vmap over a user-defined function that calls
.item()
on a Tensor. For example, the following will raise an error message:
def f(x):
return x.item()
x = torch.randn(3)
vmap(f)(x)
Please try to rewrite your code to not use .item()
calls.
You may also encounter an error message about using .item()
but you might
not have used it. In those cases, it is possible that PyTorch internally is
calling .item()
– please file an issue on GitHub and we’ll fix
PyTorch internals.
Dynamic shape operations (nonzero and friends)¶
vmap(f)
requires that f
applied to every “example” in your input
returns a Tensor with the same shape. Operations such as torch.nonzero
,
torch.is_nonzero
are not supported and will error as a result.
To see why, consider the following example:
xs = torch.tensor([[0, 1, 2], [0, 0, 3]])
vmap(torch.nonzero)(xs)
torch.nonzero(xs[0])
returns a Tensor of shape 2;
but torch.nonzero(xs[1])
returns a Tensor of shape 1.
We are unable to construct a single Tensor as an output;
the output would need to be a ragged Tensor (and PyTorch does not yet have
the concept of a ragged Tensor).
Randomness¶
The user’s intention when calling a random operation can be unclear. Specifically, some users may want
the random behavior to be the same across batches while others may want it to differ across batches.
To address this, vmap
takes a randomness flag.
The flag can only be passed to vmap and can take on 3 values, “error,” “different,” or “same,” defaulting to error. Under “error” mode, any call to a random function will produce an error asking the user to use one of the other two flags based on their use case.
Under “different” randomness, elements in a batch produce different random values. For instance,
def add_noise(x):
y = torch.randn(()) # y will be different across the batch
return x + y
x = torch.ones(3)
result = vmap(add_noise, randomness="different")(x) # we get 3 different values
Under “same” randomness, elements in a batch produce same random values. For instance,
def add_noise(x):
y = torch.randn(()) # y will be the same across the batch
return x + y
x = torch.ones(3)
result = vmap(add_noise, randomness="same")(x) # we get the same value, repeated 3 times
Warning
Our system only determine the randomness behavior of PyTorch operators and cannot control the behavior of other libraries, like numpy. This is similar to JAX’s limitations with their solutions
Note
Multiple vmap calls using either type of supported randomness will not produce
the same results. Like with standard PyTorch, a user can get randomness reproducibility through
either using torch.manual_seed()
outside of vmap or by using generators.
Note
Finally, our randomness differs from JAX because we aren’t using a stateless PRNG, in part because PyTorch doesn’t have full support for a stateless PRNG. Instead, we’ve introduced a flag system to allow for the most common forms of randomness that we see. If your use case does not fit these forms of randomness, please file an issue.


Provides the standard kernel implementation. The classes contined in this package should be considered private implementation details of XBean, and should not be used directly.


This application requires JavaScript
Please check to make sure JavaScript is enabled in your browser and try again.


Showing latest available information (ratings are not averaged)
Match details: Q= matchNum ?>
info_outlineYou're looking at a match for a team other than your own.
!= HtmlService.createHtmlOutputFromFile('globalStyles').getContent(); ?>
if(!reqFromAndroidApp) { ?>


A clean and adaptable view of all beers that are available. Sort it any way that You want.
Set the preferred characteristics of a beer that You want, and see what suits You'r needs
Feeling lucky, or just want to try something new? Give BeerRollete a whirl. You might find something amazing on the way
Want to act all cool, and knowledgeable like the guys from RateBeer? Now You can, locally on PickBeer


NewsOrNot
About Us
How
Juhi
"the best"
Rahil
"the best of all"
Somil
"the best of all"
Sohan
"the best of all"
Vishesh
"the best of all"


--- layout: default title: Shift Matrix ---
To request to be scheduled for a certain day, send mail to Troy (shift manager).
| green | Sufficient amount of cooks |
| red | Need more cooks!! |
| name (shares) | current term | next term | ||
|---|---|---|---|---|
| range | # shifts |
range | # shifts |
| green | This term has been fulfilled |
| red | This person needs to take more shifts! |


Welcome to my workshop!
Currently available things
TOP Map File Creator
ADOFAI Map Invisiblifier
More coming soon. Probably.
haha empty space at the side go brrr


Large and small buttons can be implemented through .btn-lg and .btn-sm classes respectively.
.btn-lg
.btn-sm


App
object
when the Spring Framework starts.Environment
associated with this component.null
if the key cannot be resolved.defaultValue
if the key cannot be resolved.ObjectMapper
registered in the Spring contextObjectMapper
registered in the Spring context


Name
Email
Actions
Name
Email
Actions
Name
Email
Actions
Name
Email
Actions
John Covv
<EMAIL_ADDRESS>Delete
Michael Jackson
<EMAIL_ADDRESS>Delete
Julia
<EMAIL_ADDRESS>Delete
Martin Madrazo
<EMAIL_ADDRESS>Delete


Gecode::ViewBrancher< ViewSel > Class Template Reference
[Generic brancher based on view and value selection]
Generic brancher by view selection. More...
#include <brancher.hpp>
Public Member Functions | |
| virtual bool | status (const Space &home) const |
| Check status of brancher, return true if alternatives left. | |
| virtual size_t | dispose (Space &home) |
| Delete brancher and return its size. | |
Protected Member Functions | |
| Pos | pos (Space &home) |
| Return position information. | |
| ViewSel::View | view (const Pos &p) const |
| Return view according to position information p. | |
| ViewBrancher (Space &home, bool share, ViewBrancher &b) | |
| Constructor for cloning b. | |
| ViewBrancher (Home home, ViewArray< typename ViewSel::View > &x, ViewSel &vi_s, BranchFilter bf0=NULL) | |
| Constructor for creation. | |
Protected Attributes | |
| ViewArray< typename ViewSel::View > | x |
| Views to branch on. | |
| int | start |
| Unassigned views start at x[start]. | |
| ViewSel | viewsel |
| View selection object. | |
| BranchFilter | bf |
| Branch filter function. |
Detailed Description
template<class ViewSel>
class Gecode::ViewBrancher< ViewSel >
Generic brancher by view selection.
Implements a baseclass for view-based branching for an array of views (of type ViewSel::View). The behaviour is defined by the class ViewSel (which view is selected for branching).
Definition at line 76 of file brancher.hpp.
Constructor & Destructor Documentation
| Gecode::ViewBrancher< ViewSel >::ViewBrancher | ( | Space & | home, | |
| bool | share, | |||
| ViewBrancher< ViewSel > & | b | |||
| ) | [inline, protected] |
Constructor for cloning b.
Definition at line 288 of file brancher.hpp.
| Gecode::ViewBrancher< ViewSel >::ViewBrancher | ( | Home | home, | |
| ViewArray< typename ViewSel::View > & | x, | |||
| ViewSel & | vi_s, | |||
| BranchFilter | bf0 = NULL | |||
| ) | [inline, protected] |
Constructor for creation.
Definition at line 280 of file brancher.hpp.
Member Function Documentation
| Pos Gecode::ViewBrancher< ViewSel >::pos | ( | Space & | home | ) | [inline, protected] |
Return position information.
Definition at line 318 of file brancher.hpp.
| ViewSel::View Gecode::ViewBrancher< ViewSel >::view | ( | const Pos & | p | ) | const [inline, protected] |
Return view according to position information p.
Definition at line 338 of file brancher.hpp.
| bool Gecode::ViewBrancher< ViewSel >::status | ( | const Space & | home | ) | const [inline, virtual] |
Check status of brancher, return true if alternatives left.
Implements Gecode::Brancher.
Definition at line 297 of file brancher.hpp.
| size_t Gecode::ViewBrancher< ViewSel >::dispose | ( | Space & | home | ) | [inline, virtual] |
Delete brancher and return its size.
Reimplemented from Gecode::Actor.
Reimplemented in Gecode::ViewValBrancher< ViewSel, ValSel >.
Definition at line 344 of file brancher.hpp.
Member Data Documentation
ViewArray<typename ViewSel::View> Gecode::ViewBrancher< ViewSel >::x [protected] |
Views to branch on.
Definition at line 79 of file brancher.hpp.
int Gecode::ViewBrancher< ViewSel >::start [mutable, protected] |
Unassigned views start at x[start].
Definition at line 81 of file brancher.hpp.
ViewSel Gecode::ViewBrancher< ViewSel >::viewsel [protected] |
View selection object.
Definition at line 83 of file brancher.hpp.
BranchFilter Gecode::ViewBrancher< ViewSel >::bf [protected] |
Branch filter function.
Definition at line 85 of file brancher.hpp.
The documentation for this class was generated from the following file:
- gecode/kernel/brancher.hpp (Revision: 12001)


This software is free. Please let us know when you find a problem or fix a bug.
Thanks to MapTools.org, libtiff now uses bugzilla to track bugs. All bugs filed in the older bugzilla at bugzilla.remotesensing.org (pre April 2008) have unfortunately been lost.
If you think you've discovered a bug, please first check to see if it is already known by looking at the list of already reported bugs. You can do so by visiting the buglist at http://bugzilla.maptools.org/buglist.cgi?product=libtiff. Also verify that the problem is still reproducable with the current development software from CVS.
If you'd like to enter a new bug, you can do so at http://bugzilla.maptools.org/enter_bug.cgi?product=libtiff.
If you'd like to inform us about some kind of security issue that should not be disclosed for a period of time, then you can contact maintainers directly. Send a copies of your report to the following people: Frank Warmerdam<EMAIL_ADDRESS>Andrey Kiselev<EMAIL_ADDRESS>Of course, reporting bugs is no substitute for discussion. The<EMAIL_ADDRESS>mailing list is for users of this software, and discussion TIFF issues in general. It is managed with the Mailman software, and the web interface for subscribing and managing your access to the list is at:
http://lists.maptools.org/mailman/listinfo/tiff
Posts to the list are only accepted from members of the list in order to limit the amount of spam propagated. Also, to be approved as a member you will need to email the list administrator with a brief description of why you are interested in TIFF so we can weed out spammers.
A Long Term Archive including recent messages, and most messages back to 1993, with search capabilities is available, and has been prepared and hosted by AWare Systems.


if x < 10:
print('x is less than 10')
else:
print('x is not less than 10')
Syntax:
if age > 18:
print('You are no longer in grade school')
elif age > 15:
print('You are in highschool')
elif age > 10:
print('You are in middle school')
elif age > 5:
print('You are in elementary school')
else:
print('You are too young to go to school')
answer = print('Do you like Python? (please say Yes)')
while answer != 'Yes':
print('Are you sure? Python is really great!')
answer = print('Do you like Python? (please say Yes)')
counter = 1
while counter < 10:
print('Counting:', counter)
counter = counter + 1
Write a script to ask current user for his/her birth year, then ask for the current year. Validate that the birth year is less than current year and print out the current user's age. Print an error otherwise.
answer = input('What is your birth year? ')
birth_year = int(answer)
current_year = int(input('What is the current year? '))
if birth_year <= current_year:
age = current_year - birth_year
if age > 1:
print('You are', age, 'years old')
else:
print('You are', age, 'year old')
else:
print('Invalid input! Birth year can not be in the future')
Write a script to print out a multiplication table for a number specified by the user.
number = int(input('Please enter a number between 1 and 10: '))
if number < 1:
print('Number is too small. It must be between 1 and 10')
elif number > 10:
print('Number is too large. It must be between 1 and 10')
else:
print('Multiplication table for', number)
counter = 1
while counter <= 10:
print(number, '*', counter, '=', number * counter)
counter = counter + 1
print('Done!')
Print out the multiplication tables from 1 to 10
Print out the multiplication tables from 1 to 10
number = 1
while number <= 10:
print('Multiplication table number', number)
counter = 1
while counter <= 10:
print(number, '*', counter, '=', number * counter)
counter = counter + 1
number = number + 1
number = int(input('Please enter a number between 20 and 100: '))
if number < 20:
print('Error! Number must be between 20 and 100, inclusive')
elif number > 100:
print('Error! Number must be between 20 and 100, inclusive')
else:
counter = 1
while counter <= number:
if counter % 3 == 0:
print('Fizz')
elif counter % 5 == 0:
print('Buzz')
elif counter % 15 == 0:
print('FizzBuzz')
else:
print(counter)
counter = counter + 1
number = int(input('Please enter a number between 20 and 100: '))
if number < 20:
print('Error! Number must be between 20 and 100, inclusive')
elif number > 100:
print('Error! Number must be between 20 and 100, inclusive')
else:
counter = 1
while counter <= number:
if counter % 15 == 0:
print('FizzBuzz')
elif counter % 3 == 0:
print('Fizz')
elif counter % 5 == 0:
print('Buzz')
else:
print(counter)
counter = counter + 1
if counter % 3 == 0:
print('Fizz')
if counter % 5 == 0:
print('Buzz')
number = int(input('Please enter a number between 20 and 100: '))
# skip validation to save some room
counter = 1
while counter <= number:
special = False
if counter % 3 == 0:
print(counter, 'turns into Fizz')
special = True
if counter % 5 == 0:
print(counter, 'turns into Buzz')
special = True
if not special:
print(counter)
counter = counter + 1
number = int(input('Please enter a number between 20 and 100: '))
# skip validation to save some room
counter = 1
while counter <= number:
special = False
output = ''
if counter % 3 == 0:
output = output + 'Fizz'
special = True
if counter % 5 == 0:
output = output + 'Buzz'
special = True
if not special:
output = str(counter)
print(output)
counter = counter + 1
for item in collection:
print(item)
do_something_with_item
alist = [1, 2, "three"]
>>> alist = ['a', 'b', 'c', 'd']
>>> len(alist)
4
Example: Count from 1 to 10
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print('Counting', len(numbers), 'times:')
for number in numbers:
print(number)
for number in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:
print(number)
>>> alist = [1, 2]
>>> print(len(alist))
2
>>> alist.append("three")
>>> print(len(alist))
3
>>> for item in alist:
... print(item)
1
2
three
>>> alist = [1, 2, 3, 4]
>>> x = alist.pop()
>>> print (x, alist)
4 [1, 2, 3]
>>> print(alist.pop(1))
2
>>> print(alist)
[1, 3]
>>> alist=[1, 2, 3]
>>> del alist[1]
>>> print(len(alist))
2
>>> print(alist)
[1, 3]
alist = [1, 2, 3]
alist[1] = 'x'
print(alist) # print [1, x, 3]
>>> listA = [1, 2, 3]
>>> listB = [4, 5, 6]
>>> listC = listA + listB
>>> print(listC)
[1, 2, 3, 4, 5, 6]
>>> listD = listA.append(listB)
>>> print(listD)
None
>>> print(listA)
[1, 2, 3, [4, 5, 6]]
>>> # ListA is a list of 4 items. The 4th item (index 3) is a list with 3 items
for number in range(20):
print(number) # print 0, 1, 2, .... 17, 18, 19. NOT 20
range(10) # generate [0, 1, 2, 3, ...., 8, 9]
range(2, 10) # generate [2, 3, ... 8, 9]
range(2, 10, 2) # generate [2, 4, 6, 8]
>>> alist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> aslice = alist[1:3] # gives [2, 3]. Does NOT include 4
>>> aslice = alist[4::2] # gives [5, 7, 9]
>>> aslice = alist[:4:] # gives [1, 2, 3, 4]
>>> aslice = alist[::-1] # gives [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
>>> aslice = alist[1:3:-1] # gives []: empty list
>>> aslice = alist[3:1:-1] # gives [3, 2]
atuple= (1, 2, 3, 4)
(w, x, y, z) = atuple
print(x) # print 2
print(z) # print 4
x, y, z = 1, 2, 3
print(x) # print 1
print(z) # print 3
x, y = 1, 2, 3 # Throw an error: ValueError: too many values to unpack
>>> alist = [1, 2, 3]
>>> alist.append(3)
>>> print(alist)
[1, 2, 3, 3]
>>> aset = set(alist)
>>> print(aset)
{1, 2, 3}
>>> aset = {1, 2, 3}
>>> aset.add(4)
>>> print(aset)
{1, 2, 3, 4}
>>> aset.remove(2)
>>> print(aset)
{1, 3, 4}
adict = {
'key0': 'value0',
'key1': 10,
5 : 'five'
'5' : 'five string'
}
print(adict['key0']) # print 'value0'
print(adict[5]) # print 'five'
print(adict[5] == adict['5']) # print False
How do we iterate a dictionary?
adict = {'k0': '0', 'k1': 1}
keys = adict.keys() # keys is ['key0', 'k1']
for key in keys:
value = adict[key]
print(key, "->", value)
adict = {'k0': '0', 'k1': 1}
for key in adict:
print(key, '->', adict[key])
s = 'this is a string'
s[0] = 'T' # Error: TypeError: 'str' object does not support item assignment
s = 'This is a string'
for c in s:
print('A character:', c)
if x in collection:
Example #1: read a string from the user, and convert each numeric character to a full string: '0' becomes 'zero', '1' becomes 'one'
Example #1: read a string from the user, and convert each numeric character to a full string: '0' becomes 'zero', '1' becomes 'one'
statement = input('Please enter a statement, with some numbers: ')
output = '' # initialize the output, which is concaternated as we go through the loop
for c in statement:
if c == '0':
output = output + 'zero'
elif c == '1':
output = output + 'one'
...
elif c == '9':
output = output + 'nine'
else:
output = output + c
print(output)
Example #1: read a string from the user, and convert each numeric character to a full string: '0' becomes 'zero', '1' becomes 'one'
Most if/elif problem can be solved using dictionary and a membership check
statement = input('Please enter a statement with some numbers: ')
mapping = {'0': 'zero', '1': 'one', '2': 'two' } # and more
keys = mapping.keys()
output = ''
for c in statement:
if c in keys:
output = output + mapping[c]
else:
output = output + c
print(output)
Example #2: count upto a number specified by the user, and print if the current number is odd or even
num = int(input('Please enter a number greater than 5: '))
while num <= 5:
print('Bad input! Number must be greater than 5')
num = int(input('Please enter a number greater than 5: '))
for n in range(num):
if n % 2 == 0:
print(n, 'is an even number')
else:
print(n, 'is an odd number')
Example #2: count upto a number specified by the user, and print if the current number is odd or even
num = int(input('Please enter a number greater than 5: '))
while num <= 5:
print('Bad input! Number must be greater than 5')
num = int(input('Please enter a number greater than 5: '))
oddeven = ['even', 'odd'] # why? can we set it to be ['odd', 'even']?
for n in range(num):
remainder = n % 2
print(n, 'is an', oddeven[remainder], 'number' )
Example #3: Keep asking user to enter a list of names. Then, evenly try to split them into 3 groups: A, B and C. Print out the result
Jon belongs to group A
Nancy belongs to group B
Steve belongs to group C
...
Totally, there are 20 people
Example #3: Keep asking user to enter a list of names. Then, evenly try to split them into 3 groups: A, B and C. Print out the result
groups = ['A', 'B', 'C']
number_of_groups = len(group)
names = []
name = input('Please enter a name. Enter "finish" to stop: ')
while not name == 'finish':
names.append(name)
name = input('Please enter a name. Enter "finish" to stop: ')
count = 0
for name in names:
print(name, 'belongs to group', groups[count % number_of_groups])
count = count + 1
print('Totally, there are', count, 'people')
Example #4: Ask a user for a statement. Then, count the number of apperance for each letter
s = input('Please enter a sentence: ')
result = {} # initialize an empty dictionary
for c in s:
if c in result.keys():
count = result[c]
count = count + 1
result[c] = count
else:
result[c] = 1
for c in result:
print(c, 'appears', result[c], 'times')