Skip to content

Instantly share code, notes, and snippets.

View alfonsojimenez's full-sized avatar
💭
🚀

Alfonso Jiménez alfonsojimenez

💭
🚀
View GitHub Profile
@georgkreimer
georgkreimer / point_in_polygon.rb
Created September 17, 2010 21:34
tests if a point is inside a polygon (ported code from c example)
polygon = [{:x=>0,:y=>0},{:x=>4,:y=>0},{:x=>2,:y=>2},{:x=>0,:y=>4}]
point0 = {:x=>0,:y=>0}
point1 = {:x=>0.00000000001,:y=>0.00000000001}
point2 = {:x=>1,:y=>1}
point3 = {:x=>2,:y=>2}
point4 = {:x=>1.99999999999,:y=>1.99999999999}
# http://www.visibone.com/inpoly/
# http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
#

Falsehoods programmers believe about prices

  1. You can store a price in a floating point variable.
  2. All currencies are subdivided in 1/100th units (like US dollar/cents, euro/eurocents etc.).
  3. All currencies are subdivided in decimal units (like dinar/fils)
  4. All currencies currently in circulation are subdivided in decimal units. (to exclude shillings, pennies) (counter-example: MGA)
  5. All currencies are subdivided. (counter-examples: KRW, COP, JPY... Or subdivisions can be deprecated.)
  6. Prices can't have more precision than the smaller sub-unit of the currency. (e.g. gas prices)
  7. For any currency you can have a price of 1. (ZWL)
  8. Every country has its own currency. (EUR is the best example, but also Franc CFA, etc.)
@ktheory
ktheory / LICENSE
Last active August 29, 2015 14:06
Redis indicators
Copyright 2014 Kickstarter, Inc.
Released under an MIT License.
@felixbuenemann
felixbuenemann / varnish4-newrelic-x-request-start.vcl
Last active February 2, 2017 10:44
Varnish 4 X-Request-Start Header for New Relic Queue Time Reporting
# To allow inline-C in VCL start varnishd with -p vcc_allow_inline_c=on
C{
#include <sys/time.h>
#include <stdio.h>
static const struct gethdr_s VGC_HDR_REQ_reqstart = { HDR_REQ, "\020X-Request-Start:" };
}C
sub vcl_recv {
# Add X-Request-Start header for New Relic queue time analytics
C{
[
{
"name": "Amsterdam Airport Schiphol",
"description": "Free wifi; network name: Airport_Free_WiFi (1 hour time limit) -- British Airways Lounge password: singapore -- Crown Lounge 52 network name: KLM-Lounge - password (only phones need password): (your name)#KLM\n\nHere's how to unlock airport wireless time limits: (https://foxnomad.com/2014/05/22/unlock-unlimited-wifi-airports-time-restrictions/)\n",
"long": 4.7682744,
"lat": 52.3105386
},
{
"name": "Frankfurt Airport",
"description": "Free wireless extended throughout entire airport. Network name: Frankfurt Airport, Hotspot Telekom - Name and email required. (Password: Internet)",
https://jennamolby.com/how-to-use-cookies-to-capture-url-parameters/
let YOUR_DOMAIN = "YOUR_DOMAIN.TLD" // ex: scrapingbee.com
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}