Skip to content

Instantly share code, notes, and snippets.

View stecb's full-sized avatar
🤓
Ciao!

Stefano Ceschi Berrini stecb

🤓
Ciao!
View GitHub Profile
@k88hudson
k88hudson / bare-bones-react-webpack.js
Last active February 13, 2017 19:34
Bare-bones react/webpack set-up
/* First, install dependencies:
npm install webpack babel-loader babel-core babel-preset-react --save-dev
npm install react react-dom --save
Note: babel dependencies are not needed if you aren't using jsx)
*/
// webpack.config.js
// Note: This assumes a "main.js" file in a src/ directory, and outputs "main.bundle.js" to a dist/ directory
import { Match, Redirect } from 'react-router'
// With the way we use Redirect in this demo, the word "AddressBar" probably
// makes more sense!
const AddressBar = ({ url }) => (
<Redirect to={url}/>
)
class InfniteArticleHomePage extends React.Component {

@kangax's ES6 quiz, explained

@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).

Here we go with the explanations:

Question 1:
(function(x, f = () =&gt; x) {

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.

@jordwalke
jordwalke / gist:6350319
Last active September 10, 2016 16:27
ReactJS: JavaScript just like you've always done it.
/**
* ReactJS: JavaScript like you've always done it.
*
* This example renders your top ten most followed friends/followers, `filter`ing
* only your favorites, and putting a star on all verified accounts.
*
* With ReactJS, any time your data changes, the UI is always brought up to date
* automatically. If friends length changes, or followCount - it always shows what
* `render` describes.
*/
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@smebberson
smebberson / .gitignore
Created January 9, 2012 06:46
Express simple authentication example
node_modules
*.swp
js> isNaN(null);
false
js> null > -1;
true
js> null < 1;
true
js> null > 0;
false
js> null < 0;
false