Skip to content

Instantly share code, notes, and snippets.

View NiGhTTraX's full-sized avatar
🌶️

Andrei Picus NiGhTTraX

🌶️
View GitHub Profile
@NiGhTTraX
NiGhTTraX / squid3.conf
Created November 5, 2015 20:15
squid anonymous proxy
# basic auth settings
auth_param basic program /usr/lib/squid3/ncsa_auth /etc/squid3/users.txt
auth_param basic children 2
auth_param basic realm nighttrax
auth_param basic casesensitive on
acl Users proxy_auth REQUIRED
http_access allow Users
# acl
acl manager proto cache_object
@NiGhTTraX
NiGhTTraX / git-imgdiff.sh
Created January 30, 2017 17:26
Diffing images with git
#!/bin/bash
DIFF_PATH=/tmp/diff.png
MONTAGE_PATH=/tmp/montage.png
rm -rf $DIFF_PATH $MONTAGE_PATH
# Try to diff the images and create a montage with the original on
# the left, diff in the middle and the new one on the right.
DIFF=$(compare $2 $1 png:- > $DIFF_PATH)
it('should display the name of the todo', function() {
render(<Todo name="buy milk" />);
expect($('.todo').text()).to.equal('buy milk');
});
function Todo(props) {
return <div>
<span>{props.name}</span>
</div>;
}
it('should delete the todo when clicking on the delete button', function() {
const deleteTodo = sinon.spy();
render(<Todo name=”buy milk” onDelete={deleteTodo} />);
Simulate.click($(‘.delete’)[0]);
expect(deleteTodo).to.have.been.called;
});
function Todo(props) {
return <div>
<span>{props.name}</span>
<button onClick={props.onDelete}>Delete</button>
</div>;
}
function createSpy() {
const _renderSpy = sinon.spy();
return class Spy extends Component {
static get lastProps() {
return _renderSpy.args[_renderSpy.callCount - 1][0];
}
render() {
_renderSpy(this.props);
it('should delete the todo when clicking the delete button', function() {
const Button = createSpy();
const onDeleteSpy = spy();
jest.mock('./button.jsx', () => Button);
const Todo = require('./todo.jsx');
render(<Todo name="buy milk" onDelete={onDeleteSpy} />);
Button.lastProps.onSubmit();
import Button from './button.jsx';
function Todo(props) {
return <div>
<span>{props.name}</span>
<Button onSubmit={props.onDelete}>Delete</Button>
</div>;
}
it('should delete the todo when using the delete button', function() {
const Delete = createSpy();
const onDeleteSpy = spy();
render(<Todo Delete={Delete} name="buy milk" onDelete={onDeleteSpy} />);
Delete.lastProps.onSubmit();
expect(onDeleteSpy).to.have.been.called;
});