Skip to content

Instantly share code, notes, and snippets.

Steven Noble snoblenet

Block or report user

Report or block snoblenet

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
@snoblenet
snoblenet / react_props_contract_respected_and_enforced.js
Last active Oct 30, 2018
The contracts between the components and the container are enforced by the specs
View react_props_contract_respected_and_enforced.js
// containers/form_container.js
import Form from '../components/form_component';
export const mapStateToProps = state => ({ username: state.username });
export default connect(mapStateToProps)(Form);
// components/form_component.js
import PropTypes from 'prop-types';
import React from 'react';
const Form = class extends React.Component {
@snoblenet
snoblenet / utils_contract_respected_and_enforced.js
Last active Sep 19, 2018
The contract between getPrefix() and prefixWord() is enforced by the specs
View utils_contract_respected_and_enforced.js
// utils/get_prefix.js
export const getPrefix = (lang) => {
if (lang === 'fr') return 'méga';
return 'mega';
};
// utils/prefix_word.js
export const prefixWord = (prefixGetter, wordToPrefix) => prefixGetter() + wordToPrefix;
// spec/fixtures/prefix_fixtures.js
@snoblenet
snoblenet / react_props_contract_violated_with_proptype_inconsistency.js
Last active Sep 19, 2018
The contracts between the components and the container are violated by the modules, but this is not detected by the specs
View react_props_contract_violated_with_proptype_inconsistency.js
// containers/form_container.js
import Form from '../components/form_component';
// The container passes a 'username' prop (type: string) to Form
export const mapStateToProps = state => ({ username: state.username });
export connect(mapStateToProps)(Form);
// components/form_component.js
import PropTypes from 'prop-types';
import React from 'react';
@snoblenet
snoblenet / react_props_contract_respected_but_not_enforced.js
Last active Sep 19, 2018
The contracts between the components and the container are respected by the modules but not enforced by the specs
View react_props_contract_respected_but_not_enforced.js
// containers/form_container.js
import Form from '../components/form_component';
export const mapStateToProps = state => ({ username: state.username });
export default connect(mapStateToProps)(Form);
// components/form_component.js
import PropTypes from 'prop-types';
import React from 'react';
@snoblenet
snoblenet / utils_contract_violated_with_return_type_inconsistency.js
Last active Sep 19, 2018
The contract between getPrefix() and prefixWord() is violated but this is not detected by the specs
View utils_contract_violated_with_return_type_inconsistency.js
// utils/get_prefix.js
// Changed the return value type from string to object
export const getPrefix = () => ({ en: 'mega', fr: 'méga' });
// utils/prefix_word.js
export const prefixWord = (prefixGetter, wordToPrefix) => prefixGetter() + wordToPrefix;
// spec/utils/get_prefix.js
import getPrefix from '../../utils/get_prefix';
@snoblenet
snoblenet / utils_contract_violated_with_return_value_inconsistency.js
Last active Sep 19, 2018
The contract between getPrefix() and prefixWord() is violated but this is not detected by the specs
View utils_contract_violated_with_return_value_inconsistency.js
// utils/get_prefix.js
// Changed the return value from 'mega' to 'hyper'
export const getPrefix = () => 'hyper';
// utils/prefix_word.js
export const prefixWord = (prefixGetter, wordToPrefix) => prefixGetter() + wordToPrefix;
// spec/utils/get_prefix_spec.js
import getPrefix from '../../utils/get_prefix';
@snoblenet
snoblenet / utils_contract_respected_but_not_enforced.js
Last active Sep 19, 2018
The contract between getPrefix() and prefixWord() is respected by the modules but not enforced by the specs
View utils_contract_respected_but_not_enforced.js
// utils/get_prefix.js
export const getPrefix = () => 'mega';
// utils/prefix_word.js
export const prefixWord = (prefixGetter, wordToPrefix) => prefixGetter() + wordToPrefix;
// spec/utils/get_prefix_spec.js
import getPrefix from '../../utils/get_prefix';
describe('getPrefix()', => {
@snoblenet
snoblenet / conflicted.sh
Created Oct 5, 2017
Instant Git Merge Practice
View conflicted.sh
#!/bin/bash
rm my-code.txt > /dev/null 2>&1 &
rm -rf .git > /dev/null 2>&1 &
touch my-code.txt
git init
git add my-code.txt
View keybase.md

Keybase proof

I hereby claim:

  • I am snoblenet on github.
  • I am snoblenet (https://keybase.io/snoblenet) on keybase.
  • I have a public key ASCMBay3aYDRi7nJy9DUqfqJSWUfgLj4bTBoESEfFojnUgo

To claim this, I am signing this object:

@snoblenet
snoblenet / warn.vim
Last active May 5, 2017
Caps Lock and Insert mode warning for Vim
View warn.vim
" ensure you have xset in your shell
" change 'solarized' to the name of your colorscheme
" presumes that your colorscheme, like solarized, provides both dark and light modes
function! CapsWarn()
let CapsState = system('xset -q | grep -oE "Caps Lock: on"')
if CapsState =~ "on"
highlight Normal ctermbg=Red
redraw
sleep 100m
You can’t perform that action at this time.