Skip to content

Instantly share code, notes, and snippets.

@lambdahands
lambdahands / _readme.md
Created September 28, 2015 17:09
FlowType and CSS Modules

Huh?

So basically FlowType doesn't know about CSS Modules, a really handy way of dealing with the plagues of CSS in codebases (global variables and dependency wackiness mainly).

What WebPack allows us to do is "require" CSS files and use their class names:

import styles from "my_styles.css";
import React from "react";
var Col = require('react-bootstrap/lib/Col')
var PageHeader = require('react-bootstrap/lib/PageHeader')
var React = require('react')
var Row = require('react-bootstrap/lib/Row')
var {connect} = require('react-redux')
var {reduxForm} = require('redux-form')
var DateInput = require('./DateInput')
var FormField = require('./FormField')
var LoadingButton = require('./LoadingButton')
@justinweiss
justinweiss / settings.rb
Created May 27, 2014 16:54
Simple settings for Rails
require 'yaml'
require 'erb'
require 'ostruct'
class Settings < OpenStruct
# Settings.new(:google_analytics)
def initialize(config_file_base_name)
super(YAML.load(ERB.new(File.read(Rails.root.join("config", "#{config_file_base_name}.yml"))).result)[Rails.env])
end
@christiannelson
christiannelson / new-project-setup.md
Last active February 15, 2016 00:06
From Nothing to Continuous Deployment in about 10 Minutes

These instructions walk you through using Raygun to generate a new app, pushing it to GitHub, deploying it to Heroku (two envs: production and acceptance), and setting up continuous integration and deployment using CircleCI. There's a preference for command-line operations when possible.

Prerequisties

  • Homebrew
  • Heroku toolbelt (brew install heroku-toolbelt)
  • Postgres installed (brew install postgres) and running
  • Postgres superuser called 'postgres' (createuser -s postgres)
  • PhantomJS installed (brew install phantomjs)
  • GitHub gem (gem install hub)
/* global google */
var GoogleMapComponent = Ember.Component.extend({
places: [],
width: 500,
height: 500,
attributeBindings: ['style'],
style: function () {
return 'width:'+this.width+'px; height:'+this.height+'px';
@djg
djg / woah.js
Last active December 29, 2015 12:09
Yeah, umm. WAT?!
function base_colors(src, mode) {
var col_1, col_2;
function compare(c1, c2) {
return (c1[0] * 16384 + c1[1] * 256 + c1[2]) >=
(c2[0] * 16384 + c2[1] * 256 + c2[2]);
}
if (mode === 'I') {
col_1 = extend_4to8bits(src[7], src[6], src[5]),
col_2 = extend_4to8bits(src[7] << 4, src[6] << 4, src[5] << 4)
return [ col_1, col_2 ];
@achakravarty
achakravarty / app.js
Created November 11, 2013 05:18
Sample code for demonstrating jQuery validations with Ember.js
var App = Ember.Application.create();
App.Router.map(function(){
this.resource('user');
});
App.UserController = Ember.ObjectController.extend(Ember.Evented, {
actions: {
submit: function(){
var validation = {isValid: false};

Guide to loading/error events and substates

In addition to the techniques described in the Asynchronous Routing Guide, the Ember Router provides powerful yet overridable conventions for customizing asynchronous transitions between routes by making use of error and loading substates.

loading substates

@tcjr
tcjr / messages.json
Last active December 25, 2015 06:59
Basic pagination with Ember
// The API accepts the page parameter and returns the pagination info in meta
{
"messages": [ ... ],
"meta": {
"pagination": {
"total_pages": 3,
"current_page": 1,
"total_count": 55
}