Skip to content

Instantly share code, notes, and snippets.

View secretfader's full-sized avatar
🚩
new winds

Nicholas Young secretfader

🚩
new winds
View GitHub Profile
def show
case Car.create(conn.assigns.user, params) do
{:ok, car} ->
conn
|> redirect(to: car)
{:error, changeset} ->
conn
|> render("new.html", changeset: changeset)
end
end
@sebmarkbage
sebmarkbage / Enhance.js
Last active January 31, 2024 18:33
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@koistya
koistya / ReactJS-Server-Side-Rendering.md
Last active September 15, 2023 07:32
Server-side Rendering (SSR) for ReactJS / Flux Applications. Setting document.title

Files

The basic structure of a React+Flux application (see other examples)

 - /src/actions/AppActions.js     - Action creators (Flux)
 - /src/components/Application.js - The top-level React component
 - /src/constants/ActionTypes.js  - Action types (Flux)
 - /src/core/Dispatcher.js        - Dispatcher (Flux)
 - /src/stores/AppStore.js        - The main store (Flux)
@mojodna
mojodna / Procfile
Created September 29, 2011 20:22 — forked from RandomEtc/Procfile
Getting Kue working on Heroku
web: node app.js
worker: node consumer.js
@masylum
masylum / s3upload.js
Created December 19, 2010 17:48
Upload files directly to s3
function upload (req, res) {
var Formidable = require('formidable'),
form = new Formidable.IncomingForm();
form.encoding = 'utf-8';
form.onPart = function (part) {
if (!part.filename) {
form.handlePart(part);
} else {
(function () {
@saschagehlich
saschagehlich / i18n.coffee
Created September 14, 2010 00:48
Simple i18n with node.js and express.js
exports.I18n =
en:
title: "Free YouTube video download"
navi:
home: "Home"
howto: "Tutorial"
blog: "Blog"
termsofuse: "Terms of Use"
support: "Support"
imprint: "Imprint"
@jeffrafter
jeffrafter / handler.js
Created April 2, 2010 20:59
Simple HTTP Server and Router in node.js
exports.createHandler = function (method) {
return new Handler(method);
}
Handler = function(method) {
this.process = function(req, res) {
params = null;
return method.apply(this, [req, res, params]);
}
}
@mislav
mislav / gist:17371
Created October 17, 2008 07:42
haml2erb
class ErbEngine < Haml::Engine
def push_script(text, preserve_script, in_tag = false, preserve_tag = false,
escape_html = false, nuke_inner_whitespace = false)
push_text "<%= #{text.strip} %>"
end
def push_silent(text, can_suppress = false)
push_text "<% #{text.strip} %>"
end
end