Skip to content

Instantly share code, notes, and snippets.

@marr
marr / .block
Created July 18, 2017 20:15
fresh block
license: mit
@marr
marr / .block
Created July 18, 2017 20:15
fresh block
license: mit
@marr
marr / .block
Last active August 1, 2017 23:25
Valley Fair Level 1 - Interactions
license: mit
import { pointInPolygon } from './utils';
const Vector = (x, y) => ({ x, y });
it('detects points in polygons', () => {
const vertices = [
[1, 1],
[1, 4],
[4, 4],
[4, 1]
@marr
marr / .rb
Last active June 9, 2017 22:04
class Slug < ActiveRecord::Base
before_validation :generate_slug
validates :slug, presence: true, uniqueness: true
private
def generate_slug
self.slug = self.value.parameterize
end
end
class Slug < ActiveRecord::Base
slugify :override_value, :to => :slug
validates :slug, presence: true, uniqueness: true
end
import { call, spawn } from 'redux-saga/effects'
import { sagas as centreSagas } from './ducks/centres'
export default async function rootSaga() {
const sagas = [...centreSagas]
await sagas.map(saga =>
spawn(async function () {
console.log(saga);
let isSyncError = false
var PIBY2 = Math.PI / 2;
var ToDegrees = 180 / Math.PI;
var x = 50;
var y = 50;
var vx = Math.random() - 0.5;
var vy = Math.random() - 0.5;
function update() {
<Route path="/" component={App} onEnter={authenticate}>
<IndexRoute component={HomePage} />
<Route path="feedback" component={Feedback} />
<Route path="search(/:query)" component={HomePage} />
</Route>
import 'isomorphic-fetch'
import { test } from 'tap'
import nock from 'nock'
nock('http://localhost')
.get(/item\/(.*)/)
.times(2)
.reply(200, function(url, requestBody) {
const user = url.substr(url.lastIndexOf('/') + 1)
return `You found user ${user}`