Skip to content

Instantly share code, notes, and snippets.

View lewiscowper's full-sized avatar
💻
Doing my best

Lewis Cowper lewiscowper

💻
Doing my best
View GitHub Profile
// HELPERS
// Sometimes it's easier to work with edges instead of point + size
// {x, y, height, width} => {top, bottom, left right}
function frameToRect(frame) {
return {
left: frame.x,
right: frame.x + frame.width,
top: frame.y,
bottom: frame.y + frame.height
@lewiscowper
lewiscowper / gist:bbb8e51fda00ff080058
Created January 21, 2015 14:13
Dreamcode and it's use in Hoodie
Are there any ways of getting to a Dreamcode API with little or no knowledge of how APIs work? I'm interested in API design, and I was wondering how you make the collabarative decisions on how the Hoodie API works, hopefully I can make a blog post about the ideas behind it.
I see the DreamCode/API-first design process as a really nice way of making sure your backend devs and front end devs are working in sync, toward the same goal, because the example request and response are there from an early point, allowing both to work and (hopefully) allowing the two to glue together quite well.
Basically my overall question is, how do I determine if an API is good/better/best from a design point of view, without implementing it.
2015-02-05 13:16:00.715 firefox[82846:4790852] NSWindow warning: adding an unknown subview: <NSView: 0x10e681b00>
2015-02-05 13:16:00.719 firefox[82846:4790852] Call stack:
(
0 AppKit 0x00007fff8a9178fc -[NSThemeFrame addSubview:] + 107
1 AppKit 0x00007fff8a30368f -[NSView addSubview:positioned:relativeTo:] + 208
2 XUL 0x00000001024ed0ba -[BaseWindow setContentView:] + 106
3 AppKit 0x00007fff8a26f7f6 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 45
4 XUL 0x00000001024ebeeb -[BaseWindow initWithContentRect:styleMask:backing:defer:] + 107
)
Process 82846 stopped

#How I went from forklift driver to developer in 9 months.

##Description

Moving up the ladder from forklift driver and general labourer, to front end developer, with a stint in manual testing, was a big challenge. However it’s exactly what I did, and I couldn’t have done it without following a few core principles.

Getting up the nerve to go to local usergroups, and conferences, and discovering a new found love of public speaking, was a huge leap from labouring. Similarly, I discovered contributing to open source wasn’t that big a deal, and some things certain projects did made it really easy! Also, learning about things like source control was super integral to being where I am today.

The most important part was trying to learn something from everyone I met. It didn’t matter where I met you, if I saw an opportunity to learn more, or try a new thing, I was there.

@lewiscowper
lewiscowper / gist:c68b9830d2ad9c8c5c0c
Last active August 29, 2015 14:17
I know this is wrong, but is it closer?
var DisruptionBox = React.createClass({
loadDisruptionsFromServer: function() {
$.ajax({
url: this.props.url,
dataType: 'xml',
method: 'GET',
success: function(xmlResponse) {
console.log(xmlResponse);
var data = $('item', xmlResponse).map(function () {
{
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfLineStatus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org
/2001/XMLSchema" xmlns="http://webservices.lul.co.uk/">
<LineStatus ID="0" StatusDetails="No service between Paddington and Queen's Park while we fix a faulty
train at Warwick Avenue. SEVERE DELAYS on the rest of the line. London Underground tickets will be accepted
on London Overground and local buses.">
<BranchDisruptions>
<BranchDisruption>
<StationTo ID="183" Name="Queen's Park" />
<StationFrom ID="173" Name="Paddington" />
it('checking scope values', function () {
expect(_scope.foo).toBe(false);
expect(_scope.bar).toBe(true);
expect(_scope.qux()).toBe(false);
expect(_scope.baz.quux[0].fred).toBe(true);
});
describe('on load', function () {
describe('the foo variable', function () {
it('should be defined', function () {
expect(_scope.foo).toBeDefined();
});
it('should be set correctly', function () {
expect(_scope.foo).toBe(false);
});
});
it('should call service.foo', function () {
service.foo();
expect(service.foo).toHaveBeenCalled();
service.deferredFoo.resolve();
_scope.$digest();
});
describe('when the bar function is called', function () {
beforeEach(function () {
_scope.bar();
});
it('should have called the foo function from the service', function () {
expect(service.foo).toHaveBeenCalled();
});
describe('when the foo promise resolves', function () {