Skip to content

Instantly share code, notes, and snippets.

@melv-n
melv-n / CustomComponent-test.js
Last active November 9, 2021 09:32
Testing React-Intl components with Enzyme's mount() and shallow() methods. This is a helper function which wraps the `intl` context around your component tests in an easy and efficient way.
import { mountWithIntl } from 'helpers/intl-enzyme-test-helper.js';
const wrapper = mountWithIntl(
<CustomComponent />
);
expect(wrapper.state('foo')).to.equal('bar'); // OK
expect(wrapper.text()).to.equal('Hello World!'); // OK
@mikberg
mikberg / mockRelay.js
Created January 19, 2016 22:28
Relay mock module
import Relay from 'real-react-relay';
export class Mutation extends Relay.Mutation {
_resolveProps(props) {
this.props = props;
}
}
export class MockStore {
reset() {
@monfera
monfera / .block
Last active April 29, 2017 14:18
Fluid configuration of d3.js bandlines with FRP
license: gpl-3.0
@1wheel
1wheel / circle-lattice.js
Last active June 6, 2021 05:59
Circle Aliasing
var width = 500,
height = 500,
r = 450
var svg = d3.select('html')
.append('svg')
.attr({width: width, height: height})
.append('g')
.translate([10, height - 10])
@staltz
staltz / slim-cycle-core.js
Created September 22, 2015 12:35
Cycle.js without sanity checks and comments in a single file. Don't use this, use normal Cycle.js. :-)
let Rx = require(`rx`)
function makeRequestProxies(drivers) {
let requestProxies = {}
for (let name in drivers) {
if (drivers.hasOwnProperty(name)) {
requestProxies[name] = new Rx.ReplaySubject(1)
}
}
return requestProxies
@gaearon
gaearon / slim-redux.js
Last active September 7, 2025 15:41
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 / ReduxMicroBoilerplate.js
Last active March 26, 2020 00:35
Super minimal React + Redux app
import React, { Component } from 'react';
import { createStore, combineReducers, applyMiddleware, bindActionCreators } from 'redux';
import { provide, connect } from 'react-redux';
import thunk from 'redux-thunk';
const AVAILABLE_SUBREDDITS = ['apple', 'pics'];
// ------------
// reducers
// ------------
#!/bin/bash
# modify the following to suit your environment
export DIR_EXPORT="__USER__@__HOSTNAME_EXPORT__:"
export DIR_BACKUP="/srv/backup/mysql"
export DB_USER="__USER__"
export DB_PASSWORD="__PASSWORD__"
export DB_DATE=$(date +%d-%m-%Y)
# Title and version
@terrancesnyder
terrancesnyder / README.md
Last active May 26, 2020 08:07
Sankey Barchart with D3

Sankey Barchart

Info

Provides a visualization similar to google analytics shopper behavior analytics.

Requires

  • d3js
  • underscorejs
@hariadi
hariadi / mysql_backup.sh
Created December 19, 2014 02:46
MySQL Backup
#!/bin/sh
# List of databases to be backed up separated by space
dblist="database1 database2 database3"
# Directory for backups
backupdir=/DIR/mysql_dumps
# Number of versions to keep
numversions=4