Skip to content

Instantly share code, notes, and snippets.

Nikolay Nemshilov MadRabbit

Block or report user

Report or block MadRabbit

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:828371cb298feb7750282994b3d0085b
import { Form } from 'forms-kit'
import { ValidationError } from 'a-plus-forms'
const OurForm = ({ onSubmit, defaultValues }) => {
<Form onSubmit, dfeaul>
...
}
View gist:30e4a121d6554e3d12c3293ca298700d
/- kicks in the process
+--------+
HTTP -> | kicker |
+--------+
|
V /- tracks generations
+--------+
*--->| looper |
| +--------+
| |
View gist:3b6fabeab3378a38f3b2965090b96679
let solution = 'a'...'z'; // <- the end solution;
let currentSolution = 'z'...'a';
while (grade(currrentSolution) < '100%') {
let generation = randomlyMutate(currentSolution, { times: 10 });
let bestInGeneration = pickBestSolutionIn(generation);
currentSolution = bestInGeneration;
}
@MadRabbit
MadRabbit / notes.md
Last active Jan 26, 2018
Apollo GraphQL experience notes
View notes.md
  1. Overall sense of instability. Considering that there are basically two grown up implementations for react out there Relay and Apollo. Seing issues like those in apollo make me feel uneasy. References: https://github.com/apollographql/react-apollo/issues/1286 https://github.com/apollographql/react-apollo/issues/556 https://github.com/apollographql/apollo-test-utils/issues/39

there are multiple variations of each throught the apollo related packages. the most disturbing is lack of response or sense of community ownership. it gives an impression of one guy manning half of the leverages

@MadRabbit
MadRabbit / unused.js
Created Jan 23, 2018
Finds unused react components in a project
View unused.js
const { execSync } = require('child_process');
const directory = 'src';
const findOut = execSync('find -L src').toString();
const filenames = findOut.trim().split('\n')
.filter(name => name.endsWith('.js'))
.map(name => name.replace('.js', '').replace('src/', '').replace(/\/index$/, ''));
console.log('Found', filenames.length, 'files in', directory);
View test.jsx
import { mount } from 'enzyme';
import { TextInput, PasswordInput } from 'a-plus-forms';
import SignInForm from 'src/features/auth/signin_form';
describe('<SignInForm /', () => {
it('works beautifully', () => {
const onSubmit = sinon.spy();
const wrapper = mount(<SignInForm onSubmit={onSubmit} />);
wrapper.find(TextInput).instance().value = 'nikolay';
View custom.jsx
import { field, TextInput } from 'a-plus-forms';
@field()
class PhoneInput extends React.Component {
onChange = (text) => {
const phoneNumber = format(text); // to phone number
this.props.onChange(phoneNumber);
}
render() {
View index.jsx
import { Form, TextInput, PasswordInput } from 'a-plus-forms';
const signIn = ({ username, password }) =>
axios.post('/users', { username, password });
<Form onSubmit={signIn}>
<TextInput name="username" label="Username" />
<PasswordInput name="password" label="Password" />
<button type="submit">Sign In</button>
</Form>
View index.html
<form action="/signin">
<input type="text" name="username" />
<input type="password" name="password" />
<button type="submit">Sign In</button>
</form>
View blah.js
const connect = (mapStateToProps, mapDispatchToProps) => magic ...
const MegaLopolos = (props) =>
<div>
Stuff....
</div>
export defaults connect(mapStateToProps, mapDispatchToProps)(cssModules(styles)(MegaLopolos));
You can’t perform that action at this time.