Skip to content

Instantly share code, notes, and snippets.

View BastinRobin's full-sized avatar
🏠
Working from home

Bastin Robin BastinRobin

🏠
Working from home
View GitHub Profile
<style type="text/css">p {text-align:center;width: auto}</style>

Created by Christopher Manning

Gallery

Axle Eight [Fibbobaci](http://bl.ocks.org/d/1703449/#/[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169]43/0/1) [Florets](http://bl.ocks.

@BastinRobin
BastinRobin / app.js
Created December 25, 2013 08:14 — forked from arvis/app.js
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, http = require('http')
, mongoose = require('mongoose')
, path = require('path');

This example shows how it is possible to use a D3 sunburst visualization (partition layout) with data that describes sequences of events.

A good use case is to summarize navigation paths through a web site, as in the sample synthetic data file (visit_sequences.csv). The visualization makes it easy to understand visits that start directly on a product page (e.g. after landing there from a search engine), compared to visits where users arrive on the site's home page and navigate from there. Where a funnel lets you understand a single pre-selected path, this allows you to see all possible paths.

Features:

  • works with data that is in a CSV format (you don't need to pre-generate a hierarchical JSON file, unless your data file is very large)
  • interactive breadcrumb trail helps to emphasize the sequence, so that it is easy for a first-time user to understand what they are seeing
  • percentages are shown explicitly, to help overcome the distortion of the data that occurs wh

Conventions:

Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';

<?php
/*
|--------------------------------------------------------------------------
| Return a Collection of Objects
|--------------------------------------------------------------------------
*/
// collection of all users
$sql = "select * from users";
// takes the form field value and returns true on valid number
function valid_credit_card(value) {
// accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
var nCheck = 0, nDigit = 0, bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
/*
Taken and cribbed from blog.datalicious.com/free-download-all-australian-postcodes-geocod
May contain errors where latitude and longitude are off. Use at own non-validated risk.
*/
SET NAMES utf8;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP TABLE IF EXISTS postcodes_geo;
// Routes.php
Route::get('upload', function()
{
return View::make('upload-form');
});
Route::post('upload', function()
{
// Get and move uploaded file.
<?php
// This creates a date string in the format YYYY-WNN, which is
// a four digit year followed by a hyphen and letter W then the
// two digit week number
$strtotime = date("o-\WW");
// The $start timestamp contains the timestamp at 0:00 on the
// Monday at the beginning of the week
$start = strtotime($strtotime);