Skip to content

Instantly share code, notes, and snippets.

View KamuelaFranco's full-sized avatar

Kamuela Franco KamuelaFranco

View GitHub Profile
/** Bitcoin Smart-Contract with Resilience protocol
* pre-blockchain version for enthusiasts
*/
var express = require('express');
var app = express();
var bodyParser = require('body-parser')
@blaise-io
blaise-io / prepend-use-strict.js
Last active October 18, 2020 13:15
Prepend all JavaScript files with "use strict"; that don't have it yet
// To run:
// npm install globby
// node prepend-use-strict.js
var globby = require('globby');
var fs = require('fs');
globby('**/*.js', function(err, files) {
for (var i = 0, m = files.length; i < m; i++) {
var fileContent = fs.readFileSync(files[i]).toString();
@gaearon
gaearon / slim-redux.js
Last active May 5, 2024 15:14
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@gaearon
gaearon / reducers.js
Last active December 11, 2020 14:56
How I'd do code splitting in Redux (pseudo code, not tested!)
import { combineReducers } from 'redux';
import users from './reducers/users';
import posts from './reducers/posts';
export default function createReducer(asyncReducers) {
return combineReducers({
users,
posts,
...asyncReducers
});
@nkbt
nkbt / Filters.jsx
Last active April 8, 2018 02:31
ImmutableJS + Redux
import React from 'react';
import {List} from 'immutable';
import {shouldComponentUpdate} from 'react-addons-pure-render-mixin';
import {connect} from 'react-redux';
import getFiltersData from './filtersData';
import {filtersDataReady} from './reducer';
const Filters = React.createClass({
propTypes: {
getFiltersData: React.PropTypes.func.isRequired,