Skip to content

Instantly share code, notes, and snippets.

@JSila
JSila / App.js
Created January 12, 2017 14:26
Example of showing/hiding Twitter Bootstrap (4) modal - with react, not jquery
import React, { Component } from 'react'
import Modal from './Modal'
export default class extends Component {
constructor(props) {
super(props)
this.state = {
isOpen: false
@JSila
JSila / FormGroup.js
Last active December 19, 2016 20:28
Highly reusable FormGroup React stateless component with Twitter Bootstrap 4 specific CSS classes
import React, {PropTypes} from 'react'
import classnames from 'classnames'
import setDisplayName from 'recompose/setDisplayName'
import getDisplayName from 'recompose/getDisplayName'
import defaultProps from 'recompose/defaultProps'
import compose from 'recompose/compose'
import setPropTypes from 'recompose/setPropTypes'
const FormGroup = ({name, label, error, inputType}) => {
const el = React.createElement(inputType, {
@JSila
JSila / output.bash
Created September 20, 2016 21:55
error using html-webpack-plugin with extract-text-webpack-plugin
➜ when-i-tweet git:(master) npm start
> when-person-tweets@1.0.0 start /home/jernej/Code/when-i-tweet
> nodemon --ignore ./src
[nodemon] 1.10.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node index.js`
Running on http://localhost:3000
@JSila
JSila / karma.config.js
Created September 8, 2016 20:24
karma test runner example (with webpack)
var webpackConfig = require('./webpack.config')
webpackConfig.entry = undefined
module.exports = function (config) {
config.set({
browsers: ['Chrome'],
files: [
'tests.webpack.js' // karma only needs to know where test files are. if you include source files, you are gonna have a bad time.
],
frameworks: ['mocha'],
@JSila
JSila / index.html
Created September 8, 2016 20:18
browser test runner example (mocha, chai, sinon withjquery)
<!DOCTYPE html>
<html>
<head>
<title>Mocha Tests</title>
<link rel="stylesheet" href="/node_modules/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script src="https://code.jquery.com/jquery.min.js"></script>
@JSila
JSila / embed-codes.html
Created June 13, 2016 21:05
Embed codes of some popular social networks
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Embedding</title>
</head>
<body>
<!-- facebook -->
<iframe src="https://www.facebook.com/plugins/post.php?href=https%3A%2F%2Fwww.facebook.com%2Fpolygon%2Fposts%2F1207194309293195&width=500" width="500" height="482" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
@JSila
JSila / cool-js-libs.md
Last active April 7, 2016 13:35
JavaScript libraries that I discovered and deserves a special mention.
  • FlightJS: A component-based, event-driven JavaScript framework built on top of jQuery. From Twitter.
  • React: A declarative, efficient, and flexible JavaScript library for building user interfaces. Developed and used by Facebook and Instagram.
  • Redux: Predictable state container for JavaScript application.
  • stampit: Create objects from reusable, composable behaviors. Stampit uses three different kinds of prototypal OO to let you inherit behavior in a way that is much more powerful and flexible than classical OO.
  • unexpected-react: Extension for unexpected assertion library to make testing React components easier.
@JSila
JSila / eslint.json
Created March 17, 2016 23:58
eslint.js for React and ES6
{
"rules":{
"indent": 2,
"quotes": [2, "single"],
"linebreak-style": [2, "unix"],
"react/prop-types":1,
"react/no-multi-comp":1,
"no-unused-vars":2,
"no-undef":2
},
@JSila
JSila / clean-public.js
Last active April 14, 2016 21:44
gulpfile.js for developing applications in React with ES6
module.exports = (gulp, del, paths) => {
gulp.task('clean-public', () => {
return del([ paths.jsPublicFiles, paths.jsSourceMaps ]);
});
};