Simulates a nice constellation on canvas
A Pen by Acauã Montiel on CodePen.
Simulates a nice constellation on canvas
A Pen by Acauã Montiel on CodePen.
Simulates a nice constellation on canvas
A Pen by Acauã Montiel on CodePen.
<?php | |
/** | |
* Wordpress function to optimize image in accordance with Google Pagespeed recommendations upon | |
* upload. Supports jpeg/jpg image types. | |
* | |
* Authored by: Wes Melton | |
* Source: https://gist.github.com/wmelton/bbf82ce43103fae7efe5946734e4de19 | |
* | |
* This function compresses the image, converts it to a progressive JPEG, and strips ICC information. | |
* It also converts it to sRGB colorspace, compresses to 85% quality and then saves it back. |
https://codepen.io/anon/pen/LejmPB |
SELECT latitude, longitude | |
from mytable | |
where ST_CONTAINS( | |
GeomFromText( 'LINESTRING(50.5606 -1.8131,51.5606 -0.8131)' ), | |
point(longitude, latitude) | |
) |
//Two circles intersect if, and only if, the distance between their centers is between the sum and the difference of their radii. Given two circles (x0,y0,R0) and (x1,y1,R1), the formula is as follows: | |
ABS(R0-R1) <= SQRT((x0-x1)^2+(y0-y1)^2) <= (R0+R1) | |
//Squaring both sides lets you avoid the slow SQRT, and stay with ints if your inputs are integer: | |
(R0-R1)^2 <= (x0-x1)^2+(y0-y1)^2 <= (R0+R1)^2 | |
//Since you need only a yes/no test, this check is faster than calculating the exact intersection points. | |
//Edit: corrected for the "one circle inside the other" case. |
//PHP implementation for normalisation: | |
function normalize($value, $min, $max) { | |
$normalized = ($value - $min) / ($max - $min); | |
return $normalized; | |
} | |
//Denormalization | |
function denormalize($normalized, $min, $max) { | |
$denormalized = ($normalized * ($max - $min) + $min); |
/** | |
Fast inverse square root is an algorithm that estimates 1/√x, the reciprocal (or multiplicative inverse) of the square root of a 32-bit floating bit number x. This operation is used in digital signal processing to normalize a vector, i.e., scale it to length 1. For example, computer graphics programs use inverse square roots to compute angles of incidence and reflection for lighting and shading The algorithm is best known for its implementation in 1999 in the source code of Quake III Arena, a first-person shooter video game that made heavy use of 3D graphics. The algorithm only started appearing on public forums such as Usenet in 2002 or 2003. | |
At the time, it was generally computationally expensive to compute the reciprocal of a floating-point number, especially on a large scale; the fast inverse square root bypassed this step. | |
**/ | |
float InvSqrt(float x){ | |
float xhalf = 0.5f * x; | |
int i = *(int*)&x; // store floating-point bits in integer |
//Originally found here - https://stackoverflow.com/questions/19014907/call-fotorama-gallery-in-full-screen-mode-via-api | |
<script> | |
$(function () { | |
var fotorama = $('.fotorama') | |
.fotorama({allowfullscreen: true}) | |
.data('fotorama'); | |
fotorama.requestFullScreen(); | |
}); |
var countDownDate = new Date("Jan 5, 2018 15:37:25").getTime(); | |
// Update the count down every 1 second | |
var x = setInterval(function() { | |
// Get todays date and time | |
var now = new Date().getTime(); | |
// Find the distance between now an the count down date | |
var distance = countDownDate - now; |