Skip to content

Instantly share code, notes, and snippets.

View evanjmg's full-sized avatar
👨‍💻
actively contributing

Evan Gillogley evanjmg

👨‍💻
actively contributing
View GitHub Profile
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(() => {
// 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 -
@evanjmg
evanjmg / .block
Last active February 19, 2017 16:39
Simple Zoom Example d3 v4
license: gpl-3.0
@evanjmg
evanjmg / index.html
Last active February 19, 2017 16:14
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.axis path {
display: none;
}
.axis line {
stroke-opacity: 0.3;
shape-rendering: crispEdges;
@evanjmg
evanjmg / .block
Last active February 19, 2017 16:43
Drag, Pan, Snap To Grid example
license: gpl-3.0
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'
@evanjmg
evanjmg / gulp-browserify-sample.js
Last active January 21, 2021 19:31
Browserify Sample
// 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 */
<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 () {
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', {
# 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]