Skip to content

Instantly share code, notes, and snippets.

View dcousineau's full-sized avatar
:shipit:
WORKING HARD OR HARDLY WORKING AHAHAHAH

Daniel Cousineau dcousineau

:shipit:
WORKING HARD OR HARDLY WORKING AHAHAHAH
View GitHub Profile
class Chart extends React.Component {
static propTypes = {
width: React.PropTypes.number,
height: React.PropTypes.number,
data: React.PropTypes.shape({
x: React.PropTypes.number.isRequired,
y: React.PropTypes.number.isRequired
}).isRequired
};
var loadImage = require('image').loadImage;
var images = [
'url1',
'url2',
'url3',
//...
];
Promise.all(images.map(loadImage)).then(function() {
import React from 'react';
import throttle from 'lodash/function/throttle.js';
import extend from 'lodash/object/extend.js';
import getCaretPosition from 'caret.js';
const TEST_DATA = [
{ value: "SomethingNoSpaces", label: "Something No Spaces" }
];
import React from 'react';
export default class ShowOnRoute extends React.Component {
static contextTypes = {
router: React.PropTypes.func.isRequired
};
static propTypes = {
name: React.PropTypes.string.isRequired,
// --------------------------------------------------
// Flexbox LESS mixins
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// Flexbox display
// flex or inline-flex
.flex-display(@display: flex) {
display: ~"-webkit-@{display}";
display: ~"-moz-@{display}";
import React from 'react';
import Marty from 'marty';
import {RouteHandler} from 'react-router';
import Login from 'pages/user/login.jsx';
export default Marty.createContainer(RouteHandler, {
listenTo: ["stores.AuthStore"],
fetch: {
define(['foo1', 'foo2'], function(Foo1, Foo2) {
var test = Foo1.test;
test(Foo2);
return {
results: 'result'
};
});
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>IFrame Test (MB JJ)</title>
<style>
@media (min-width: 850px) {
.container { width: 100%; }
}
@media (min-width: 1056px) {
@dcousineau
dcousineau / app.js
Last active August 29, 2015 14:19
How to initialize cookies for Safari when your app lives in an Iframe
import cookie from 'cookie-cutter';
App.on('before:start', () => {
//Safari does not respect P3P policies by default and blocks all 3rd party cookies (which is what our cookie is when
//loaded in an Iframe). To work around this we need to open a window to our application and set the cookies then
//close it. Safari allows us to interact with cookies that have already been set (but not create new ones).
if (cookie.get('expected_cookie') === undefined) {
//However, Safari (like all browsers) puts the kibosh on all windows that open without user interaction!
//Therefore we intercept all clicks to open the short-lived window that initializes all of our cookies.
$(document.body).one('click', '[data-goto]', e => {
@dcousineau
dcousineau / example_usage.js
Last active August 29, 2015 14:18
Super safe CORS image loader that bypasses browser caches
import image from 'image';
image
.load("/my/image/url")
.then(img => {
let canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
canvas.getContext("2d").drawImage(img, 0, 0);
//...