Skip to content

Instantly share code, notes, and snippets.

@ZwaarContrast
ZwaarContrast / signin.js
Last active January 3, 2018 19:52
Sign in Component using updated redux-form.
import React, { Component } from 'react';
import {Field,reduxForm} from 'redux-form';
import {connect} from 'react-redux';
import * as actions from '../../actions';
class Signin extends Component {
handleSignin({ email, password }){
// Log values
console.log('Email', email);
@markerikson
markerikson / render-logic.js
Last active January 1, 2024 06:20
React render function organization
// See https://blog.isquaredsoftware.com/presentations/react-redux-ts-intro-2020-12/#/36 for slides
// My basic render function structure:
function RenderLogicExample({
someBoolean, // 1) Destructure values from `props` object
someList,
}) {
// 2) Declare state values
const [a, setA] = useState(0);
const [b, setB] = useState(0);
@markerikson
markerikson / nodeenvDiscussion.md
Last active January 9, 2023 15:24
Summary of process.env.NODE_ENV and its use with Webpack

[02:06 PM] acemarke: @Steven : a couple other thoughts on the whole NODE_ENV thing. First, per my comments, it really is a Node concept. It's a system environment variable that Node exposes to your application, and apparently the Express web server library popularized using its value to determine whether to do optimizations or not
[02:08 PM] acemarke: Second, because of its use within the Node ecosystem, web-focused libraries also started using it to determine whether to they were being run in a "development" environment vs a "production" environment, with corresponding optimizations. For example, React uses that as the equivalent of a C #ifdef to act as conditional checking for debug logging and perf tracking. If process.env.NODE_ENV is set to "production", all those if clauses will evaluate to false.
Third, in conjunction with a tool like UglifyJS that does minification and removal of dead code blocks, a clause that is surrounded with if(process.env.NODE_ENV !== "development")

@coryhouse
coryhouse / package.json
Last active November 9, 2023 06:04
Example of pre and post scripts in package.json
{
"name": "npm-scripts-example",
"version": "1.0.0",
"description": "npm scripts example",
"scripts": {
"prebuild": "echo I run before the build script",
"build": "cross-env NODE_ENV=production webpack",
"postbuild": "echo I run after the build script"
}
}
/**
* @providesModule PatientList
*/
import NavigationBar from 'react-native-navbar';
import NavigationButtons from 'NavigationButtons';
import React, { ListView, Navigator, StyleSheet, Text, TextInput, TouchableHighlight, View } from 'react-native';
import { connect } from 'react-redux/native'
@connect(state => ({
patients: state.patients
@fxg42
fxg42 / HelloController.groovy
Last active January 26, 2017 20:02
Comparing Express, Phoenix, Rails, Flask, Grails and... PHP?
class HelloController {
def index() {
render([ hello:"world!" ] as grails.converters.JSON)
}
}
@ktuukkan
ktuukkan / JsonMarshallers.groovy
Last active December 29, 2021 05:05
Custom Grails JSON marshalling
package example
import example.Book
import example.Author
import grails.converters.JSON
/**
* Probably the cleanest way to define custom JSON marshalling in Grails.
*
* Imagine Book and Author are domain classes with some typical fields.
*
@nulltask
nulltask / app.js
Created March 17, 2012 08:46
Output CSV in Express
/**
* Module dependencies.
*/
var express = require('express')
, app = module.exports = express.createServer();
// Configuration
app.use(app.router);
@jagregory
jagregory / gist:710671
Created November 22, 2010 21:01
How to move to a fork after cloning
So you've cloned somebody's repo from github, but now you want to fork it and contribute back. Never fear!
Technically, when you fork "origin" should be your fork and "upstream" should be the project you forked; however, if you're willing to break this convention then it's easy.
* Off the top of my head *
1. Fork their repo on Github
2. In your local, add a new remote to your fork; then fetch it, and push your changes up to it
git remote add my-fork git@github...my-fork.git
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')