Skip to content

Instantly share code, notes, and snippets.

@donabrams
donabrams / findDependencies.js
Created September 17, 2015 21:00
List all dependencies for given entry points
var detective = require('detective');
var fs = require('fs');
var _ = require('lodash');
var path = require('path');
var resolve = require('resolve');
var toProcess = [{name: './index.js', basedir: __dirname}];
var entries = {};
while (toProcess.length) {
@donabrams
donabrams / todoExample.jsx
Last active October 4, 2015 19:10
Ember TodoMVC quasi port to React
// This Page Component would normally be auto-generated from a template
class TodoPage extends Component {
render() {
let bootstrap = `
var Todos = require('Todos');
// really, we use redux for injecting/setting up initialProps and tying in action handlers
var element = React.createElement(Todos, {});
React.render(element, getElementById('app'));
`;
@donabrams
donabrams / playground.rs
Last active December 22, 2015 16:33 — forked from anonymous/playground.rs
Shared via Rust Playground
use std::collections::HashMap;
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
use std::fs::File;
use std::error::Error;
use std::mem;
use std::str;
type Something<'a> = HashMap<&'a str, &'a str>;
@donabrams
donabrams / playground.rs
Created December 22, 2015 16:55 — forked from anonymous/playground.rs
Shared via Rust Playground
use std::collections::HashMap;
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
use std::fs::File;
use std::error::Error;
use std::mem;
use std::str;
type Something = HashMap<String, String>;
@donabrams
donabrams / SUCESS.rs
Last active December 22, 2015 18:12 — forked from anonymous/playground.rs
Shared via Rust Playground
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
use std::fs::File;
fn main(){
match get_line_vec("yay.txt") {
Ok(vec) => {
let mut mut_vec = vec;
let a = mut_vec.pop().unwrap();
@donabrams
donabrams / SUCESS.rs
Last active December 22, 2015 18:06 — forked from anonymous/playground.rs
Shared via Rust Playground
fn main() {
let mut p = get_mut();
while let Some(x) = p.pop() {
print!("{} ", x);
}
println!("");
}
fn get_mut<'s>() -> Vec<i16> {

babel-plugin-encapsulate-jsx

TLDR; A babel plugin to namespace your components to package/version combinations. There is an associated css plugin.

why

At Craftsy, we use a monorepo: each React component is in it's own npm package.

let obj = checkin
do {
console.log(Object.getOwnPropertyNames(obj))
} while ((obj = Object.getPrototypeOf(obj)) !== null)
@donabrams
donabrams / InstallCinnamonCrouton
Last active July 18, 2016 15:03 — forked from sohjsolwin/InstallCinnamonCrouton
Steps to install and setup a cinnamon flavored crouton on a Chromebook Pixel
# The next command will install a [raring] based ubuntu
# chroot, named [cinnamon] into the default directory
# with the targets [core], [cli-extra], [touch], and [keyboard]
sudo crouton -n cinnamon -r xenial -t core,cli-extra,touch,keyboard
# Supply your new username and password like normal, and
# once that finishes, enter the chroot with:
sudo enter-chroot -n cinnamon
@donabrams
donabrams / example.js
Created August 24, 2016 18:33
Redux Reducer Middleware to Conditionally Execute a second action
import {createStore} from 'redux';
import {interceptingAction} from 'redux-intercepting-action';
import {createAction} from 'redux-actions';
import reducer from './reducers'
const getInterceptingAction = (state)=> {
if (state.good) {
return {
type: 'YAY'
}