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(() => {
@evanjmg
evanjmg / index.html
Last active February 19, 2017 17:17
Drag, Zoom in Grid d3 v4
<!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
@evanjmg
evanjmg / .block
Last active February 19, 2017 16:39
Simple Zoom Example d3 v4
license: gpl-3.0
// 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 / 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;
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'
require 'typhoeus'
class Identity < ActiveRecord::Base
belongs_to :user
def refresh_token_if_expired(domain)
if token_expired?
client_id_key = self.provider.upcase + '_CLIENT_ID'
client_secret_key = self.provider.upcase + '_CLIENT_SECRET'
r= 'http://localhost:9000/' + self.provider
function login () {
// get your specified redirect uri - usually window.location + '/uber'
var redirect_uri = '{your-url}'
// generate login url to get oauth code
var url = 'https://login.uber.com/oauth/v2/authorize?client_id='+ ENV['uber'] +'&response_type=code&scope=request+all_trips+profile&redirect_uri='+ redirect_uri;
// replace current url with new url
window.location.replace(url);
}
<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 () {