This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var previousDraggedPosition = null, | |
selected = null; | |
// snap to grid is simply rounding to the nearest resolution of the square | |
function snapToGrid(p, r) { | |
return Math.round(p / r) * r; | |
} | |
// we'll use a resolution of 50 here | |
var cubeResolution = 50; | |
// randomly generate points, but make sure they snap to grid | |
var points = d3.range(10).map(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// save the current zoom in this object | |
// this is useful for redraws later on | |
var currentTransform = null; | |
// add a subview with a group tag - we'll add objects to this later | |
var view = svg.append("g") | |
.attr("class", "view"); | |
// you would execute this on any draw action to adjust zoom | |
if (currentTransform) view.attr('transform', currentTransform); | |
// this is d3's main zoom plugin - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: gpl-3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
.axis path { | |
display: none; | |
} | |
.axis line { | |
stroke-opacity: 0.3; | |
shape-rendering: crispEdges; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: gpl-3.0 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var webpack = require('webpack'); | |
var HtmlWebpackPlugin = require('html-webpack-plugin'); | |
var ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
var helpers = require('./helpers'); | |
module.exports = { | |
entry: { // in this case we have three entry points in order to import three separate files for our build | |
'polyfills': './src/polyfills.ts', | |
'vendor': './src/vendor.ts', | |
'app': './src/main.ts' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Paths is a nodejs global object with path url string we're using to specify our bundle | |
const gulp = require('gulp'); | |
const browserify = require('browserify'); | |
const gutil = require('gulp-util'); | |
const source = require('vinyl-source-stream'); // Convert our stream to an output vinyl | |
const sourcemaps = require('gulp-sourcemaps'); // We need to include the sourcemaps for our files | |
const ngAnnotate = require('browserify-ngannotate'); // e.g Browserify plugin to make sure Angular dependencies will work on minification | |
const buffer = require('vinyl-buffer'); // This finishes what source stream started | |
/* BROWSERIFY SETTINGS */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="bower_components/pusher-websocket-iso/dist/web/pusher.js"></script> | |
<script src="bower_components/pusher-angular/lib/pusher-angular.min.js"></script> | |
<script> | |
// in app.js | |
angular.module("YourApp",['pusher-angular']) | |
// in pusherService.js | |
(function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UberService | |
def run | |
#... all the other stuff we did before | |
send_pusher(data, build_pusher_notification(data)) | |
end | |
def send_pusher(response, text) | |
channel = 'private-' + @current_identity.user.id.to_s | |
Pusher.trigger(channel, 'notification', { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in routes.rb add your endpoint | |
post 'pusher/auth', to: "pusher#auth" | |
# create a pusher_controller.rb in your api | |
class Api::V1::PusherController < Api::V1::BaseController | |
skip_authorization_check | |
skip_before_filter :check_api_auth!, only: [:auth] |