Skip to content

Instantly share code, notes, and snippets.

View kaievns's full-sized avatar

Kai Evans kaievns

  • Sydney, Australia
View GitHub Profile
@kaievns
kaievns / gist:acb23149b66418ba340c
Created July 29, 2014 00:44
How to populate PostgreSQL with dummy data
CREATE TABLE t_random AS SELECT s, md5(random()::text) FROM generate_Series(1,5) s;
INSERT INTO t_random VALUES (generate_series(1,1000000000), md5(random()::text));
SELECT pg_size_pretty(pg_relation_size('t_random'));
@kaievns
kaievns / gist:996893
Created May 28, 2011 14:20
Cubic Bezier function emulator
/**
* Cubic Bezier CSS3 transitions emulator
*
* See this post for more details
* http://st-on-it.blogspot.com/2011/05/calculating-cubic-bezier-function.html
*
* Copyright (C) 2011 Nikolay Nemshilov
*/
function Bezier(p1,p2,p3,p4) {
// defining the bezier functions in the polynomial form
import { Form } from 'forms-kit'
import { ValidationError } from 'a-plus-forms'
const OurForm = ({ onSubmit, defaultValues }) => {
<Form onSubmit, dfeaul>
...
}
@kaievns
kaievns / gist:908025
Created April 7, 2011 15:38
Jasmine Hack
// hacking jasmine over
var jasmine = require('jasmine-node');
var original_it = it;
var original_expect = expect;
var original_describe = describe;
global.it = function(desc, callback) {
if (typeof(desc) !== 'string') {
for (var key in desc) {
/- kicks in the process
+--------+
HTTP -> | kicker |
+--------+
|
V /- tracks generations
+--------+
*--->| looper |
| +--------+
| |
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;
}
@kaievns
kaievns / unused.js
Created January 23, 2018 01:56
Finds unused react components in a project
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);
@kaievns
kaievns / notes.md
Last active January 26, 2018 08:19
Apollo GraphQL experience notes
  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: apollographql/react-apollo#1286 apollographql/react-apollo#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

@kaievns
kaievns / index.jsx
Last active December 7, 2017 05:40
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>
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';