| 1 | /* =========================================================== | |
| 2 | * JFreeChart : a free chart library for the Java(tm) platform | |
| 3 | * =========================================================== | |
| 4 | * | |
| 5 | * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. | |
| 6 | * | |
| 7 | * Project Info: http://www.jfree.org/jfreechart/index.html | |
| 8 | * | |
| 9 | * This library is free software; you can redistribute it and/or modify it | |
| 10 | * under the terms of the GNU Lesser General Public License as published by | |
| 11 | * the Free Software Foundation; either version 2.1 of the License, or | |
| 12 | * (at your option) any later version. | |
| 13 | * | |
| 14 | * This library is distributed in the hope that it will be useful, but | |
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
| 16 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | |
| 17 | * License for more details. | |
| 18 | * | |
| 19 | * You should have received a copy of the GNU Lesser General Public | |
| 20 | * License along with this library; if not, write to the Free Software | |
| 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | |
| 22 | * USA. | |
| 23 | * | |
| 24 | * [Java is a trademark or registered trademark of Sun Microsystems, Inc. | |
| 25 | * in the United States and other countries.] | |
| 26 | * | |
| 27 | * ---------------------- | |
| 28 | * XYTitleAnnotation.java | |
| 29 | * ---------------------- | |
| 30 | * (C) Copyright 2007-2009, by Object Refinery Limited and Contributors. | |
| 31 | * | |
| 32 | * Original Author: David Gilbert (for Object Refinery Limited); | |
| 33 | * Contributor(s): Andrew Mickish; | |
| 34 | * Peter Kolb (patch 2809117); | |
| 35 | * | |
| 36 | * Changes: | |
| 37 | * -------- | |
| 38 | * 02-Feb-2007 : Version 1 (DG); | |
| 39 | * 30-Apr-2007 : Fixed equals() method (DG); | |
| 40 | * 26-Feb-2008 : Fixed NullPointerException when drawing chart with a null | |
| 41 | * ChartRenderingInfo - see patch 1901599 by Andrew Mickish (DG); | |
| 42 | * 03-Sep-2008 : Moved from experimental to main (DG); | |
| 43 | * 24-Jun-2009 : Fire change events (see patch 2809117 by PK) (DG); | |
| 44 | * | |
| 45 | */ | |
| 46 | ||
| 47 | package org.jfree.chart.annotations; | |
| 48 | ||
| 49 | import java.awt.Graphics2D; | |
| 50 | import java.awt.geom.Point2D; | |
| 51 | import java.awt.geom.Rectangle2D; | |
| 52 | import java.io.Serializable; | |
| 53 | import org.jfree.chart.axis.AxisLocation; | |
| 54 | import org.jfree.chart.axis.ValueAxis; | |
| 55 | import org.jfree.chart.block.BlockParams; | |
| 56 | import org.jfree.chart.block.EntityBlockResult; | |
| 57 | import org.jfree.chart.block.RectangleConstraint; | |
| 58 | import org.jfree.chart.plot.Plot; | |
| 59 | import org.jfree.chart.plot.PlotOrientation; | |
| 60 | import org.jfree.chart.plot.PlotRenderingInfo; | |
| 61 | import org.jfree.chart.plot.XYPlot; | |
| 62 | import org.jfree.chart.title.Title; | |
| 63 | import org.jfree.chart.util.HashUtilities; | |
| 64 | import org.jfree.chart.util.ObjectUtilities; | |
| 65 | import org.jfree.chart.util.PublicCloneable; | |
| 66 | import org.jfree.chart.util.RectangleAnchor; | |
| 67 | import org.jfree.chart.util.RectangleEdge; | |
| 68 | import org.jfree.chart.util.Size2D; | |
| 69 | import org.jfree.data.Range; | |
| 70 | import org.jfree.chart.util.XYCoordinateType; | |
| 71 | ||
| 72 | /** | |
| 73 | * An annotation that allows any {@link Title} to be placed at a location on | |
| 74 | * an {@link XYPlot}. | |
| 75 | * | |
| 76 | * @since 1.0.11 | |
| 77 | */ | |
| 78 | public class XYTitleAnnotation extends AbstractXYAnnotation | |
| 79 | implements Cloneable, PublicCloneable, Serializable { | |
| 80 | ||
| 81 | /** For serialization. */ | |
| 82 | private static final long serialVersionUID = -4364694501921559958L; | |
| 83 | ||
| 84 | /** The coordinate type. */ | |
| 85 | private XYCoordinateType coordinateType; | |
| 86 | ||
| 87 | /** The x-coordinate (in data space). */ | |
| 88 | private double x; | |
| 89 | ||
| 90 | /** The y-coordinate (in data space). */ | |
| 91 | private double y; | |
| 92 | ||
| 93 | /** The maximum width. */ | |
| 94 | private double maxWidth; | |
| 95 | ||
| 96 | /** The maximum height. */ | |
| 97 | private double maxHeight; | |
| 98 | ||
| 99 | /** The title. */ | |
| 100 | private Title title; | |
| 101 | ||
| 102 | /** | |
| 103 | * The title anchor point. | |
| 104 | */ | |
| 105 | private RectangleAnchor anchor; | |
| 106 | ||
| 107 | /** | |
| 108 | * Creates a new annotation to be displayed at the specified (x, y) | |
| 109 | * location. | |
| 110 | * | |
| 111 | * @param x the x-coordinate (in data space). | |
| 112 | * @param y the y-coordinate (in data space). | |
| 113 | * @param title the title (null not permitted). | |
| 114 | */ | |
| 115 | public XYTitleAnnotation(double x, double y, Title title) { | |
| 116 | this(x, y, title, RectangleAnchor.CENTER); | |
| 117 | } | |
| 118 | ||
| 119 | /** | |
| 120 | * Creates a new annotation to be displayed at the specified (x, y) | |
| 121 | * location. | |
| 122 | * | |
| 123 | * @param x the x-coordinate (in data space). | |
| 124 | * @param y the y-coordinate (in data space). | |
| 125 | * @param title the title (null not permitted). | |
| 126 | * @param anchor the title anchor (null not permitted). | |
| 127 | */ | |
| 128 | public XYTitleAnnotation(double x, double y, Title title, | |
| 129 | RectangleAnchor anchor) { | |
| 130 | super(); | |
| 131 |
1
1. |
if (title == null) { |
| 132 | throw new IllegalArgumentException("Null 'title' argument."); | |
| 133 | } | |
| 134 |
1
1. |
if (anchor == null) { |
| 135 | throw new IllegalArgumentException("Null 'anchor' argument."); | |
| 136 | } | |
| 137 | this.coordinateType = XYCoordinateType.RELATIVE; | |
| 138 | this.x = x; | |
| 139 | this.y = y; | |
| 140 | this.maxWidth = 0.0; | |
| 141 | this.maxHeight = 0.0; | |
| 142 | this.title = title; | |
| 143 | this.anchor = anchor; | |
| 144 | } | |
| 145 | ||
| 146 | /** | |
| 147 | * Returns the coordinate type (set in the constructor). | |
| 148 | * | |
| 149 | * @return The coordinate type (never null). | |
| 150 | */ | |
| 151 | public XYCoordinateType getCoordinateType() { | |
| 152 |
1
1. getCoordinateType : mutated return of Object value for org/jfree/chart/annotations/XYTitleAnnotation::getCoordinateType to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return this.coordinateType; |
| 153 | } | |
| 154 | ||
| 155 | /** | |
| 156 | * Returns the x-coordinate for the annotation. | |
| 157 | * | |
| 158 | * @return The x-coordinate. | |
| 159 | */ | |
| 160 | public double getX() { | |
| 161 |
1
1. getX : replaced return of double value with -(x + 1) for org/jfree/chart/annotations/XYTitleAnnotation::getX → NO_COVERAGE |
return this.x; |
| 162 | } | |
| 163 | ||
| 164 | /** | |
| 165 | * Returns the y-coordinate for the annotation. | |
| 166 | * | |
| 167 | * @return The y-coordinate. | |
| 168 | */ | |
| 169 | public double getY() { | |
| 170 |
1
1. getY : replaced return of double value with -(x + 1) for org/jfree/chart/annotations/XYTitleAnnotation::getY → NO_COVERAGE |
return this.y; |
| 171 | } | |
| 172 | ||
| 173 | /** | |
| 174 | * Returns the title for the annotation. | |
| 175 | * | |
| 176 | * @return The title. | |
| 177 | */ | |
| 178 | public Title getTitle() { | |
| 179 |
1
1. getTitle : mutated return of Object value for org/jfree/chart/annotations/XYTitleAnnotation::getTitle to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return this.title; |
| 180 | } | |
| 181 | ||
| 182 | /** | |
| 183 | * Returns the title anchor for the annotation. | |
| 184 | * | |
| 185 | * @return The title anchor. | |
| 186 | */ | |
| 187 | public RectangleAnchor getTitleAnchor() { | |
| 188 |
1
1. getTitleAnchor : mutated return of Object value for org/jfree/chart/annotations/XYTitleAnnotation::getTitleAnchor to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return this.anchor; |
| 189 | } | |
| 190 | ||
| 191 | /** | |
| 192 | * Returns the maximum width. | |
| 193 | * | |
| 194 | * @return The maximum width. | |
| 195 | */ | |
| 196 | public double getMaxWidth() { | |
| 197 |
1
1. getMaxWidth : replaced return of double value with -(x + 1) for org/jfree/chart/annotations/XYTitleAnnotation::getMaxWidth → NO_COVERAGE |
return this.maxWidth; |
| 198 | } | |
| 199 | ||
| 200 | /** | |
| 201 | * Sets the maximum width and sends an | |
| 202 | * {@link AnnotationChangeEvent} to all registered listeners. | |
| 203 | * | |
| 204 | * @param max the maximum width (0.0 or less means no maximum). | |
| 205 | */ | |
| 206 | public void setMaxWidth(double max) { | |
| 207 | this.maxWidth = max; | |
| 208 |
1
1. setMaxWidth : removed call to org/jfree/chart/annotations/XYTitleAnnotation::fireAnnotationChanged → NO_COVERAGE |
fireAnnotationChanged(); |
| 209 | } | |
| 210 | ||
| 211 | /** | |
| 212 | * Returns the maximum height. | |
| 213 | * | |
| 214 | * @return The maximum height. | |
| 215 | */ | |
| 216 | public double getMaxHeight() { | |
| 217 |
1
1. getMaxHeight : replaced return of double value with -(x + 1) for org/jfree/chart/annotations/XYTitleAnnotation::getMaxHeight → NO_COVERAGE |
return this.maxHeight; |
| 218 | } | |
| 219 | ||
| 220 | /** | |
| 221 | * Sets the maximum height and sends an | |
| 222 | * {@link AnnotationChangeEvent} to all registered listeners. | |
| 223 | * | |
| 224 | * @param max the maximum height. | |
| 225 | */ | |
| 226 | public void setMaxHeight(double max) { | |
| 227 | this.maxHeight = max; | |
| 228 |
1
1. setMaxHeight : removed call to org/jfree/chart/annotations/XYTitleAnnotation::fireAnnotationChanged → NO_COVERAGE |
fireAnnotationChanged(); |
| 229 | } | |
| 230 | ||
| 231 | /** | |
| 232 | * Draws the annotation. This method is called by the drawing code in the | |
| 233 | * {@link XYPlot} class, you don't normally need to call this method | |
| 234 | * directly. | |
| 235 | * | |
| 236 | * @param g2 the graphics device. | |
| 237 | * @param plot the plot. | |
| 238 | * @param dataArea the data area. | |
| 239 | * @param domainAxis the domain axis. | |
| 240 | * @param rangeAxis the range axis. | |
| 241 | * @param rendererIndex the renderer index. | |
| 242 | * @param info if supplied, this info object will be populated with | |
| 243 | * entity information. | |
| 244 | */ | |
| 245 | public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, | |
| 246 | ValueAxis domainAxis, ValueAxis rangeAxis, | |
| 247 | int rendererIndex, | |
| 248 | PlotRenderingInfo info) { | |
| 249 | ||
| 250 | PlotOrientation orientation = plot.getOrientation(); | |
| 251 | AxisLocation domainAxisLocation = plot.getDomainAxisLocation(); | |
| 252 | AxisLocation rangeAxisLocation = plot.getRangeAxisLocation(); | |
| 253 | RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( | |
| 254 | domainAxisLocation, orientation); | |
| 255 | RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( | |
| 256 | rangeAxisLocation, orientation); | |
| 257 | Range xRange = domainAxis.getRange(); | |
| 258 | Range yRange = rangeAxis.getRange(); | |
| 259 | double anchorX = 0.0; | |
| 260 | double anchorY = 0.0; | |
| 261 |
1
1. draw : negated conditional → SURVIVED |
if (this.coordinateType == XYCoordinateType.RELATIVE) { |
| 262 |
2
1. draw : Replaced double multiplication with division → SURVIVED 2. draw : Replaced double addition with subtraction → SURVIVED |
anchorX = xRange.getLowerBound() + (this.x * xRange.getLength()); |
| 263 |
2
1. draw : Replaced double multiplication with division → SURVIVED 2. draw : Replaced double addition with subtraction → SURVIVED |
anchorY = yRange.getLowerBound() + (this.y * yRange.getLength()); |
| 264 | } | |
| 265 | else { | |
| 266 | anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge); | |
| 267 | anchorY = rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge); | |
| 268 | } | |
| 269 | ||
| 270 | float j2DX = (float) domainAxis.valueToJava2D(anchorX, dataArea, | |
| 271 | domainEdge); | |
| 272 | float j2DY = (float) rangeAxis.valueToJava2D(anchorY, dataArea, | |
| 273 | rangeEdge); | |
| 274 | float xx = 0.0f; | |
| 275 | float yy = 0.0f; | |
| 276 |
1
1. draw : negated conditional → SURVIVED |
if (orientation == PlotOrientation.HORIZONTAL) { |
| 277 | xx = j2DY; | |
| 278 | yy = j2DX; | |
| 279 | } | |
| 280 |
1
1. draw : negated conditional → SURVIVED |
else if (orientation == PlotOrientation.VERTICAL) { |
| 281 | xx = j2DX; | |
| 282 | yy = j2DY; | |
| 283 | } | |
| 284 | ||
| 285 | double maxW = dataArea.getWidth(); | |
| 286 | double maxH = dataArea.getHeight(); | |
| 287 |
1
1. draw : negated conditional → SURVIVED |
if (this.coordinateType == XYCoordinateType.RELATIVE) { |
| 288 |
2
1. draw : changed conditional boundary → SURVIVED 2. draw : negated conditional → SURVIVED |
if (this.maxWidth > 0.0) { |
| 289 |
1
1. draw : Replaced double multiplication with division → NO_COVERAGE |
maxW = maxW * this.maxWidth; |
| 290 | } | |
| 291 |
2
1. draw : changed conditional boundary → SURVIVED 2. draw : negated conditional → SURVIVED |
if (this.maxHeight > 0.0) { |
| 292 |
1
1. draw : Replaced double multiplication with division → NO_COVERAGE |
maxH = maxH * this.maxHeight; |
| 293 | } | |
| 294 | } | |
| 295 |
1
1. draw : negated conditional → SURVIVED |
if (this.coordinateType == XYCoordinateType.DATA) { |
| 296 | maxW = this.maxWidth; | |
| 297 | maxH = this.maxHeight; | |
| 298 | } | |
| 299 | RectangleConstraint rc = new RectangleConstraint( | |
| 300 | new Range(0, maxW), new Range(0, maxH)); | |
| 301 | ||
| 302 | Size2D size = this.title.arrange(g2, rc); | |
| 303 | Rectangle2D titleRect = new Rectangle2D.Double(0, 0, size.width, | |
| 304 | size.height); | |
| 305 | Point2D anchorPoint = RectangleAnchor.coordinates(titleRect, | |
| 306 | this.anchor); | |
| 307 |
1
1. draw : Replaced float subtraction with addition → SURVIVED |
xx = xx - (float) anchorPoint.getX(); |
| 308 |
1
1. draw : Replaced float subtraction with addition → SURVIVED |
yy = yy - (float) anchorPoint.getY(); |
| 309 |
1
1. draw : removed call to java/awt/geom/Rectangle2D::setRect → SURVIVED |
titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight()); |
| 310 | BlockParams p = new BlockParams(); | |
| 311 |
1
1. draw : negated conditional → KILLED |
if (info != null) { |
| 312 |
1
1. draw : negated conditional → NO_COVERAGE |
if (info.getOwner().getEntityCollection() != null) { |
| 313 |
1
1. draw : removed call to org/jfree/chart/block/BlockParams::setGenerateEntities → NO_COVERAGE |
p.setGenerateEntities(true); |
| 314 | } | |
| 315 | } | |
| 316 | Object result = this.title.draw(g2, titleRect, p); | |
| 317 |
1
1. draw : negated conditional → KILLED |
if (info != null) { |
| 318 |
1
1. draw : negated conditional → NO_COVERAGE |
if (result instanceof EntityBlockResult) { |
| 319 | EntityBlockResult ebr = (EntityBlockResult) result; | |
| 320 |
1
1. draw : removed call to org/jfree/chart/entity/EntityCollection::addAll → NO_COVERAGE |
info.getOwner().getEntityCollection().addAll( |
| 321 | ebr.getEntityCollection()); | |
| 322 | } | |
| 323 | String toolTip = getToolTipText(); | |
| 324 | String url = getURL(); | |
| 325 |
2
1. draw : negated conditional → NO_COVERAGE 2. draw : negated conditional → NO_COVERAGE |
if (toolTip != null || url != null) { |
| 326 |
1
1. draw : removed call to org/jfree/chart/annotations/XYTitleAnnotation::addEntity → NO_COVERAGE |
addEntity(info, new Rectangle2D.Float(xx, yy, |
| 327 | (float) size.width, (float) size.height), | |
| 328 | rendererIndex, toolTip, url); | |
| 329 | } | |
| 330 | } | |
| 331 | } | |
| 332 | ||
| 333 | /** | |
| 334 | * Tests this object for equality with an arbitrary object. | |
| 335 | * | |
| 336 | * @param obj the object (null permitted). | |
| 337 | * | |
| 338 | * @return A boolean. | |
| 339 | */ | |
| 340 | public boolean equals(Object obj) { | |
| 341 |
1
1. equals : negated conditional → KILLED |
if (obj == this) { |
| 342 |
1
1. equals : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
| 343 | } | |
| 344 |
1
1. equals : negated conditional → KILLED |
if (!(obj instanceof XYTitleAnnotation)) { |
| 345 |
1
1. equals : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
| 346 | } | |
| 347 | XYTitleAnnotation that = (XYTitleAnnotation) obj; | |
| 348 |
1
1. equals : negated conditional → KILLED |
if (this.coordinateType != that.coordinateType) { |
| 349 |
1
1. equals : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
| 350 | } | |
| 351 |
1
1. equals : negated conditional → KILLED |
if (this.x != that.x) { |
| 352 |
1
1. equals : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED |
return false; |
| 353 | } | |
| 354 |
1
1. equals : negated conditional → KILLED |
if (this.y != that.y) { |
| 355 |
1
1. equals : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED |
return false; |
| 356 | } | |
| 357 |
1
1. equals : negated conditional → KILLED |
if (this.maxWidth != that.maxWidth) { |
| 358 |
1
1. equals : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
| 359 | } | |
| 360 |
1
1. equals : negated conditional → KILLED |
if (this.maxHeight != that.maxHeight) { |
| 361 |
1
1. equals : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
| 362 | } | |
| 363 |
1
1. equals : negated conditional → KILLED |
if (!ObjectUtilities.equal(this.title, that.title)) { |
| 364 |
1
1. equals : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED |
return false; |
| 365 | } | |
| 366 |
1
1. equals : negated conditional → KILLED |
if (!this.anchor.equals(that.anchor)) { |
| 367 |
1
1. equals : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
| 368 | } | |
| 369 |
1
1. equals : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED |
return super.equals(obj); |
| 370 | } | |
| 371 | ||
| 372 | /** | |
| 373 | * Returns a hash code for this object. | |
| 374 | * | |
| 375 | * @return A hash code. | |
| 376 | */ | |
| 377 | public int hashCode() { | |
| 378 | int result = 193; | |
| 379 | result = HashUtilities.hashCode(result, this.anchor); | |
| 380 | result = HashUtilities.hashCode(result, this.coordinateType); | |
| 381 | result = HashUtilities.hashCode(result, this.x); | |
| 382 | result = HashUtilities.hashCode(result, this.y); | |
| 383 | result = HashUtilities.hashCode(result, this.maxWidth); | |
| 384 | result = HashUtilities.hashCode(result, this.maxHeight); | |
| 385 | result = HashUtilities.hashCode(result, this.title); | |
| 386 |
1
1. hashCode : replaced return of integer sized value with (x == 0 ? 1 : 0) → SURVIVED |
return result; |
| 387 | } | |
| 388 | ||
| 389 | /** | |
| 390 | * Returns a clone of the annotation. | |
| 391 | * | |
| 392 | * @return A clone. | |
| 393 | * | |
| 394 | * @throws CloneNotSupportedException if the annotation can't be cloned. | |
| 395 | */ | |
| 396 | public Object clone() throws CloneNotSupportedException { | |
| 397 |
1
1. clone : mutated return of Object value for org/jfree/chart/annotations/XYTitleAnnotation::clone to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return super.clone(); |
| 398 | } | |
| 399 | ||
| 400 | } | |
Mutations | ||
| 131 |
1.1 |
|
| 134 |
1.1 |
|
| 152 |
1.1 |
|
| 161 |
1.1 |
|
| 170 |
1.1 |
|
| 179 |
1.1 |
|
| 188 |
1.1 |
|
| 197 |
1.1 |
|
| 208 |
1.1 |
|
| 217 |
1.1 |
|
| 228 |
1.1 |
|
| 261 |
1.1 |
|
| 262 |
1.1 2.2 |
|
| 263 |
1.1 2.2 |
|
| 276 |
1.1 |
|
| 280 |
1.1 |
|
| 287 |
1.1 |
|
| 288 |
1.1 2.2 |
|
| 289 |
1.1 |
|
| 291 |
1.1 2.2 |
|
| 292 |
1.1 |
|
| 295 |
1.1 |
|
| 307 |
1.1 |
|
| 308 |
1.1 |
|
| 309 |
1.1 |
|
| 311 |
1.1 |
|
| 312 |
1.1 |
|
| 313 |
1.1 |
|
| 317 |
1.1 |
|
| 318 |
1.1 |
|
| 320 |
1.1 |
|
| 325 |
1.1 2.2 |
|
| 326 |
1.1 |
|
| 341 |
1.1 |
|
| 342 |
1.1 |
|
| 344 |
1.1 |
|
| 345 |
1.1 |
|
| 348 |
1.1 |
|
| 349 |
1.1 |
|
| 351 |
1.1 |
|
| 352 |
1.1 |
|
| 354 |
1.1 |
|
| 355 |
1.1 |
|
| 357 |
1.1 |
|
| 358 |
1.1 |
|
| 360 |
1.1 |
|
| 361 |
1.1 |
|
| 363 |
1.1 |
|
| 364 |
1.1 |
|
| 366 |
1.1 |
|
| 367 |
1.1 |
|
| 369 |
1.1 |
|
| 386 |
1.1 |
|
| 397 |
1.1 |


Animated Canvas
start
stop
restart
pause frame
previous frame
next frame
pause set
previous set
next set


>
|
Allegro CL version 8.0 |
This is a preliminary document which will be updated over time. Upates will be available for downloading.
Introduction and a simple example
LHTML parse output format
Case mode notes
Parsing HTML comments
Parsing ") --> ((:script "this will not be parsed"))
Since, some HTML pages contain special XML/SGML tags, non-comment tags starting with '<!' are treated specially:
(parse-html "<!doctype this is some text>") --> ((:!doctype " this is some text"))
There is plenty of illegal and deprecated HTML on the web that popular browsers nonetheless successfully display. The parse-html parser is generous - it will not raise an error condition upon encountering most input. In particular, it does not maintain a list of legal HTML tags and will successfully parse nonsense input.
For example,
(parse-html "<this> <is> <some> <nonsense> <input>") --> ((:this (:is (:some (:nonsense :input)))))
In some situations, you may prefer a two-pass parse that results in a parse where deep nesting related to unrecognized tags is minimized:
(let ((string "<this> <is> <some> <nonsense> </some> <input>")) (multiple-value-bind (res rogues) (parse-html string :collect-rogue-tags t) (declare (ignorable res)) (parse-html string :no-body-tags rogues))) --> (:this :is (:some (:nonsense)) :input)
See the descriptions of the collect-rogue-tags and no-body-tags keyword arguments to parse-html descriptions in the reference section below for more information.
As per the HTML 4.0 specification, attributes without specified values are given a lower case string value that matches the attribute name.
For example,
(parse-html "
") --> (((:p :here "here" :are "are" :some "some" :attributes "attributes")))
Existing HTML pages often have character format tags that are interleaved among other tags. Such interleaving is removed in a manner consistent with the HTML 4.0 specification.
For example,
(parse-html "
Here is bold text
that spanstwo paragraphs") --> ((:p "Here is " (:b "bold text")) (:p (:b "that spans") "two paragraphs"))
Arguments: input-source &key callbacks callback-only collect-rogue-tags no-body-tags eliminate-blank-strings parse-entities
Returns LHTML output, as described above in this document.
Methods specializing on the required argument are defined for stream
(reads output from the stream) and string
(parses the argument string).
parse-html (p stream) &key callbacks callback-only collect-rogue-tags no-body-tagsparse-html (str string) &key callbacks callback-only collect-rogue-tags no-body-tagsparse-html (file t) &key callbacks callback-only collect-rogue-tags no-body-tags
The t method assumes the argument is a pathname suitable for use with the with-open-file macro.
Arguments: stream read-sequence-func callback-only callbacks collect-rogue-tags no-body-tags
This function may be used when more control is needed for supplying the HTML input. The read-sequence-func argument, if non-nil, should be a function object or a symbol naming a function. When phtml-internal requires another buffer of HTML input, it will invoke the read-sequence-func function with two arguments - the first argument is an internal buffer character array and the second argument is the phtml-internal stream argument. If read-sequence-fun is nil, phtml-internal will invoke read-sequence to fill the buffer. The read-sequence-func function must return the number of character array elements successfully stored in the buffer.
Copyright (c) 2000, 2001, 2004 by Franz Inc. All rights reserved.
Documentation for Allegro CL version 7.0. This is the initial (unrevised) page.
Created 2004.9.12.
|
Allegro CL version 8.0 |


CHiVE: Examples of side-by-side comparison
Examples where CHiVE was preferred
5 examples where audio produced based on the sentence prosody embedding produced by the hierarchical CHiVE model was preferred over the audio produced by the non-hierarchical baseline.
| Baseline | CHiVE |
|---|---|
Examples where the baseline was preferred
5 examples where audio produced based on the sentence prosody embedding produced by the non-hierarchical baseline was preferred over the audio produced by hierarchical CHiVE model.
| Baseline | CHiVE |
|---|---|
These audio samples go with CHiVE: Varying Prosody in Speech Synthesis with a Linguistically Driven Dynamic Hierarchical Conditional Variational Network, Wan, V., Chan, C.-a., Kenter, T., Vit, J., and Clark, R. A., Proceedings of the Thirty-sixth International Conference on Machine Learning (ICML 2019), 2019, side-by-side comparison between CHiVE and a baseline non-hierarchical model (Section 4.1, Table 1 in the paper).


Members
addListeners
Adds the same listener to multiple events.
Usage:
- const events = ['foo', 'bar'];
- const handler = () => {};
- emitter.addListeners(events, handler);
- Source:
getRegisteredEvents
Gets array of names of all registered event types.
- Source:
ons
Alias for addListeners
- Source:
pauseEvents
Pauses all events.
Chainable.
Any events emitted while paused will be added to a queue.
- Source:
registerEvent
Registers a single event type to be used by this Class.
Events must be registered before they can be emitted.
- Source:
registerEvents
Registers multiple event types to be used by this Class.
Events must be registered before they can be emitted.
- Source:
relayEventsFrom
Relays events from one object to another. A relayed event will appear to be emitted
from the relaying object (this), not from the origin object.
- Source:
resumeEvents
Resumes all events.
Chainable.
- Source:
unregisterEvent
Unregisters a single event type from use in this Class.
- Source:
unregisterEvents
Unregisters multiple event types from use in this Class.
Events must be registered before they can be emitted.
- Source:


| DOSE: |
13.5 mg |
oral |
2C-E |
(powder / crystals) |
I ingested 12-15mg of 2ce orally.
I dumped the fluffy, flaky white powder onto some jackasses business card, folded it in half and held it in the air, above my face, angling the card so that it dropped down onto my tongue. Not much of a noticeable taste, washed it down with some water. Then I chilled for awhile. I don't remember exactly what I did, I probably used my computer.
After awhile I began to feel the 2ce come on. The come up was a little rough, but nothing out of hand (no vomiting). At first I amused myself with my computer, but then, once I could really feel it -this became pointless. I went and laid down to think, as I usually do for long periods of time when tripping by myself. I thought alot about my life, and about the people, and situations in my present life. At it's strongest, I noticed that surfaces were breathing with my eyes open.
This dose seemed to be just about right for me at this moment, becuase I was testing the substance on myself for the first time. I didn't want it to be too strong, but I didn't want it to be boringly weak either, go figure. Luckily, I hit the nail on the head with the dosing. After laying down for probably a few hours thinking (in a bed and a big foam bag), I ventured out into the living room.
I had fleeting thoughts of smoking herb here and there (I had smoked on the come up), but each time I realized there was no point as the 2ce was so strong. I also had part of a pack of cigarettes (I used to smoke), because every once in awhile I like one during or after a long night's trip, but not this time. When in the living room, I closed my eyes and just felt and thought, standing there in the brightly lit, large living room. I felt like I could see with my eyes closed. I walked around a little bit with my eyes closed, but then I started to feel like I was messing with things I didn't want to mess with (like seeing through walls and wierd cult stuff, or potentially frightening spirit-world stuff), at least while completely alone and tripping. So I opened my eyes and went and did something else, probably writhed on the floor alone, thinking.
I did get alternately hot and cold during the experience. I could tell I was very cold and I thought to myself, 'it must be in the low 60's in here'. I was surprised when I went to the thermostat and found it was like 76. I alternated between wearing my jacket (I was inside the whole time) for small periods because I was cold, and taking it off because I was too warm from wearing it (it would warm me up pretty quickly). I also got some jaw clenching, I'm pretty experienced with fighting off jaw clenching, and when I noticed it I forced my jaw muscles to unclench and go slack, and I focused on keeping them that way.
After a long time (t+6-7 hours), I finally came down enough to feel like maybe I could smoke out. I went to my smoke area and got my smoke on, smoking a bowl or two. Once I came inside and laid down, I realized what I had to do.  I put on Rabbit in the Moon - OBE, and dove into the visions. I remember thinking 'damn this is some old school' --whatever that really means. I saw many visions and patterns, not too intense, but very visible and powerful. All of a sudden, at a point in the song where it makes a noise kind of like 'whoowabeep', a young girl appeared in front of me, in vivid 3 dimensional detail. She waved and gave me a smile. When she disappeared my visions evaporated into large, sun-spotty type residual images of her head shape.
Usually when I'm tripping and I see something in such vivid 3 dimensional detail, I'm tripping really hard on a substance. Like one time when I took DPT and was punched into other places that were as real as the room I'm in now. I had snorted a large rail and I could tell I was going to trip really hard, and then I did. This was surprising in that, out of a sea of clear, strong, but not extremely intense visions while I listened to music on the tail end of my 2ce trip, a 3 dimensional being burst forth as if peeking out at me (if someones entire body can 'peek' at once), and waved cutely. Her whole presence was very cute, and left me with a good feeling inside as well as a sense of something, maybe it was wonder...
I went to sleep at t+7-8 hours. When laying in bed getting to sleep, the dark had the potential to be frightening, as it was kind of swirling and just seemed spiritually spooky, like entities coming at me. While I recognized this aversive or fearful thought or feeling's existence within myself, I chose not to give it any play and cut it off. I've been in extremely paranoid mental spaces when tripping before and I am fairly good at not giving in to The Fear. Maybe someday I'll be able to embrace paranoia and fear in some way, maybe that's what The Fear is all about. At any rate, during this trip it was relatively easy to stave off the Paranoia / Fear and keep it on a relatively positive vibe. I got to sleep ok, and I think I slept pretty well. I slept most of the day, and when I woke up I felt a little different but not much. The whole experience had a kind of clarity to it, even the after effects and day after effects.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


Struct defining the characteristics of a displayed field on the HMI.
@since SDL 1.0
The enumeration identifying the field.
See
SDLTextFieldNameRequired
@property (nonatomic, strong) SDLTextFieldName _Nonnull name;
var name: SDLTextFieldName { get set }
The set of characters that are supported by this text field. All text is sent in UTF-8 format, but not all systems may support all of the characters expressed by UTF-8. All systems will support at least ASCII, but they may support more, either the LATIN-1 character set, or the full UTF-8 character set.
@property (nonatomic, strong) SDLCharacterSet _Nonnull characterSet;
var characterSet: SDLCharacterSet { get set }
The number of characters in one row of this field.
Required, Integer 1 - 500
@property (nonatomic, strong) NSNumber<SDLInt> *_Nonnull width;
var width: NSNumber & SDLInt { get set }
The number of rows for this text field.
Required, Integer 1 - 8
@property (nonatomic, strong) NSNumber<SDLInt> *_Nonnull rows;
var rows: NSNumber & SDLInt { get set }
Convenience initializer for the TextField RPC struct
- (nonnull instancetype)initWithName:(nonnull SDLTextFieldName)name
characterSet:(nonnull SDLCharacterSet)characterSet
width:(NSUInteger)width
rows:(NSUInteger)rows;
init(name: SDLTextFieldName, characterSet: SDLCharacterSet, width: UInt, rows: UInt)
The name identifying this text field
The character set of this text field
The number of characters per row allowed in this text field
The number of rows allowed in this text field


Version 2.2.3
This app is built with CampusKit. CampusKit is an open source project created by the UCSF Library & Center for Knowledge Management.


Apple marlet where you can buy apple products with the best price and quality
Apple marlet where you can buy apple products with the best price and quality
Apple marlet where you can buy apple products with the best price and quality
Apple marlet where you can buy apple products with the best price and quality
Steve Jobs
founder at apple
Apple marlet where you can buy apple products with the best price and quality
Steve Jobs
founder at apple
FIND US ON SOCIAL MEDIA


Create a record containing several vectors and matrices. It is your choice what types and values the variables should have.
a vector with seven values,
a matrix of four rows and two columns,
a matrix of one row and five columns,
two unspecified matrices
and an empty matrix.


class: center, middle, inverse, title-slide # Data I/O and Wrangling ### The R Bootcamp @ Erfurt
www.therbootcamp.com
@therbootcamp
### June 2018 --- layout: true
 Erfurt, June 2018                                           www.therbootcamp.com
 --- .pull-left45[ ## Data input - Paths When using R projects, paths are always relative to the location of your project folder
 If all of your data files are in your project folder (or a subfolder), the path will be easy to find
  Note: You can load files from other locations on your computer, but you shouldn't (for reproducibility reasons)
 ] .pull-right5[ ### Example) ```r # Create survey dataframe from # survey.csv (Comma-separated csv) survey <- read_csv(file = "data/survey.csv") # Create study1 dataframe from # study1.sav (SPSS file) survey <- read_spss(file = "data/study1.sav") ``` Tip! Press the tab key to view a list of all files in the directory!  Look at help menus for additional arguments ```r # Look at help menu for read_csv function ?read_csv ``` ] --- ## Data input - Web You can easily load files directly from the web by specifying the URL as the path
 ```r # Save file URL as fires_url (it's pretty long) fires_url <- "https://archive.ics.uci.edu/ml/machine-learning-databases/forest-fires/forestfires.csv" # Load as new dataframe called fires fires <- read_csv(file = fires_url) # Look at result! print(fires) ``` ``` ## # A tibble: 517 x 13 ## X Y month day FFMC DMC DC ISI temp RH wind rain area ## <int> <int> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <dbl> <dbl> <dbl> ## 1 7 5 mar fri 86.2 26.2 94.3 5.1 8.2 51 6.7 0 0 ## 2 7 4 oct tue 90.6 35.4 669. 6.7 18 33 0.9 0 0 ## 3 7 4 oct sat 90.6 43.7 687. 6.7 14.6 33 1.3 0 0 ## 4 8 6 mar fri 91.7 33.3 77.5 9 8.3 97 4 0.2 0 ## 5 8 6 mar sun 89.3 51.3 102. 9.6 11.4 99 1.8 0 0 ## 6 8 6 aug sun 92.3 85.3 488 14.7 22.2 29 5.4 0 0 ## 7 8 6 aug mon 92.3 88.9 496. 8.5 24.1 27 3.1 0 0 ## 8 8 6 aug mon 91.5 145. 608. 10.7 8 86 2.2 0 0 ## 9 8 6 sep tue 91 130. 693. 7 13.1 63 5.4 0 0 ## 10 7 5 sep sat 92.5 88 699. 7.1 22.8 40 4 0 0 ## # ... with 507 more rows ``` --- # Where you're at... .pull-left4[ 0) Loaded packages (like tidyverse!) with `library()`
 1) Created a new dataframe (df) from external files using a data input function such as `df <- read_csv()`
 2) You can explore the dataframe with functions like `View()`, `dim()` and `names()` 3) You can explore the dataframe and calculate descriptive statistics on specific columns using `FUN(df$NAME)`

 What's next?... **Wrangling!** ] .pull-right55[ ```r # Step 0) Load libraries library(tidyverse) # Step 1) Read file called baslers.txt # in a data folder with read_csv() # and save as new object baslers baslers <- read_csv(file = "data/baslers.txt") # Step 2) Explore data View(baslers) # Open in new window dim(baslers) # Show number of rows and columns names(baslers) # Show names # Step 3) Calculate descriptives on named colums mean(baslers$age) # What is the mean age? table(baslers$sex) # How many of each sex? # Step 4) ... ``` ] --- .pull-left5[ # What is Wrangling? Transform - Adding new columns - Combining columns - Splitting columns Organise - Moving data between columns and rows - Merging several dataframes - Sorting data by columns Aggregation - Aggregate data according to variables - Summarizing data across groups ] .pull-right5[  ] --- .pull-left45[

 To wrangle data in R, we will use the dplyr and tidyr packages ```r # Load packages individually # install.packages('dplyr') # install.packages('tidyr') library(dplyr) library(tidyr) # Or just use the tidyverse! # install.packages('tidyverse') library(tidyverse) ``` ] .pull-right5[

  ] --- # %>% aka "The Pipe!" .pull-left35[ dplyr makes extensive use of a new operator called the "Pipe" %>%

 The "Pipe" %>% is used to pass objects from one function to another

 You can read the "Pipe" %>% as "And Then..."

 ] .pull-right65[
 object %>% "And then..."
 FUN1() %>% "And then..."
 FUN2() %>% "And then..."

 ] --- .pull-left45[  ] .pull-right5[

 ### Example ```r # Create a vector score score <- c(8, 4, 6, 3, 7, 3) ``` ```r # Base-R method mean(score) ``` ``` ## [1] 5.167 ``` ```r # Pipe %>% method score %>% # Take the vector score AND THEN mean() # calculate the mean ``` ``` ## [1] 5.167 ``` ] --- .pull-left45[  ] .pull-right5[

 ### Example ```r # Create a vector score score <- c(8, 4, 6, 3, 7, 3) ``` ```r # Base-R method round(sd(score), digits = 1) ``` ``` ## [1] 2.1 ``` ```r # Pipe %>% method score %>% # Take vector score AND THEN sd() %>% # Calculate the sd AND THEN round(digits = 1) # Round to 1 digit ``` ``` ## [1] 2.1 ``` ] --- .pull-left4[

 ## Functions in dplyr There are dozens (hundreds?) functions in dplyr that allow you to wrangle data.
 For an overview, look at the cheatsheet!
 We will now show you how to use ~10 of the most common functions
 ] .pull-right55[

  ] --- .pull-left45[
 ## How dplyr looks in action
 > From the baselers data...

1) Change the name of the column 'age' to 'age_years' and 'weight' to 'weight_kg'.

2), only include people younger than 40.

3) Add a new column called that shows people's debt divided by their income.

4) Create groups based on sex.

5) Calculate summary statistics: the mean income, debt, and debt ratio for each group. ] .pull-right55[
 ```r # Assign result to baslers_agg baslers_agg <- baselers %>% # Change column names with rename() rename(age_years = age, weight_kg = weight) %>% # PIPE! # Select specific rows with filter() filter(age_years < 40) %>% # PIPE! # Create new columns witb mutate() mutate(debt_ratio = debt / income) %>% # PIPE! # Group data with group_by() group_by(sex) %>% # PIPE! # Calculate summary statistics with summarise() summarise(income_mean = mean(income), debt_mean = mean(debt), dr_mean = mean(dr)) ``` ] --- .pull-left4[
 ## How dplyr looks in action
 Start by assigning your result to a new object to save it!

 "Keep the pipe %>% going" to continue working with your dataframe

 The output of dplyr functions will (almost) always be a tibble

 You can almost always include multiple operations within each function

 ] .pull-right55[
 ```r # Assign result to baslers_agg baslers_agg <- baselers %>% # Change column names with rename() rename(age_years = age, weight_kg = weight) %>% # PIPE! # Select specific rows with filter() filter(age_years < 40) %>% # PIPE! # Create new columns witb mutate() mutate(debt_ratio = debt / income) %>% # PIPE! # Group data with group_by() group_by(sex) %>% # PIPE! # Calculate summary statistics with summarise() summarise(income_mean = mean(income), debt_mean = mean(debt), dr_mean = mean(dr)) ``` ] --- .pull-left4[ # Transformation Functions | Function| Description| |:-------------|:----| | `rename()` | Change column names | | `mutate()`| Create a new column from existing columns| | `case_when()`| Recode values from a vector to another| | `left_join()` | Combine multiple dataframes| ] .pull-right55[

 ### patients_df ```r patients_df # Demographic data ``` ``` ## # A tibble: 5 x 3 ## id b c ## <dbl> <dbl> <dbl> ## 1 1 37 1 ## 2 2 65 2 ## 3 3 57 2 ## 4 4 34 1 ## 5 5 45 2 ``` ] --- # `rename()` .pull-left3[ Change column names with `rename()` New = Old, New = Old, ... ```r patients_df # Original ``` ``` ## # A tibble: 5 x 3 ## id b c ## <dbl> <dbl> <dbl> ## 1 1 37 1 ## 2 2 65 2 ## 3 3 57 2 ## 4 4 34 1 ## 5 5 45 2 ``` ] .pull-right65[ Create better column names with `rename()` ```r # 0) Start with patients_df data patients_df <- patients_df %>% # 1) Change column names with rename() rename(age = b, # New = Old arm = c) # New = Old ``` ] --- # `mutate()` .pull-left3[ Add new columns (or change existing ones) with `mutate()`

 Define new columns in terms of existing columns in the dataframe

 Can add multiple new columns within one `mutate()`

 Change an existing column by assigning it to itself ```r df %>% mutate( NEW1 = DEFINITION1, NEW2 = DEFINITION2, NEW3 = DEFINITION3, ... ) ``` ] .pull-right65[ Add new columns with `mutate()` ```r patients_df <- patients_df %>% # Create new columns with mutate() mutate(age_months = age * 12, age_decades = age / 10) ``` ``` ## Warning: package 'bindrcpp' was built under R version 3.4.4 ``` ] --- .pull-left4[ # `case_when()` Use `case_when()` in combination with `mutate()` to define new columns based on logical conditions ```r # Using mutate(case_when()) df %>% mutate( NEW = case_when( COND1 ~ VAL1, COND2 ~ VAL2 )) ``` Useful for recoding values. Example: |arm|arm_char| |:--|:--| |0|"placebo"| |1|"drug"| |0|"placebo"| ] .pull-right55[

 Recode values with `mutate(case_when())` ```r patients_df <- patients_df %>% # Create column arm_char based on values of arm mutate( arm_char = case_when(arm == 0 ~ "placebo", arm == 1 ~ "drug") ) ``` Note: By default, all 'other' values are set to NA. To set 'other' values to something else, use the condition `TRUE` as a catch-all for all 'other' values. ```r patients_df <- patients_df %>% mutate( arm_char = case_when(arm == 0 ~ "placebo", arm == 1 ~ "drug", TRUE ~ "other") # Catch-all ) ``` ] --- # Joining data  --- .pull-left35[ ## left_join()
 Use left_join() to combine data from 2 dataframes based on one or more keuy columns

 Each dataset must contain the 'key' column(s)
 ```r # Join df2 to df1 # using KEY as the key column df1 %>% left_join(df2, by = c("KEY")) ```  ] .pull-right6[
 Join patients_df with results_df to create combined_df ```r combined_df <- patients_df %>% # Join with results_df with left_join() left_join(results_df, by = "id") # Look at all column names names(combined_df) ``` ``` ## [1] "id" "age" "arm" "age_months" "age_decades" "arm_char" "t1" ## [8] "t2" ``` ```r # Show a few columns combined_df %>% select(id, arm, age, t1, t2) ``` ``` ## # A tibble: 5 x 5 ## id arm age t1 t2 ## <dbl> <dbl> <dbl> <dbl> <dbl> ## 1 1 1 37 123 135 ## 2 2 2 65 143 140 ## 3 3 2 57 NA NA ## 4 4 1 34 100 105 ## 5 5 2 45 NA NA ``` ] --- .pull-left35[

 # Notes Don't forget to start by assigning to a new (or existing) object with <-
 Keep adding new functions connected by the pipe %>%
 Order matters! You can refer to new columns in later code

 ] .pull-right6[

 Create combined_df using multiple functions ```r # 0) Start with patients_df data combined_df <- patients_df %>% # 1) Change column names with rename() rename(age = b, arm = c) %>% # 2) Create new columns with mutate() mutate(age_months = age * 12, age_decades = age / 10, arm_char = case_when(arm == 0 ~ "placebo", arm == 1 ~ "drug") ) %>% # 3) Add data from results_df with left_join() left_join(results_df, by = "id") ``` ] --- .pull-left55[ # Organisation Functions Organisation functions help you shuffle your data by sorting rows by columns, filter rows based on criteria, select columns (etc.) | Function| Purpose|Example| |:--------|:----|:------------| | `arrange()` |Sort rows by columns|`df %>%`
`arrange(arm, age)`| | `slice()`| Select rows by location|`df %>%`
`slice(1:10)`| | `filter()` | Select specific rows by criteria|`df %>%`
`filter(age > 50)`| | `select()`| Select specific columns|`df %>%`
`select(arm, t1)`| ] .pull-right4[

 Organise the `combined_df` dataframe ```r combined_df %>% # Sort rows by arm then in # descending order of age arrange(arm, desc(age)) %>% # Only include age > 50 filter(age > 50) %>% # Select these columns select(arm, age, t1, t2) ``` ``` ## # A tibble: 2 x 4 ## arm age t1 t2 ## <dbl> <dbl> <dbl> <dbl> ## 1 2 65 143 140 ## 2 2 57 NA NA ``` ] --- .pull-left3[ # arrange() The arrange() function is used to sort (aka, arrange) rows of a dataframe

 You can sort by as many conditions as you want

 To sort in descending order, use desc() ] .pull-right65[

 Sort rows by id then in descending order of age ```r # 0) Start with combined_df data combined_df %>% # 1) Sort by id then age (descending) arrange(id, desc(age)) ``` ``` ## # A tibble: 5 x 8 ## id age arm age_months age_decades arm_char t1 t2 ## <dbl> <dbl> <dbl> <dbl> <dbl> <chr> <dbl> <dbl> ## 1 1 37 1 444 3.7 drug 123 135 ## 2 2 65 2 780 6.5 other 143 140 ## 3 3 57 2 684 5.7 other NA NA ## 4 4 34 1 408 3.4 drug 100 105 ## 5 5 45 2 540 4.5 other NA NA ``` ] --- .pull-left3[ # filter() The filter() function is used to select rows based on certain criteria using logical comparisons
 |Operator| Effect| |---|---| |==| equal to| |!=| Not equal to| |<, >| Less than, greater than| |<=, >=|Less or =, greater or =| For complex conditions, chain multiple logical comparison operators with & (and), | (or) ] .pull-right65[

 Select patients over 30 given drug ```r combined_df %>% # Sort by id then age (descending) arrange(id, desc(age)) %>% # NEW - Only over 30 given drug filter(age > 30 & arm_char == "drug") ``` ``` ## # A tibble: 2 x 8 ## id age arm age_months age_decades arm_char t1 t2 ## <dbl> <dbl> <dbl> <dbl> <dbl> <chr> <dbl> <dbl> ## 1 1 37 1 444 3.7 drug 123 135 ## 2 4 34 1 408 3.4 drug 100 105 ``` ] --- .pull-left4[ # select() Keep columns with select() ```r # Select columns id, age df %>% select(id, age) ``` Drop columns (and keep others) with - ```r # Select everything BUT sex and id df %>% select(-sex, -id) ``` Use functions like contains(), starts_with(), (...) for advanced selection (look at help menu ?select() to see them all) ```r # Advanced selection df %>% select(contains("response")) df %>% select(id, # Start with id starts_with("demo"), contains("response")) ``` ] .pull-right55[

 Drop age_months and age_decades colummns ```r # 0) Start with combined_df data combined_df %>% # Sort by id then age (descending) arrange(id, desc(age)) %>% # Only drugtrial over 30 filter(arm_char == "drug" & age > 30) %>% # NEW - Remove age_months and age_decades select(-age_months, -age_decades) ``` ``` ## # A tibble: 2 x 6 ## id age arm arm_char t1 t2 ## <dbl> <dbl> <dbl> <chr> <dbl> <dbl> ## 1 1 37 1 drug 123 135 ## 2 4 34 1 drug 100 105 ``` ] --- ## Grouped Aggregation  --- .pull-left4[ # Aggregation functions | Function| action| |:-------------|:----| | `group_by()` |Group data by levels of one or more variables | | `summarise()` | Calculate summary statistics | ### Statistical functions | Function| action| |:-------------|:----| | `min(), max()`| Minimum, maximum | | `mean(), median()` |Mean, Median | | `sd()` |Standard deviation| | `sum()` | Sum| | `n()`| Number of cases| ] .pull-right55[
 ```r # First 2 rows of raw data combined_df %>% slice(1:2) ``` ``` ## # A tibble: 2 x 5 ## id age arm t1 t2 ## <dbl> <dbl> <chr> <dbl> <dbl> ## 1 1 37 drug 123 135 ## 2 2 65 other 143 140 ``` ```r # Group and summarise! combined_df %>% group_by(arm) %>% summarise( N = n(), age_mean = mean(age), t1_mean = mean(t1, na.rm = TRUE), t2_mean = mean(t2, na.rm = TRUE) ) ``` ``` ## # A tibble: 2 x 5 ## arm N age_mean t1_mean t2_mean ## <chr> <int> <dbl> <dbl> <dbl> ## 1 drug 2 35.5 112. 120 ## 2 other 3 55.7 143 140 ``` ] --- .pull-left3[ # group_by() Used to combine data into separate groups based on 'grouping' columns

 You can group by as many variables as you wish

 You won't see any changes to the data until you use summarise()
 ] .pull-right65[

 Group data by arm ```r # 0) Start with combined_df data combined_df %>% # 1) Group data by arm with group_by group_by(arm) ``` ``` ## # A tibble: 5 x 5 ## # Groups: arm [2] ## id age arm t1 t2 ## <dbl> <dbl> <chr> <dbl> <dbl> ## 1 1 37 drug 123 135 ## 2 2 65 other 143 140 ## 3 3 57 other NA NA ## 4 4 34 drug 100 105 ## 5 5 45 other NA NA ``` ] --- .pull-left4[ # summarise() Used to summarise data from groups

 Works like mutate() to create new variables, but with summary functions
 ```r df %>% group_by(VAR1) %>% summarise( SUMMARY = FUN(x), # age_mean = mean(age), # Ex 1 height_min = min(height) # Ex 2 total = n() ) ``` ] .pull-right55[

 Calculate summary statistics ```r # 0) Start with combined_df data combined_df %>% # 1) Group data by arm with group_by group_by(arm) %>% # 2) Calculate summary columns summarise( t1_mean = mean(t1, na.rm = TRUE), t2_mean = mean(t2, na.rm = TRUE), diff = t2_mean - t1_mean, N = n() # Number of rows in group ) ``` ``` ## # A tibble: 2 x 5 ## arm t1_mean t2_mean diff N ## <chr> <dbl> <dbl> <dbl> <int> ## 1 drug 112. 120 8.5 2 ## 2 other 143 140 -3 3 ``` ] --- .pull-left45[ ## Reshaping data There are two key functions in the tidyr package (part of the tidyverse) that allow you to 'reshape' a dataframe between 'wide'and 'long' formats.
 'Wide' dataframes have key data in separate columns,

'Long' dataframes have key data in separate rows.
 Why reshape data between wide and long? Some functions require data to be in a certain shape
 #### Two key tidyr functions | Function | Result | |:----------|:-------| |`gather()`|Move data from 'wide' to 'long' format| |`spread()`|Move data from 'long' to 'wide' format| ] .pull-right5[

 ### 'Wide' vs. 'Long' data ```r # Wide format stock_w ``` ``` ## id t1 t2 ## 1 a 10 20 ## 2 b 20 26 ## 3 c 15 30 ``` ```r # Long format stock_l ``` ``` ## id time measure ## 1 a t1 10 ## 2 b t1 20 ## 3 c t1 15 ## 4 a t2 20 ## 5 b t2 26 ## 6 c t2 30 ``` ] --- .pull-left45[ ## gather() Use gather() to convert wide to long ```r # Show wide data stock_w ``` ``` ## id t1 t2 ## 1 a 10 20 ## 2 b 20 26 ## 3 c 15 30 ``` ```r # "Gather" wide data to long stock_w %>% gather(time, # New group column measure, # New target column -id) # ID column ``` ``` ## id time measure ## 1 a t1 10 ## 2 b t1 20 ## 3 c t1 15 ## 4 a t2 20 ## 5 b t2 26 ## 6 c t2 30 ``` ] .pull-right5[ ## spread() Use spread() to convert long to wide ```r # Show long data stock_l ``` ``` ## id time measure ## 1 a t1 10 ## 2 b t1 20 ## 3 c t1 15 ## 4 a t2 20 ## 5 b t2 26 ## 6 c t2 30 ``` ```r # "Spread" long data to wide stock_l %>% spread(time, # Old group column measure) # Old target column ``` ``` ## id t1 t2 ## 1 a 10 20 ## 2 b 20 26 ## 3 c 15 30 ``` ] --- .pull-left3[ ## Important!
 You can call many dplyr functions directly without the pipe %>%

 However, we recommend always using the pipe %>% so you can string many operations together ] .pull-right65[

  Use the pipes %>%! ```r ## Using dplyr functions without pipes %>% ## Avoid this if you can data <- mutate(data, age_years = age_months * 12) data <- filter(data, sex == "m") ## Using dplyr functions with pipes %>% ## Much better!!! data <- data %>% mutate(age_years = age_months * 12) data <- data %>% filter(sex == "m") # Why? Because with pipes you can easily put multiple # functions together if you choose. data <- data %>% mutate(age_years = age_months * 12) %>% filter(sex == "m") %>% # .... ``` ] --- .pull-left45[ # Questions?  ] .pull-right45[

  ] ---

 # [Wrangling Practical](https://therbootcamp.github.io/Erfurt_2018June/_sessions/D1S2_Wrangling/Wrangling_practical.html)


Here is some content that has been columnised and translated 600px (or two "pages"). Via various methods, on what pages are the three "beacon" elements?
The expected results are 1, 2 and 5.
GBCR: GetBoundingClientRect — A pretty efficient calculation based on block dimensions and offsets. Not supported in older browsers.
SIV: ScrollIntoView — A slower and less accurate calculation that works by natively "scrolling the element into view", checking the scroll offset, then scrolling back to the previous offset. Browsers sometimes calculate "in view" differently, leading to infrequent off-by-one errors. Also, it has to remove transforms before calculating scroll offset, and replace them afterward.


--- layout: post authors: ["Thomas Guignard", "Jeramia Ory"] title: "Workshop at the University at Albany, SUNY" date: 2015-02-16 time: "20:26:00" tags: ["Workshops", "SUNY Albany"] ---
We recently ran a workshop hosted by the University at Albany, SUNY's Department of Informatics. The workshop ran on the weekend of January 31 and February 1, 2015 with the following schedule:
| Day 1 AM: | Automating tasks with the Unix shell (instructor: Thomas Guignard) |
| Day 1 PM: | Building programs with Python (instructor: Jeramia Ory) |
| Day 2 AM: | Version Control with Git (Jeramia) |
| Day 2 PM: | Managing data with SQL (Thomas) |
Thomas:The welcome we received from the University at Albany Department of Informatics staff was fantastic. They looked into every single detail and did a great job taking care of the instructors during the entire weekend. As a new instructor (it was my third time teaching and first time teaching bash) with very little teaching experience outside of Software Carpentry, this created the perfect atmosphere for me to relax a little and focus on delivering the lesson. Being paired with a more seasoned instructor (Jeramia) was also very useful, and we used the breaks to give each other feedback and report on how the class was following and which were the topics with with some attendees seemed to have issues and warranted being mentioned again.
Another thing that I learned the hard way was that if I don't know the answer to a question straight away, I'm better off admitting that I would need some time researching it, doing so during the next break, and then coming up with an answer, rather than try to look up the information online live and trying multiple options until I found a solution. While it does demystifies the process and highlights the approach of looking up answers to specific questions on the Web (which I believe is an important part of learning to code), it makes me too nervous and ends up being unproductive. Maybe with more experience I'll get better at adlibbing.
On Saturday, the organisers had invited Michael Corey, a social science researcher currently working for Facebook, to give a prep talk to attendees (some of which were recent Social Sciences graduates) about the importance of basic programming skills and knowledge of tools like R in their profession. I found it to be an interesting addition to the workshop, clearly a good way to link the syllabus with real-life examples. On the flip side, it also meant that most attendees didn't take a proper break over lunch, which had effects on their attention in the afternoon. Maybe something to keep in mind when discussing future workshops with organisers.
Jeramia: The planning of the workshop cannot be praised enough. It was easily the most trouble-free experience I have had to date. The WiFi worked, almost everyone had the software installed ahead of time, and attendees provided good feedback. Chris Kotfila, a graduate student in the Informatics program, provided local office hours on the two Fridays preceeding the workshop and was a helper along with Alex Jurkat. Having friendly, enthusiastic helpers meant that Thomas and I could check in about "higher level" issues at the breaks, and was just fantastic.
At the end of the workshop I gave a short demonstration of how I use Python and R in my workflow. I hoped to address the question that we frequently get during and after a workshop: why should I use Python? Should I be using R? Short answer: it depends. I personally think Python, as a general purpose language, is a bit closer to the philosophy under which Software Carpentry was created. That said, one can't deny the power of R's libraries. Interestingly, a number of students were already quite familiar with R with their work in the Informatics program, and wanted to learn python and automation. I also fell victim to trying to answer questions in real time in a similar way as Thomas. Ultimately I think these experiences can be useful for students to see, but it can lead to the question "Why did we ask you here to Google something?" My only answer to that, as with my undergraduates, is that we hope to teach you the vocabulary you need to succesfully search for things on your own after we leave.
Thanks to all attendees, helpers and organisers at the Software Carpentry workshop, University at Albany, Jan 31-Feb 1, 2015. (Photo: George Berg)


{% extends 'layout.server.view.html' %} {% block content %}
Thankyou for using our application. Your account has been created. You may now check your email to verify your account. :)


# A Brief Introduction
to Functions #### by ### Sean Healy --- # What is a Function? > Lots of technical definitions but I want to focus on a couple practical cases that will often come up for new developers. --- # A Function - Allows you to provide a name for a piece of behaviour. - Allows you to break a problem into smaller steps. - Allows you to reuse blocks of code. --- # A Few Things to Know - In JavaScript a function is a variable like any other. ```javascript var name = "Clarus the Dogcow"; var speak = function() { alert("Moof!"); }; console.log(typeof name); // => "string" console.log(typeof speak); // => "function" ``` --- # A Simple Example ```javascript var sayHi = function() { console.log("Hi!"); } sayHi(); // => "Hi!" ``` --- # Using Parameters ```javascript var announce = function(message) { console.log("Important announcement: " + message); } announce("Isn't this amazing?"); // => "Important announcement: Isn't this amazing?" ``` --- # Returning Values ```javascript var add = function(a, b) { return a + b; } console.log(add(2, 3)); // => 5 ``` --- # Lets Build a Site Time to build a little page with some simple functionality. ```html
Hello World!
``` > index.html ```javascript // Javascript code will go here. ``` > main.js
*Run It*
--- # Add A Simple Function ```javascript // Code will go here. // Create our hello function. var hello = function() { console.log("Our site says: Hello"); }; // Call our hello function. hello(); ``` > main.js
*Run It*
--- # Add A Button ```html
Hello World!
My Button
``` > index.html
*Run It*
--- # Add A Button ```javascript var hello = function() { console.log("Our site says: Hello"); }; hello(); // Get a reference to our button. var myButton = document.getElementById("my-button"); // Create a function for our button's action. var buttonClick = function() { console.log("Our site says: You clicked the Button."); }; // Call our button function on click. myButton.addEventListener("click", buttonClick); ``` > main.js
*Run It*
--- # Simplify Some Repetition ```javascript // Create a function for announcements. var announce = function(message) { console.log("Our site says: " + message); }; var hello = function() { announce("Hello"); }; hello(); var myButton = document.getElementById("my-button"); var buttonClick = function() { announce("You clicked the Button."); }; myButton.addEventListener("click", buttonClick); ``` > main.js
*Run It*
--- # Simplify Some Repetition ```javascript // Create a function for formatting announcements. var buildAnnouncement = function(message) { return "Our site says: " + message; }; var hello = function() { var announcement = buildAnnouncement("Hello"); console.log(announcement); }; hello(); var myButton = document.getElementById("my-button"); var buttonClick = function() { var announcement = buildAnnouncement("You clicked the Button."); console.log(announcement); }; myButton.addEventListener("click", buttonClick); ``` > main.js
*Run It*
--- # Diving Deeper A few things to look into once you're comfortable with function basics. - [Namespaces](https://javascriptweblog.wordpress.com/2010/12/07/namespacing-in-javascript/) - [Arrow Functions](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions) - Modules - [Import](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Statements/import) - [Export](https://developer.mozilla.org/en/docs/web/javascript/reference/statements/export) ---
# *Fin!* ## Any questions? ### [@seanhealy](https://twitter.com/seanhealy) on Twitter.


| About the ADL SCORM® 2004 4th Edition Test Suite Version 1.1.1 |
The ADL SCORM 2004 4th Edition Test Suite
Version 1.1.1 provides the capability to assess
conformance of learning management systems (LMS),
Sharable Content Objects (SCOs) and
content packages with the SCORM
.
More information on the specific details of each individual test module
is available by selecting any of the following links:
For information regarding SCORM®
,
please visit
ADLNet.gov.
For a summary of the SCORM®
Testing Requirements,
please view the
ADL SCORM® 2004 4th Edition Conformance Matrix.
Designed with a common look and feel, each test module includes
step-by-step instructions, a test log, and a link to its About page.
Testing activity can be monitored real-time while the test log is
updated. The test tool provides the ability to print the log, save the
log, or add textual comments to the log.


More InfoLess Info


Cards
.card
.card-header Basic Card Example
.card-body This is an example of a basic card.
Note: The card styling in SB Admin Pro looks best with a light background color due to the background color of the card header, card body, and box shadow.
Card with Dropdown in Header:
This is an example of a custom card with a dropdown action inside of the card header. The card's overflow is set to hidden, so your card body height should exceed the height of your dropdown menu.
.card.card-header-actions
.card-header
| Header Dropdown
.dropdown.no-caret
button#dropdownMenuButton.btn.btn-transparent-dark.btn-icon.dropdown-toggle(type='button', data-toggle='dropdown', aria-haspopup='true', aria-expanded='false')
i.text-primary(data-feather='more-vertical')
.dropdown-menu.dropdown-menu-right.animated--fade-in-up(aria-labelledby='dropdownMenuButton')
a.dropdown-item(href='javascript:void(0);') Action
a.dropdown-item(href='javascript:void(0);') Another action
a.dropdown-item(href='javascript:void(0);') Something else here
.card-body
| ...
.card-header-actions
class to your .card
when using two elements within the card header. This class will apply flex styling to the card header, allowing for even spacing between the text and another element.Card with Icons in Header:
This is an example of a custom card with a group of icons inside of the card header.
.card.card-header-actions
.card-header
| Header Icons
div
button.btn.btn-pink.btn-icon.mr-2
i(data-feather='heart')
button.btn.btn-teal.btn-icon.mr-2
i(data-feather='bookmark')
button.btn.btn-blue.btn-icon
i(data-feather='share')
.card-body
...
.card-header-actions
class.Card with a Button in Header:
This is an example of a custom card with a button inside of the card header.
.card.card-header-actions
.card-header
| Header Button
button.btn.btn-primary.btn-sm Action
.card-body
| ...
.btn-sm
styling. The .btn-xs
styling is also supported, but larger buttons may change the internal height of the card header.Card with an Input in Header:
This is an example of a custom card with a form input inside of the card header.
.card.card-header-actions
.card-header
| Header Input
form
input.form-control(placeholder='Search')
.card-body
...
.card-header-actions
class in order to position the card header elements correctly.This is a collapsable card example using Bootstrap's built in collapse functionality with some added custom styling. Click on the card header to see the card body collapse and expand!
.card.card-collapsable
a.card-header(href='#collapseCardExample', data-toggle='collapse', role='button', aria-expanded='true', aria-controls='collapseCardExample')
| Collapsable Card Example
.card-collapsable-arrow
i.fas.fa-chevron-down
#collapseCardExample.collapse.show
.card-body
| ...
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
.card.card-scrollable
.card-header Scrollable Card Example
.card-body
p.card-text
...
.card-footer.small.text-muted Card Footer
.card-body
element, and scroll the contents of the card body when the height is fixed. You can set the max height of the card body by changing the $card-scrollable-max-height
SCSS variable, which is set to 15rem
by default. You can also set the max height of the card body using inline CSS, or CSS overrides for different cards.Card Image Caps:
Card Image Cap (Top)
This is am example of a default Bootstrap image card with an image above the card body content.
Card Image Cap (Bottom)
This is am example of a default Bootstrap image card with an image below the card body content.
//- Card Image Cap (Top) Example
.card
img.card-img-top(src='path/to/image', alt='...')
.card-body
h5.card-title Card Image Cap (Top)
p.card-text
| ...
//- Card Image Cap (Bottom) Example
.card
.card-body
h5.card-title Card Image Cap (Bottom)
p.card-text
| ...
img.card-img-bottom(src='path/to/image', alt='...')
Card Image Overlay:
//- Card Image Overlay Example
.card
img.card-img(src='path/to/image', alt='...')
.card-img-overlay
h5.card-title Card Image (Overlay)
p.card-text
| ...
Card Image Sides:
Card Image (Left)
Use the Bootstrap grid with utility classes to create this card variant.
Card Image (Right)
Use the Bootstrap grid with utility classes to create this card variant.
//- Card Image (Left)
.card
.row.no-gutters
.col-md-4
img.img-fluid(src='path/to/image', alt='...')
.col-md-8
.card-body
h5.card-title Card Image (Left)
p.card-text
| ...
//- Card Image (Right)
.card
.row.no-gutters
.col-md-8
.card-body
h5.card-title Card Image (Right)
p.card-text
| ...
.col-md-4
img.img-fluid(src='path/to/image', alt='...')
//- Icon Card Example
.card.card-icon
.row.no-gutters
.col-auto.card-icon-aside.bg-primary
i.mr-1.text-white-50(data-feather='layers')
.col
.card-body.py-5
h5.card-title Custom Icon Card
p.card-text
| ...
Default Card Colors:
Here is some example text within the card body.
Here is some example text within the card body.
Here is some example text within the card body.
Here is some example text within the card body.
Here is some example text within the card body.
Here is some example text within the card body.
Here is some example text within the card body.
//- Primary Card
.card.bg-primary.text-white
.card-header.text-white Primary Card
.card-body
p.card-text ...
.card-footer Card Footer
//- Secondary Card
.card.bg-secondary.text-white
.card-header.text-white Secondary Card
.card-body
p.card-text ...
.card-footer Card Footer
//- Success Card
.card.bg-success.text-white
.card-header.text-white Success Card
.card-body
p.card-text ...
.card-footer Card Footer
//- Danger Card
.card.bg-danger.text-white
.card-header.text-white Danger Card
.card-body
p.card-text ...
.card-footer Card Footer
//- Warning Card
.card.bg-warning.text-white
.card-header.text-white Warning Card
.card-body
p.card-text ...
.card-footer Card Footer
//- Light Card
.card.bg-light
.card-header.text-dark Light Card
.card-body
p.card-text ...
.card-footer Card Footer
//- Dark Card
.card.bg-dark.text-white
.card-header.text-white Dark Card
.card-body
p.card-text ...
.card-footer Card Footer
.bg-*
background utility class, along with a text color utility class when necessary. All of the above examples, except for the light background colored card, use the .text-white
utility along with a background utility.Extended Card Colors:
Here is some example text within the card body.
Here is some example text within the card body.
Here is some example text within the card body.
Here is some example text within the card body.
Here is some example text within the card body.
Here is some example text within the card body.
Here is some example text within the card body.
Here is some example text within the card body.
Here is some example text within the card body.
Here is some example text within the card body.


{% extends "base.html" %} {% block content %} Are you sure you want to delete product {{ product.name }} from the database? Cancel Delete {% endblock %}


Hexidecimals, Binary, and Other Radices
Would you believe that 0xDF9A2C,<PHONE_NUMBER>01101000101100 and 14653996 are all the same number? Two weeks ago I would have said ‘Sure, but why the heck should I even care?’. While they all do represent the same number, where they differ is their radix. This is more commonly referred to as number’s base. When you see price tags, speed limits, and apartment numbers they are all in base 10. You may be wondering what exactly that implies. Base 10 means that we use ten unique characters to represent a number. Numbers we deal with on a daily basis are only made up of the characters 0 1 2 3 4 5 6 7 8 and 9. Every number that you can count to is representable using this base 10 system. You may be wondering at this point if there are other radices (bases). In fact there are. None of them are as commonplace as base 10 but they each definitely have their place. First lets take a look at binary, which is considered base 2.
Binary
Ever heard the saying ‘There are 10 types of people in the world: Those who understand binary, and those who don’t.’ This funny saying specifically shows how quickly people assume the numbers they see are base 10 and not another base. Had they wrote 102, some people might have caught on earlier that this wasn’t a regular number. Following the previous statement I made about representing a number in base 10, we can do exactly the same with base 2. But this time, we can only use two unique characters. These just so happen to be 0 and 1. It almost seems impossible. How can you possibly represent a number like 1256 with only two characters? With a bit of math, I’ll do my best to explain this herculean task.
Lets start out with some simple math. I hope we can all agree that 21 = 2. And if you’re really mathematically inclined, you’ll already know that 20 = 1. If you didn’t already know that’s ok. If we follow this pattern for a bit, we can actually build up a nice little chart with the following numbers:
| 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
|---|---|---|---|---|---|---|---|
| 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 |


Rapid Prototyping with Rails: Lesson 2, Nested Routes
20 Oct 2014Comments - using Nested Routes
def create
@post = Post.find(params[:post_id])
@comment = Comment.new(params.require(:comment).permit(:body))
@comment.post = @post
end
OR
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.build(params.require(:comment).permit(:body))
end
What we've covered:
Creating a Nested Resource
Creating a model-backed form in a nested resource way... to generate a nested URL
In your controller Create action, you must set up the parent object in the controller action, so that it can be called on in your form_for
Under the error condition, you have to render 'posts/show' rather than 'new'


Exponential growth of cumulative cases (not as illustrative as in the early days of COVID-19).
Data from the COVID Tracking Project. JavaScript: GitHub.


NTILE Window Function
The NTILE window function divides ordered rows in the partition into the specified number of ranked groups of as equal size as possible and returns the group that a given row falls into.
Syntax
NTILE (expr) OVER ( [ PARTITION BY expression_list ] [ ORDER BY order_list ] )
Arguments
- expr
-
The number of ranking groups and must result in a positive integer value (greater than 0) for each partition. The expr argument must not be nullable.
- OVER
-
A clause that specifies the window partitioning and ordering. The OVER clause cannot contain a window frame specification.
- PARTITION BY window_partition
-
Optional. The range of records for each group in the OVER clause.
- ORDER BY window_ordering
-
Optional. An expression that sorts the rows within each partition. If the ORDER BY clause is omitted, the ranking behavior is the same.
If ORDER BY does not produce a unique ordering, the order of the rows is nondeterministic. For more information, see Unique Ordering of Data for Window Functions.
Return Type
BIGINT
Examples
See NTILE Window Function Examples.


Kindly Myers Flaunts Figure In The Skimpiest Daisy Dukes While Posing With A Gun
November 20, 2019
Kindly Myers Flaunts Figure In The Skimpiest Daisy Dukes While Posing With A Gun
Kindly Myers gave her 1.8 million followers something to get excited about with her latest update in which she flaunted her figure posing with a gun.
The photo showed Kindly from behind as she stood outside near a patch of trees holding a gun that looked to be some kind of semi-automatic rifle, although she did not identify the weapon.
While the gun might have attracted a bit of attention, it was Kindly’s incredible figure that stole the show. She wore a beige, knit crop top with spaghetti straps that flashed a bit of side boob while also showing off her flat abs and shapely arms. Her Daisy Dukes were about as small as the could get. The low-rise shorts were extremely high cut in the back, revealing Kindly’s perky derrière and the tops of her toned thighs.
The blond bombshell’s makeup looked flawless and featured sculpted bows, smoky eye shadow and thick lashes. Her cheeks were contoured and she wore a nude gloss on her full lips. Her long hair also looked fabulous as it fell in loose curls down her back. With a sultry pout on her face, she looked down at the gun as she pointed it in the air while running her other hand through her hair.
In the post’s caption, Kindly referenced the gun with a playful comment while also crediting the photographer as well as the hair and makeup artists.
Her followers raved over how hot she looked in the snap.
“Should be against the law to be this sexy!” commented one follower.
Loading...
“You’re by far the hottest woman I’ve ever seen in a pair of daisies and a tank top. Pic, movie, etc. Nothin [sic] comes close to how you rock it girl. Damn,” a second admirer wrote.
“This is heart stopping sexy Kindly. I’ve seen some sexy photos of you but this is without a doubt the sexiest,” wrote a third fan.
“Might be hottest picture ever!” a fourth admirer said.
The Playboy Playmate updates her Instagram on almost a daily basis with titillating photos that show plenty of skin. She likes go topless from time to time while modeling revealing bikini bottoms or skimpy underwear. Going totally nude on the photo-sharing platform is also something Kindly has been known to do from time to time. While her racy shots may not be for everyone, she seems to know what her followers like to see.