Skip to content

Instantly share code, notes, and snippets.

@joakimk
joakimk / socket.js
Last active August 22, 2016 06:45
An example of auto reload on deploy in an Elixir Phoenix app
import {Socket} from "phoenix"
let socket = new Socket("/socket", { params: {} })
socket.connect()
let channel = socket.channel("updates", {})
channel.join()
// Reload the app if it's out of date when it joins the websocket
let revision = null
var webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var shared = require('./shared')
module.exports = {
devtool: 'inline-source-map',
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',

Hang on, I'm not saying flux is dead, or that redux isn't amazing.

Okay ...

Most everybody is familiar with flux by now:

User Interaction --event data-->
  Action Creator --action-->
 Dispatcher --payload-->

Folder Structure

Please note

While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.

Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.

ui2/app
├── components
│   ├── Header.js
│   └── Main.js
├── shared
│   ├── components
│   │   ├── T-test.js
│   │   └── T.js
│   ├── lib
│   │   ├── I18n.js
.
├── actions
├── stores
├── views
│   ├── Anonymous
│   │   ├── __tests__
│   │   ├── views
│   │   │   ├── Home
│   │   │   │   ├── __tests__
│   │   │   │   └── Handler.js
@tkafka
tkafka / LICENSE.txt
Last active May 17, 2024 02:08
Drop-in replacement for ReactCSSTransitionGroup that uses velocity.js instead of CSS transforms. Add your own transitions to `transitions` hash.
The MIT License (MIT)
Copyright (c) 2014 Tomas Kafka
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@mlangenberg
mlangenberg / ams_cache.rb
Last active August 29, 2015 13:58
One approach to cache ActiveModelSerializer representations with ActiveRecord objects
class User < ActiveRecord::Base; end;
class Post < ActiveRecord::Base; end;
class Comment < ActiveRecord::Base; end;
class AuthorSerializer < ActiveModel::Serializer
attributes :id, :name :created_at, :updated_at
end
class PostSerializer < ActiveModel::Serializer
attributes :id, :body :created_at, :updated_at
@cheeaun
cheeaun / image-processing-services.md
Last active April 20, 2024 22:17
3rd-party image processing/manipulation/upscaling/enlarging services
@markoa
markoa / deploy.rb
Created October 10, 2011 13:31
Ingredients to monitor Resque with God automatically via Capistrano (on Ubuntu)
namespace :deploy do
desc "Hot-reload God configuration for the Resque worker"
task :reload_god_config do
sudo "god stop resque"
sudo "god load #{File.join(deploy_to, 'current', 'config', 'resque-' + rails_env + '.god')}"
sudo "god start resque"
end
end
# append to the bottom: