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
def gc():
"""
Garbage collect cache directory ensuring oldest files are deleted until the cache limit is met
"""
# List of files in cache dir in order of oldest to newest
files = sorted(
[path(f) for f in os.listdir(cache_dir) if os.path.isfile(path(f))],
key=lambda file: os.path.getmtime(file)
)
@dcousineau
dcousineau / thelist.md
Last active August 29, 2015 14:13
Things To Do In DFW

Things to do in Dallas

Downtown Dallas

  • Perot Museum of Nature and Science - 5 story museum, flagship
  • Dallas World Aquarium - Awesome aquarium, but less tanks and more rain forest. Walking distance from Perot, one of my favorite places
  • 6th Floor Museum - Museum dedicated to the JFK assasination in the book loft where Lee Harvey's sniper's nest was. There's an X on the road out front where the actual assassination happened, restaurants nearby in Historic West End
  • Old Red Museum - Dallas history, across street from the 6th Floor Museum, restaurants nearby in Historic West End
  • Nasher Sculpture Center - The ceiling of the entry/lobby is a sculpture in and of itself
  • Dallas Museum of Art - Should be free now
  • Klyde Warren Park - *Cool city park built as a 'roof' over
@dcousineau
dcousineau / README.md
Last active August 29, 2015 14:16
Reproduction of watchify bug

To reproduce

  1. Run npm install
  2. Run gulp watch-js
  3. Open test.html, notice the proper content
  4. Remove the comment on line 16 of app.jsx
  5. Refresh test.html, notice the white screen and the call stack size exceeded error in the console
@dcousineau
dcousineau / gulpfile.js
Created April 9, 2015 14:07
Gulp Build System
"use strict";
var _ = require('underscore')
, nodeResolve = require('resolve')
, gulp = require('gulp')
, gutil = require('gulp-util')
, browserify = require('browserify')
, watchify = require('watchify')
, babelify = require('babelify')
, source = require('vinyl-source-stream')
@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);
//...
@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 => {
<!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) {
define(['foo1', 'foo2'], function(Foo1, Foo2) {
var test = Foo1.test;
test(Foo2);
return {
results: 'result'
};
});
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: {
// --------------------------------------------------
// 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}";