Skip to content

Instantly share code, notes, and snippets.

@JoshBarr
JoshBarr / frontend_permissions.py
Created March 16, 2016 20:40
Wagtail front-end permissions mixin
# Mixin
class PermissionRequiredMixin:
required_permissions = []
def route(self, request, path_components):
if not request.user.has_perms(self.required_permissions):
return RouteResult(self, kwargs={'permission_check_failed': True})
return super().route(request, path_components)
@JoshBarr
JoshBarr / Preferences.sublime-settings
Created September 16, 2015 05:11
sublime config
{
"always_show_minimap_viewport": true,
"auto_complete": false,
"auto_complete_commit_on_tab": true,
"auto_match_enabled": true,
"bold_folder_labels": true,
"caret_style": "solid",
"color_scheme": "Packages/User/SublimeLinter/Material Oceanic Next (SL).tmTheme",
"detect_indentation": true,
"draw_indent_guides": true,
import React from 'react';
import * as utils from '../utils';
var whichAnimationEvent = utils.whichAnimationEvent();
export default React.createClass({
getNode() {
return this.refs.node.getDOMNode();
},
@JoshBarr
JoshBarr / InfoModal.js
Created August 18, 2015 01:34
react modal using child element for the link trigger
import React from 'react';
import { Router, Link } from 'react-router';
import Modal from 'react-modal';
import Slider from '../components/Slider.js';
import Metric from '../components/Metric.js';
import DEFAULTS from '../config/defaults.js';
var appElement = document.getElementById('mount');
Modal.setAppElement(appElement);
@JoshBarr
JoshBarr / Carousel.js
Last active January 20, 2019 23:21
Flickity React integration
@JoshBarr
JoshBarr / uuid.js
Created June 3, 2015 19:06
Quick UUID in JS
function uuid() {
var i, random;
var uuid = '';
for (i = 0; i < 32; i++) {
random = Math.random() * 16 | 0;
if (i === 8 || i === 12 || i === 16 || i === 20) {
uuid += '-';
}
uuid += (i === 12 ? 4 : (i === 16 ? (random & 3 | 8) : random)).toString(16);
@JoshBarr
JoshBarr / .scss-lint.yml
Last active August 29, 2015 14:19
CSS Guidelines
scss_files: 'site/*/scss/**/*.scss'
exclude: 'site/**/scss/**/vendor/*.scss'
linters:
BorderZero:
enabled: true
Indentation:
severity: warning
width: 4
@JoshBarr
JoshBarr / index.html
Created March 12, 2015 04:44
Range slider
<!DOCTYPE html>
<html>
<head>
<title>Slider test</title>
<style type="text/css">
body {
font-family: pitch, courier;
margin: 4em;
}