Are you over 18 and want to see adult content?
More Annotations
A complete backup of jagersvereniging.nl
Are you over 18 and want to see adult content?
A complete backup of pololacostepaschers.fr
Are you over 18 and want to see adult content?
A complete backup of cityofturlock.org
Are you over 18 and want to see adult content?
A complete backup of tasc4topanga.org
Are you over 18 and want to see adult content?
A complete backup of rallinspired.com
Are you over 18 and want to see adult content?
A complete backup of cigohardenberg.nl
Are you over 18 and want to see adult content?
Favourite Annotations
A complete backup of thelighthouse.co.uk
Are you over 18 and want to see adult content?
A complete backup of newyorklatinculture.com
Are you over 18 and want to see adult content?
A complete backup of cameraworks.co.uk
Are you over 18 and want to see adult content?
A complete backup of students-helping-students.org
Are you over 18 and want to see adult content?
Text
BLOG | CODEUTOPIA
The most annoying piece of code to fix or work with is the code you can’t make any sense out of. Tests are code. As such, it’s important to treat your test code just like any other code, and make sure it’s easy to understand! Let’s take a look at how we can structure our test code to make sure our tests are easy to understandand follow.
BEST PRACTICES FOR BUILDING EMBEDDABLE WIDGETS REACT APPLICATION DATA-FLOW: WHERE AND HOW TO STORE YOUR The basic idea with React is whenever we have nested components – for example, Chat, which has a list of ChatMessage s – the parent component updates each child. This is what we’re doing in our code now. The Chat component has a list of messages. Each message is given to a ChatMessage, in other words, the data flows from parent ( Chat)to
SINON.JS QUICK TIP: HOW TO STUB/MOCK COMPLEX OBJECTS, SUCHSEE MORE ONCODEUTOPIA.NET
MONGOOSE MODELS AND UNIT TESTS: THE DEFINITIVE GUIDESEE MORE ONCODEUTOPIA.NET
COMMON WIDGET DESIGN PATTERNS USING ANGULARJS FOR FAST PROTOTYPING TRACKING THE USER’S BROWSING HISTORY WITH PHP CAN YOU MAKE JAVASCRIPT’S STRING MUTABLE? FIND AN APPLICATION’S ICON WITH WINAPI Sure, there’s a lot of documentation available about the Windows API, but how do I know where to look? I did eventually figure out how to do this, so here’s the solution for anyone else who might be struggling with the same. public Icon GetAppIcon ( IntPtr hwnd) { IntPtr iconHandle = SendMessage ( hwnd,WM_GETICON,ICON_SMALL2, 0); ifBLOG | CODEUTOPIA
The most annoying piece of code to fix or work with is the code you can’t make any sense out of. Tests are code. As such, it’s important to treat your test code just like any other code, and make sure it’s easy to understand! Let’s take a look at how we can structure our test code to make sure our tests are easy to understandand follow.
BEST PRACTICES FOR BUILDING EMBEDDABLE WIDGETS REACT APPLICATION DATA-FLOW: WHERE AND HOW TO STORE YOUR The basic idea with React is whenever we have nested components – for example, Chat, which has a list of ChatMessage s – the parent component updates each child. This is what we’re doing in our code now. The Chat component has a list of messages. Each message is given to a ChatMessage, in other words, the data flows from parent ( Chat)to
SINON.JS QUICK TIP: HOW TO STUB/MOCK COMPLEX OBJECTS, SUCHSEE MORE ONCODEUTOPIA.NET
MONGOOSE MODELS AND UNIT TESTS: THE DEFINITIVE GUIDESEE MORE ONCODEUTOPIA.NET
COMMON WIDGET DESIGN PATTERNS USING ANGULARJS FOR FAST PROTOTYPING TRACKING THE USER’S BROWSING HISTORY WITH PHP CAN YOU MAKE JAVASCRIPT’S STRING MUTABLE? FIND AN APPLICATION’S ICON WITH WINAPI Sure, there’s a lot of documentation available about the Windows API, but how do I know where to look? I did eventually figure out how to do this, so here’s the solution for anyone else who might be struggling with the same. public Icon GetAppIcon ( IntPtr hwnd) { IntPtr iconHandle = SendMessage ( hwnd,WM_GETICON,ICON_SMALL2, 0); if HOW TO UNIT TEST NODEJS HTTP REQUESTS? We will use the builtin assert module as a validator for our tests.sinon is our mocking library.PassThrough is a simple stream, which we can use as a test double for other streams. We will look at the use of http next.. The key things here are beforeEach and afterEach.beforeEach creates a stub to replace http.request, and afterEach restores the original functionality. COMMON PROGRAMMING ERRORS AND HOW TO AVOID THEM I had a better example in mind from some recent code I modified, but I forgot it. However, this kind of made-up looking example still demonstrates the point – as you can see, the condition is much cleaner and it’s quite obvious what the requirements for the if-clause passing are. COMMON WIDGET DESIGN PATTERNS The common parameter is that all widgets would benefit from a common storage interface, which could be easily swapped. In its simplest form: var Storage = { get: function( name) { }, set: function( name, value) { } }; var Storage = { get: function (name) { }, set: function (name, value) { } }; The above is a very simple storage abstraction.You
GETTING STARTED WITH NPM AND BROWSERIFY IN A REACT PROJECT This is the second article in a series where we build a Slack-style chat app with React. So far, in the previous article, we’ve built a simple prototype.We want to start adding features to it – such as actually supporting multiple people chatting – but before we do that, let’s set up some tools. USING ANGULARJS FOR FAST PROTOTYPING Prototyping UIs with Angular is very easy. You don’t even need to know much about how Angular works, as you’ll simply be using the data binding features most of the time. Using Bootstrap along with this is a good pick, as there’s a great library, Angular UI Bootstrap, which wraps many of the useful Bootstrap components intoAngularJS
I SPENT MY VACATION PROGRAMMING I spent my vacation programming. Tags: I was just on vacation for four weeks and I spent the entire time writing code. Well okay, I did also spend some time playing games because Steam summer sale and all that (I finished Bayonetta).. but that’s beside the point :) My job is towrite code.
BEST PRACTICES FOR JAVASCRIPT FUNCTION PARAMETERS Best practice: Provide defaults for optional parameters. We can also use destructuring in the parameter list with objects, together with a default: This gives you the best of both worlds. You can pass in parameters easily as an object, but the properties for the object can be easily seen from the function’s signature. UNIT TESTING 4: MOCK OBJECTS AND TESTING CODE WHICH USES After learning to write tests and some good testing practices, it’s now time to look at mock objects.. When testing a class which needs an instance of another class to work, you do not want to depend on the other class too much. This is where mock objects come in – a mock object is a “clone” of an object, which we can use to simplify our tests, by having the mock object perform SHOULD A FAILED FUNCTION RETURN A VALUE OR THROW AN An uncaught exception can bring down a whole application. An unhandled return code might not really cause anything at all. Sometimes it’s important to consider this factor too. One interesting alternative is using a type to indicate the result. For example, in Haskell, you can have a value of type Maybe. This indicates that it can have a HOW TO PASS VARIABLE VALUES TO JAVASCRIPT 1. Embedding scripts into templates. This is the most straightforward way of passing values: Embed your JavaScript code into the template/view or whatever you call the thing you’re outputting from your server-side script. The example shows a very simple function which just alerts a message with a variable’s value.BLOG | CODEUTOPIA
The most annoying piece of code to fix or work with is the code you can’t make any sense out of. Tests are code. As such, it’s important to treat your test code just like any other code, and make sure it’s easy to understand! Let’s take a look at how we can structure our test code to make sure our tests are easy to understandand follow.
BEST PRACTICES FOR BUILDING EMBEDDABLE WIDGETS REACT APPLICATION DATA-FLOW: WHERE AND HOW TO STORE YOUR The basic idea with React is whenever we have nested components – for example, Chat, which has a list of ChatMessage s – the parent component updates each child. This is what we’re doing in our code now. The Chat component has a list of messages. Each message is given to a ChatMessage, in other words, the data flows from parent ( Chat)to
SINON.JS QUICK TIP: HOW TO STUB/MOCK COMPLEX OBJECTS, SUCHSEE MORE ONCODEUTOPIA.NET
USING SPATIAL DATA IN DOCTRINE 2 USING ANGULARJS FOR FAST PROTOTYPING HOW TO AUTOMATICALLY RUN UNIT TESTS FROM A GIT PUSHSEE MORE ONCODEUTOPIA.NET
TRACKING THE USER’S BROWSING HISTORY WITH PHP FIND AN APPLICATION’S ICON WITH WINAPI Sure, there’s a lot of documentation available about the Windows API, but how do I know where to look? I did eventually figure out how to do this, so here’s the solution for anyone else who might be struggling with the same. public Icon GetAppIcon ( IntPtr hwnd) { IntPtr iconHandle = SendMessage ( hwnd,WM_GETICON,ICON_SMALL2, 0); if HOW TO EASILY REDIRECT PHP OUTPUT TO A FILEBLOG | CODEUTOPIA
The most annoying piece of code to fix or work with is the code you can’t make any sense out of. Tests are code. As such, it’s important to treat your test code just like any other code, and make sure it’s easy to understand! Let’s take a look at how we can structure our test code to make sure our tests are easy to understandand follow.
BEST PRACTICES FOR BUILDING EMBEDDABLE WIDGETS REACT APPLICATION DATA-FLOW: WHERE AND HOW TO STORE YOUR The basic idea with React is whenever we have nested components – for example, Chat, which has a list of ChatMessage s – the parent component updates each child. This is what we’re doing in our code now. The Chat component has a list of messages. Each message is given to a ChatMessage, in other words, the data flows from parent ( Chat)to
SINON.JS QUICK TIP: HOW TO STUB/MOCK COMPLEX OBJECTS, SUCHSEE MORE ONCODEUTOPIA.NET
USING SPATIAL DATA IN DOCTRINE 2 USING ANGULARJS FOR FAST PROTOTYPING HOW TO AUTOMATICALLY RUN UNIT TESTS FROM A GIT PUSHSEE MORE ONCODEUTOPIA.NET
TRACKING THE USER’S BROWSING HISTORY WITH PHP FIND AN APPLICATION’S ICON WITH WINAPI Sure, there’s a lot of documentation available about the Windows API, but how do I know where to look? I did eventually figure out how to do this, so here’s the solution for anyone else who might be struggling with the same. public Icon GetAppIcon ( IntPtr hwnd) { IntPtr iconHandle = SendMessage ( hwnd,WM_GETICON,ICON_SMALL2, 0); if HOW TO EASILY REDIRECT PHP OUTPUT TO A FILE WHAT ARE UNIT TESTING, INTEGRATION TESTING AND FUNCTIONAL Unit testing is the practice of testing small pieces of code, typically individual functions, alone and isolated. If your test uses some external resource, like the network or a database, it’s not a unit test. Unit tests should be fairly simple to write. A unit tests should essentially just give the function that’s tested some inputs,and
MONGOOSE MODELS AND UNIT TESTS: THE DEFINITIVE GUIDE Mongoose models and unit tests: The definitive guide. Mongoose is a great tool, as it helps you build Node apps which use MongoDB more easily. Instead of having to sprinkle the model-related logic all over the place, it’s easy to define the functionality as Mongoose models. Querying MongoDB for data also becomes quick and easy – and if you COMMON WIDGET DESIGN PATTERNS The common parameter is that all widgets would benefit from a common storage interface, which could be easily swapped. In its simplest form: var Storage = { get: function( name) { }, set: function( name, value) { } }; var Storage = { get: function (name) { }, set: function (name, value) { } }; The above is a very simple storage abstraction.You
COMMON PROGRAMMING ERRORS AND HOW TO AVOID THEM I had a better example in mind from some recent code I modified, but I forgot it. However, this kind of made-up looking example still demonstrates the point – as you can see, the condition is much cleaner and it’s quite obvious what the requirements for the if-clause passing are. USING ANGULARJS FOR FAST PROTOTYPING Prototyping UIs with Angular is very easy. You don’t even need to know much about how Angular works, as you’ll simply be using the data binding features most of the time. Using Bootstrap along with this is a good pick, as there’s a great library, Angular UI Bootstrap, which wraps many of the useful Bootstrap components intoAngularJS
GETTING STARTED WITH NPM AND BROWSERIFY IN A REACT PROJECT This is the second article in a series where we build a Slack-style chat app with React. So far, in the previous article, we’ve built a simple prototype.We want to start adding features to it – such as actually supporting multiple people chatting – but before we do that, let’s set up some tools. HOW TO FIX JAVASCRIPT ERRORS MORE EASILY WITH CHROME’S The Call Stack shows us the “parents” of this function call. Our current function is highlighted, Loader.loadImages.All the items below it are functions which were executed before entering this function – in this case, we can see the function where the code came from is an (anonymous function).. We can access all the previous functions by clicking them in the call stack list. SHOULD A FAILED FUNCTION RETURN A VALUE OR THROW AN An uncaught exception can bring down a whole application. An unhandled return code might not really cause anything at all. Sometimes it’s important to consider this factor too. One interesting alternative is using a type to indicate the result. For example, in Haskell, you can have a value of type Maybe. This indicates that it can have a WHY USE USER STORY BASED TESTING TOOLS LIKE CUCUMBER When working with most testing tools, you would write a test, perhaps like this: When working with Cucumber, you would instead write a user story, step definitions and a “world” where the steps run in. Stories, or features, generally follow a format like this: So you write human readable examples like above, and then you write step HOW TO PASS VARIABLE VALUES TO JAVASCRIPT 1. Embedding scripts into templates. This is the most straightforward way of passing values: Embed your JavaScript code into the template/view or whatever you call the thing you’re outputting from your server-side script. The example shows a very simple function which just alerts a message with a variable’s value.BLOG | CODEUTOPIA
The most annoying piece of code to fix or work with is the code you can’t make any sense out of. Tests are code. As such, it’s important to treat your test code just like any other code, and make sure it’s easy to understand! Let’s take a look at how we can structure our test code to make sure our tests are easy to understandand follow.
ABOUT | CODEUTOPIA
Hi, I’m Jani Hartikainen, and I help JavaScript developers to go from good to great (and more). I’ve spent more than half of my life writing web apps and software. I’ve worked with big companies like Nokia, but also with smaller shops and super secret startups. You might’ve seen my articles featured on SitePoint, AirPair or Packt REACT APPLICATION DATA-FLOW: WHERE AND HOW TO STORE YOURREACT DATA GRID EXAMPLESREACT AJAXREACT EXAMPLESREACT GET JSONREACT GET JSON The basic idea with React is whenever we have nested components – for example, Chat, which has a list of ChatMessage s – the parent component updates each child. This is what we’re doing in our code now. The Chat component has a list of messages. Each message is given to a ChatMessage, in other words, the data flows from parent ( Chat)to
WHAT ARE UNIT TESTING, INTEGRATION TESTING AND FUNCTIONALSEE MORE ONCODEUTOPIA.NET
5 STEP METHOD TO MAKE TEST-DRIVEN DEVELOPMENT AND UNITSEE MORE ONCODEUTOPIA.NET
USING SPATIAL DATA IN DOCTRINE 2 SINON.JS QUICK TIP: HOW TO STUB/MOCK COMPLEX OBJECTS, SUCHSEE MORE ON CODEUTOPIA.NETSINON JS FOR TYPESCRIPTSINON JSSINON STUB PROPERTYSINON STUB EXPORTED FUNCTIONSINON STUB RETURNSSINON STUB MULTIPLE CALLS SHOULD A FAILED FUNCTION RETURN A VALUE OR THROW ANSEE MORE ON CODEUTOPIA.NETC# THROW AN EXCEPTIONC# THROW AN EXCEPTIONPYTHON THROWAN EXCEPTION
FIND AN APPLICATION’S ICON WITH WINAPI Sure, there’s a lot of documentation available about the Windows API, but how do I know where to look? I did eventually figure out how to do this, so here’s the solution for anyone else who might be struggling with the same. public Icon GetAppIcon ( IntPtr hwnd) { IntPtr iconHandle = SendMessage ( hwnd,WM_GETICON,ICON_SMALL2, 0); if TRACKING THE USER’S BROWSING HISTORY WITH PHPBLOG | CODEUTOPIA
The most annoying piece of code to fix or work with is the code you can’t make any sense out of. Tests are code. As such, it’s important to treat your test code just like any other code, and make sure it’s easy to understand! Let’s take a look at how we can structure our test code to make sure our tests are easy to understandand follow.
ABOUT | CODEUTOPIA
Hi, I’m Jani Hartikainen, and I help JavaScript developers to go from good to great (and more). I’ve spent more than half of my life writing web apps and software. I’ve worked with big companies like Nokia, but also with smaller shops and super secret startups. You might’ve seen my articles featured on SitePoint, AirPair or Packt REACT APPLICATION DATA-FLOW: WHERE AND HOW TO STORE YOURREACT DATA GRID EXAMPLESREACT AJAXREACT EXAMPLESREACT GET JSONREACT GET JSON The basic idea with React is whenever we have nested components – for example, Chat, which has a list of ChatMessage s – the parent component updates each child. This is what we’re doing in our code now. The Chat component has a list of messages. Each message is given to a ChatMessage, in other words, the data flows from parent ( Chat)to
WHAT ARE UNIT TESTING, INTEGRATION TESTING AND FUNCTIONALSEE MORE ONCODEUTOPIA.NET
5 STEP METHOD TO MAKE TEST-DRIVEN DEVELOPMENT AND UNITSEE MORE ONCODEUTOPIA.NET
USING SPATIAL DATA IN DOCTRINE 2 SINON.JS QUICK TIP: HOW TO STUB/MOCK COMPLEX OBJECTS, SUCHSEE MORE ON CODEUTOPIA.NETSINON JS FOR TYPESCRIPTSINON JSSINON STUB PROPERTYSINON STUB EXPORTED FUNCTIONSINON STUB RETURNSSINON STUB MULTIPLE CALLS SHOULD A FAILED FUNCTION RETURN A VALUE OR THROW ANSEE MORE ON CODEUTOPIA.NETC# THROW AN EXCEPTIONC# THROW AN EXCEPTIONPYTHON THROWAN EXCEPTION
FIND AN APPLICATION’S ICON WITH WINAPI Sure, there’s a lot of documentation available about the Windows API, but how do I know where to look? I did eventually figure out how to do this, so here’s the solution for anyone else who might be struggling with the same. public Icon GetAppIcon ( IntPtr hwnd) { IntPtr iconHandle = SendMessage ( hwnd,WM_GETICON,ICON_SMALL2, 0); if TRACKING THE USER’S BROWSING HISTORY WITH PHPABOUT | CODEUTOPIA
Hi, I’m Jani Hartikainen, and I help JavaScript developers to go from good to great (and more). I’ve spent more than half of my life writing web apps and software. I’ve worked with big companies like Nokia, but also with smaller shops and super secret startups. You might’ve seen my articles featured on SitePoint, AirPair or Packt CONTACT | CODEUTOPIA Questions? Comments? I like to hear from my readers, so drop me a line. Want me to write for you? I do guest posts, ask me and let’s see if we can work something out. 5 STEP METHOD TO MAKE TEST-DRIVEN DEVELOPMENT AND UNIT We’ll go back to step 3, and choose the next tiny step to take. Step 4, add test. Step 5, implement. Repeat. If you keep advancing in small steps like this, TDD suddenly becomes a lot easier. Yes – you might end up with several tests for a fairly small amount of code, but that’s not a bad thing. HOW TO UNIT TEST NODEJS HTTP REQUESTS? We will use the builtin assert module as a validator for our tests.sinon is our mocking library.PassThrough is a simple stream, which we can use as a test double for other streams. We will look at the use of http next.. The key things here are beforeEach and afterEach.beforeEach creates a stub to replace http.request, and afterEach restores the original functionality. HOW TO FIX JAVASCRIPT ERRORS MORE EASILY WITH CHROME’S The Call Stack shows us the “parents” of this function call. Our current function is highlighted, Loader.loadImages.All the items below it are functions which were executed before entering this function – in this case, we can see the function where the code came from is an (anonymous function).. We can access all the previous functions by clicking them in the call stack list. HOW TO AUTOMATICALLY RUN UNIT TESTS FROM A GIT PUSH First you’ll need to set up the tool (s) you wish to run from the script. In my case, I’ve installed PHPUnit on my server and verified it runs from the command-line. For the git pre-receive hook to run before a push, it must be placed into the server which holds the git repository. I probably should point out that this should be a bare CAN YOU MAKE JAVASCRIPT’S STRING MUTABLE? Turns out toString isn’t used when it comes to strings. However, when casting the variable to string with the String constructor, it outputs the value from toString. HOW TO PASS VARIABLE VALUES TO JAVASCRIPT 1. Embedding scripts into templates. This is the most straightforward way of passing values: Embed your JavaScript code into the template/view or whatever you call the thing you’re outputting from your server-side script. The example shows a very simple function which just alerts a message with a variable’s value. WHAT’S THE DIFFERENCE BETWEEN UNIT TESTING, TDD AND BDD BDD – Behavior-Driven Development – is perhaps the biggest source of confusion. When applied to automated testing, BDD is a set of best practices for writing great tests. BDD can, and should be, used together with TDD and unit testing methods. One of the key things BDD addresses is implementation detail in unit tests. HOW TO EASILY REDIRECT PHP OUTPUT TO A FILE Ever wanted to change where your PHP sends the output to a file instead of the browser? I have, and it involved changing every echo and other printing statemenet to fwrite.BLOG | CODEUTOPIA
The most annoying piece of code to fix or work with is the code you can’t make any sense out of. Tests are code. As such, it’s important to treat your test code just like any other code, and make sure it’s easy to understand! Let’s take a look at how we can structure our test code to make sure our tests are easy to understandand follow.
ABOUT | CODEUTOPIA
Hi, I’m Jani Hartikainen, and I help JavaScript developers to go from good to great (and more). I’ve spent more than half of my life writing web apps and software. I’ve worked with big companies like Nokia, but also with smaller shops and super secret startups. You might’ve seen my articles featured on SitePoint, AirPair or Packt REACT APPLICATION DATA-FLOW: WHERE AND HOW TO STORE YOURREACT DATA GRID EXAMPLESREACT AJAXREACT EXAMPLESREACT GET JSONREACT GET JSON The basic idea with React is whenever we have nested components – for example, Chat, which has a list of ChatMessage s – the parent component updates each child. This is what we’re doing in our code now. The Chat component has a list of messages. Each message is given to a ChatMessage, in other words, the data flows from parent ( Chat)to
WHAT ARE UNIT TESTING, INTEGRATION TESTING AND FUNCTIONALSEE MORE ONCODEUTOPIA.NET
5 STEP METHOD TO MAKE TEST-DRIVEN DEVELOPMENT AND UNITSEE MORE ONCODEUTOPIA.NET
USING SPATIAL DATA IN DOCTRINE 2 SINON.JS QUICK TIP: HOW TO STUB/MOCK COMPLEX OBJECTS, SUCHSEE MORE ON CODEUTOPIA.NETSINON JS FOR TYPESCRIPTSINON JSSINON STUB PROPERTYSINON STUB EXPORTED FUNCTIONSINON STUB RETURNSSINON STUB MULTIPLE CALLS SHOULD A FAILED FUNCTION RETURN A VALUE OR THROW ANSEE MORE ON CODEUTOPIA.NETC# THROW AN EXCEPTIONC# THROW AN EXCEPTIONPYTHON THROWAN EXCEPTION
FIND AN APPLICATION’S ICON WITH WINAPI Sure, there’s a lot of documentation available about the Windows API, but how do I know where to look? I did eventually figure out how to do this, so here’s the solution for anyone else who might be struggling with the same. public Icon GetAppIcon ( IntPtr hwnd) { IntPtr iconHandle = SendMessage ( hwnd,WM_GETICON,ICON_SMALL2, 0); if TRACKING THE USER’S BROWSING HISTORY WITH PHPBLOG | CODEUTOPIA
The most annoying piece of code to fix or work with is the code you can’t make any sense out of. Tests are code. As such, it’s important to treat your test code just like any other code, and make sure it’s easy to understand! Let’s take a look at how we can structure our test code to make sure our tests are easy to understandand follow.
ABOUT | CODEUTOPIA
Hi, I’m Jani Hartikainen, and I help JavaScript developers to go from good to great (and more). I’ve spent more than half of my life writing web apps and software. I’ve worked with big companies like Nokia, but also with smaller shops and super secret startups. You might’ve seen my articles featured on SitePoint, AirPair or Packt REACT APPLICATION DATA-FLOW: WHERE AND HOW TO STORE YOURREACT DATA GRID EXAMPLESREACT AJAXREACT EXAMPLESREACT GET JSONREACT GET JSON The basic idea with React is whenever we have nested components – for example, Chat, which has a list of ChatMessage s – the parent component updates each child. This is what we’re doing in our code now. The Chat component has a list of messages. Each message is given to a ChatMessage, in other words, the data flows from parent ( Chat)to
WHAT ARE UNIT TESTING, INTEGRATION TESTING AND FUNCTIONALSEE MORE ONCODEUTOPIA.NET
5 STEP METHOD TO MAKE TEST-DRIVEN DEVELOPMENT AND UNITSEE MORE ONCODEUTOPIA.NET
USING SPATIAL DATA IN DOCTRINE 2 SINON.JS QUICK TIP: HOW TO STUB/MOCK COMPLEX OBJECTS, SUCHSEE MORE ON CODEUTOPIA.NETSINON JS FOR TYPESCRIPTSINON JSSINON STUB PROPERTYSINON STUB EXPORTED FUNCTIONSINON STUB RETURNSSINON STUB MULTIPLE CALLS SHOULD A FAILED FUNCTION RETURN A VALUE OR THROW ANSEE MORE ON CODEUTOPIA.NETC# THROW AN EXCEPTIONC# THROW AN EXCEPTIONPYTHON THROWAN EXCEPTION
FIND AN APPLICATION’S ICON WITH WINAPI Sure, there’s a lot of documentation available about the Windows API, but how do I know where to look? I did eventually figure out how to do this, so here’s the solution for anyone else who might be struggling with the same. public Icon GetAppIcon ( IntPtr hwnd) { IntPtr iconHandle = SendMessage ( hwnd,WM_GETICON,ICON_SMALL2, 0); if TRACKING THE USER’S BROWSING HISTORY WITH PHPABOUT | CODEUTOPIA
Hi, I’m Jani Hartikainen, and I help JavaScript developers to go from good to great (and more). I’ve spent more than half of my life writing web apps and software. I’ve worked with big companies like Nokia, but also with smaller shops and super secret startups. You might’ve seen my articles featured on SitePoint, AirPair or Packt CONTACT | CODEUTOPIA Questions? Comments? I like to hear from my readers, so drop me a line. Want me to write for you? I do guest posts, ask me and let’s see if we can work something out. 5 STEP METHOD TO MAKE TEST-DRIVEN DEVELOPMENT AND UNIT We’ll go back to step 3, and choose the next tiny step to take. Step 4, add test. Step 5, implement. Repeat. If you keep advancing in small steps like this, TDD suddenly becomes a lot easier. Yes – you might end up with several tests for a fairly small amount of code, but that’s not a bad thing. HOW TO UNIT TEST NODEJS HTTP REQUESTS? We will use the builtin assert module as a validator for our tests.sinon is our mocking library.PassThrough is a simple stream, which we can use as a test double for other streams. We will look at the use of http next.. The key things here are beforeEach and afterEach.beforeEach creates a stub to replace http.request, and afterEach restores the original functionality. HOW TO FIX JAVASCRIPT ERRORS MORE EASILY WITH CHROME’S The Call Stack shows us the “parents” of this function call. Our current function is highlighted, Loader.loadImages.All the items below it are functions which were executed before entering this function – in this case, we can see the function where the code came from is an (anonymous function).. We can access all the previous functions by clicking them in the call stack list. HOW TO AUTOMATICALLY RUN UNIT TESTS FROM A GIT PUSH First you’ll need to set up the tool (s) you wish to run from the script. In my case, I’ve installed PHPUnit on my server and verified it runs from the command-line. For the git pre-receive hook to run before a push, it must be placed into the server which holds the git repository. I probably should point out that this should be a bare CAN YOU MAKE JAVASCRIPT’S STRING MUTABLE? Turns out toString isn’t used when it comes to strings. However, when casting the variable to string with the String constructor, it outputs the value from toString. HOW TO PASS VARIABLE VALUES TO JAVASCRIPT 1. Embedding scripts into templates. This is the most straightforward way of passing values: Embed your JavaScript code into the template/view or whatever you call the thing you’re outputting from your server-side script. The example shows a very simple function which just alerts a message with a variable’s value. WHAT’S THE DIFFERENCE BETWEEN UNIT TESTING, TDD AND BDD BDD – Behavior-Driven Development – is perhaps the biggest source of confusion. When applied to automated testing, BDD is a set of best practices for writing great tests. BDD can, and should be, used together with TDD and unit testing methods. One of the key things BDD addresses is implementation detail in unit tests. HOW TO EASILY REDIRECT PHP OUTPUT TO A FILE Ever wanted to change where your PHP sends the output to a file instead of the browser? I have, and it involved changing every echo and other printing statemenet to fwrite.BLOG | CODEUTOPIA
The most annoying piece of code to fix or work with is the code you can’t make any sense out of. Tests are code. As such, it’s important to treat your test code just like any other code, and make sure it’s easy to understand! Let’s take a look at how we can structure our test code to make sure our tests are easy to understandand follow.
ABOUT | CODEUTOPIA
Hi, I’m Jani Hartikainen, and I help JavaScript developers to go from good to great (and more). I’ve spent more than half of my life writing web apps and software. I’ve worked with big companies like Nokia, but also with smaller shops and super secret startups. You might’ve seen my articles featured on SitePoint, AirPair or Packt REACT APPLICATION DATA-FLOW: WHERE AND HOW TO STORE YOURREACT DATA GRID EXAMPLESREACT AJAXREACT EXAMPLESREACT GET JSONREACT GET JSON The basic idea with React is whenever we have nested components – for example, Chat, which has a list of ChatMessage s – the parent component updates each child. This is what we’re doing in our code now. The Chat component has a list of messages. Each message is given to a ChatMessage, in other words, the data flows from parent ( Chat)to
WHAT ARE UNIT TESTING, INTEGRATION TESTING AND FUNCTIONALSEE MORE ONCODEUTOPIA.NET
5 STEP METHOD TO MAKE TEST-DRIVEN DEVELOPMENT AND UNITSEE MORE ONCODEUTOPIA.NET
USING SPATIAL DATA IN DOCTRINE 2 SINON.JS QUICK TIP: HOW TO STUB/MOCK COMPLEX OBJECTS, SUCHSEE MORE ON CODEUTOPIA.NETSINON JS FOR TYPESCRIPTSINON JSSINON STUB PROPERTYSINON STUB EXPORTED FUNCTIONSINON STUB RETURNSSINON STUB MULTIPLE CALLS SHOULD A FAILED FUNCTION RETURN A VALUE OR THROW ANSEE MORE ON CODEUTOPIA.NETC# THROW AN EXCEPTIONC# THROW AN EXCEPTIONPYTHON THROWAN EXCEPTION
FIND AN APPLICATION’S ICON WITH WINAPI Sure, there’s a lot of documentation available about the Windows API, but how do I know where to look? I did eventually figure out how to do this, so here’s the solution for anyone else who might be struggling with the same. public Icon GetAppIcon ( IntPtr hwnd) { IntPtr iconHandle = SendMessage ( hwnd,WM_GETICON,ICON_SMALL2, 0); if TRACKING THE USER’S BROWSING HISTORY WITH PHPBLOG | CODEUTOPIA
The most annoying piece of code to fix or work with is the code you can’t make any sense out of. Tests are code. As such, it’s important to treat your test code just like any other code, and make sure it’s easy to understand! Let’s take a look at how we can structure our test code to make sure our tests are easy to understandand follow.
ABOUT | CODEUTOPIA
Hi, I’m Jani Hartikainen, and I help JavaScript developers to go from good to great (and more). I’ve spent more than half of my life writing web apps and software. I’ve worked with big companies like Nokia, but also with smaller shops and super secret startups. You might’ve seen my articles featured on SitePoint, AirPair or Packt REACT APPLICATION DATA-FLOW: WHERE AND HOW TO STORE YOURREACT DATA GRID EXAMPLESREACT AJAXREACT EXAMPLESREACT GET JSONREACT GET JSON The basic idea with React is whenever we have nested components – for example, Chat, which has a list of ChatMessage s – the parent component updates each child. This is what we’re doing in our code now. The Chat component has a list of messages. Each message is given to a ChatMessage, in other words, the data flows from parent ( Chat)to
WHAT ARE UNIT TESTING, INTEGRATION TESTING AND FUNCTIONALSEE MORE ONCODEUTOPIA.NET
5 STEP METHOD TO MAKE TEST-DRIVEN DEVELOPMENT AND UNITSEE MORE ONCODEUTOPIA.NET
USING SPATIAL DATA IN DOCTRINE 2 SINON.JS QUICK TIP: HOW TO STUB/MOCK COMPLEX OBJECTS, SUCHSEE MORE ON CODEUTOPIA.NETSINON JS FOR TYPESCRIPTSINON JSSINON STUB PROPERTYSINON STUB EXPORTED FUNCTIONSINON STUB RETURNSSINON STUB MULTIPLE CALLS SHOULD A FAILED FUNCTION RETURN A VALUE OR THROW ANSEE MORE ON CODEUTOPIA.NETC# THROW AN EXCEPTIONC# THROW AN EXCEPTIONPYTHON THROWAN EXCEPTION
FIND AN APPLICATION’S ICON WITH WINAPI Sure, there’s a lot of documentation available about the Windows API, but how do I know where to look? I did eventually figure out how to do this, so here’s the solution for anyone else who might be struggling with the same. public Icon GetAppIcon ( IntPtr hwnd) { IntPtr iconHandle = SendMessage ( hwnd,WM_GETICON,ICON_SMALL2, 0); if TRACKING THE USER’S BROWSING HISTORY WITH PHPABOUT | CODEUTOPIA
Hi, I’m Jani Hartikainen, and I help JavaScript developers to go from good to great (and more). I’ve spent more than half of my life writing web apps and software. I’ve worked with big companies like Nokia, but also with smaller shops and super secret startups. You might’ve seen my articles featured on SitePoint, AirPair or Packt CONTACT | CODEUTOPIA Questions? Comments? I like to hear from my readers, so drop me a line. Want me to write for you? I do guest posts, ask me and let’s see if we can work something out. 5 STEP METHOD TO MAKE TEST-DRIVEN DEVELOPMENT AND UNIT We’ll go back to step 3, and choose the next tiny step to take. Step 4, add test. Step 5, implement. Repeat. If you keep advancing in small steps like this, TDD suddenly becomes a lot easier. Yes – you might end up with several tests for a fairly small amount of code, but that’s not a bad thing. HOW TO UNIT TEST NODEJS HTTP REQUESTS? We will use the builtin assert module as a validator for our tests.sinon is our mocking library.PassThrough is a simple stream, which we can use as a test double for other streams. We will look at the use of http next.. The key things here are beforeEach and afterEach.beforeEach creates a stub to replace http.request, and afterEach restores the original functionality. HOW TO FIX JAVASCRIPT ERRORS MORE EASILY WITH CHROME’S The Call Stack shows us the “parents” of this function call. Our current function is highlighted, Loader.loadImages.All the items below it are functions which were executed before entering this function – in this case, we can see the function where the code came from is an (anonymous function).. We can access all the previous functions by clicking them in the call stack list. HOW TO AUTOMATICALLY RUN UNIT TESTS FROM A GIT PUSH First you’ll need to set up the tool (s) you wish to run from the script. In my case, I’ve installed PHPUnit on my server and verified it runs from the command-line. For the git pre-receive hook to run before a push, it must be placed into the server which holds the git repository. I probably should point out that this should be a bare CAN YOU MAKE JAVASCRIPT’S STRING MUTABLE? Turns out toString isn’t used when it comes to strings. However, when casting the variable to string with the String constructor, it outputs the value from toString. HOW TO PASS VARIABLE VALUES TO JAVASCRIPT 1. Embedding scripts into templates. This is the most straightforward way of passing values: Embed your JavaScript code into the template/view or whatever you call the thing you’re outputting from your server-side script. The example shows a very simple function which just alerts a message with a variable’s value. WHAT’S THE DIFFERENCE BETWEEN UNIT TESTING, TDD AND BDD BDD – Behavior-Driven Development – is perhaps the biggest source of confusion. When applied to automated testing, BDD is a set of best practices for writing great tests. BDD can, and should be, used together with TDD and unit testing methods. One of the key things BDD addresses is implementation detail in unit tests. HOW TO EASILY REDIRECT PHP OUTPUT TO A FILE Ever wanted to change where your PHP sends the output to a file instead of the browser? I have, and it involved changing every echo and other printing statemenet to fwrite.CodeUtopia
__ __
__
__
__ Navigation
* Home
* Blog
* About
* Contact
* __ Search
* Home
* Blog
* About
* Contact
* __ Search
I SPENT MY VACATION PROGRAMMINGTags:
I was just on vacation for four weeks and I spent the entire timewriting code.
Read More
QUICK JAVASCRIPT TESTING TIP: HOW TO STRUCTURE YOUR TESTS? Tags: JavaScript TestingUnit Testing
Something that’s not talked very often when it comes to writing unit tests is how should you structure your test code? I’m not talking about “well, just put your code into a file in test/SomeTest.js”, but rather, how should the test code itself within your test case be structured? While it may feel inconsequential – afterall, it’s just a test, and it’s probably just a few lines of code – it’s actually very important to take care when writing your tests. The most annoying piece of code to fix or work with is the code you can’t make any sense out of. Tests are code. As such, it’s important to treat your test code just like any other code, and make sure it’s easy tounderstand!
Let’s take a look at how we can structure our test code to make sure our tests are easy to understand and follow.Read More
JAVASCRIPT TESTING TOOL SHOWDOWN: SINON.JS VS TESTDOUBLE.JS Tags: JavaScript Sinontestdouble
Unit Testing
When unit testing real-world code, there are many situations that make tests hard to write. How do you check if a function was called? How do you test an Ajax call? Or code using setTimeout? That’s when you use test doubles — replacement code that makes hard to test things easyto test.
For many years, Sinon.js has been the de-facto standard in JavaScript tests for creating test doubles. It’s a must-have tool for any JavaScript developer writing tests, as without it, writing tests for real applications would be nigh impossible. Recently, a new library, aptly named testdouble.js, has been making waves. It boasts a similar feature set as Sinon.js, with a few differences here and there. In this article, we’ll look into what both Sinon.js and testdouble.js offer, and compare their respective pros and cons. Will Sinon.js remain the superior choice, or will the challenger take theprize?
Note: If you’re unfamiliar with test doubles, I recommend reading mySinon.js tutorial
first. It will help you better understand the concepts we’ll betalking about here.
Read the rest of this entry here 230 CURATED RESOURCES AND TOOLS FOR BUILDING APPS WITH REACT.JS Tags: JavaScript React This post will curate the best resources, tools, libraries, and articles that will help you learn to build production applications with React.js. This 6000 word post will take you from getting started with React, through UI design, routing, testing, deployment, and continuous integration. There are many sections and you should feel free to jump to the resources you need.Read More
SIMPLIFY YOUR JAVASCRIPT CODE WITH NORMALIZER FUNCTIONSTags: JavaScript
Everyone loves a good if-else tower! What could be simpler than nesting a few conditionals?if(stuff) {
if(more stuff) {
haha();
}
else {
cool();
}
}
if(stuff) { if(more stuff) { haha(); } else { cool(); } } Ok – that isn’t the most amazing thing in the world. In a simple example like this, it isn’t too bad. But we all know real code is never easy to understand, especially after ten different people have changed it over the course of years! But what can you do? Sometimes you have complicated logic, and implementing it without a leaning tower of if-elses can be nighimpossible.
Let me show you something called _normalizer functions_, and how they can help you get rid of some of that complexity.Read More
4 NON-JAVASCRIPT LIBRARY TOPICS TO LEARN TO TAKE YOUR SKILLS TO THENEXT LEVEL
Tags:
Every new year there’s always a bunch of articles about “Learn this in year 200X!” But the problem is.. they’re always about libraries. Learn PrototypeJS. Learn jQuery. Learn Backbone. Learn AngularJS. Now it’s Learn React (or some React-derivative) This stuff comes and goes! Chances are, your job mostly dictates the libraries you’d use. Even if you do get to pick one, you’ll figure it out with your coworkers based on factors other than “some guy on the internet said we shoulduse this”.
I’m not saying those articles are necessarily _bad_. They can be a useful look at what’s popular and what are some new interesting upand comers.
What I am saying is THERE ARE MORE USEFUL THINGS TO LEARN BEYOND THE COOL LIBRARY OF THE YEAR.Read More
BEST PRACTICES FOR JAVASCRIPT FUNCTION PARAMETERS Tags: Best PracticesJavaScript
From time to time, people ask things like “should I use objects to pass function arguments”. I’m sure you recognize the pattern, as it’s common with many libraries: $.post({ a: 'lot', of: 'properties', live: 'in', here: 'yep' }) $.post({ a: 'lot', of: 'properties', live: 'in', here: 'yep' }) But I would say this is not actually such a good idea. Let’s take a look at the best practices for defining function parameter lists in JavaScript.Read More
5 STEP METHOD TO MAKE TEST-DRIVEN DEVELOPMENT AND UNIT TESTING EASY Tags: JavaScript Sinon Test-Driven DevelopmentUnit Testing
What’s the hardest thing in test-driven development or unit testingin general?
Writing tests!
The syntax or the tools aren’t the problem – you can learn those enough to get started in 15 minutes. The problem is how to take some vague idea in your head about what you want to do, and turn it into something that verifies some function works… _before you even wrote the damn thing!_ People tell you to use TDD. But how can you possibly write a test for something that doesn’t exist? I don’t even know what the function is going to do yet – or if I actually want two functions instead of one – and instead you want me to think of a test for it? Are youcrazy?
How do all those people who tell you to use TDD do it? That’s the thing – test-driven development requires thinking of your code in a different way. And nobody ever tells you how to dothat.
Until now.
Read More
WHAT IS PROPERTY BASED TESTING (AND HOW TO DO IT IN JAVASCRIPT)?Tags: JavaScript
QuickCheck
Unit Testing
Ever wonder… what if you didn’t have to write specific tests with hardcoded test data? Or have you ever written a function which can take many different values as input? How can you test something like that easily withdifferent values?
These are the kinds of important questions in life that keep me up at night! (ok maybe not) But did you know both of these questions can be solved with something that’s called “property based testing”? That’s right – PROPERTY BASED TESTING CAN HELP YOU TEST THE UNTESTABLE. And while at it, you can even use them to test your other functions with automatically generated data. All of this means property based tests are great for finding those pesky corner cases that are easy to forget. This means less debugging weird bugs that you find in production – you know, the really hard to reproduce ones, which occur for only one user in some weirdly specific combination of settings. Sounds pretty cool huh? Let’s find out some more!Read More
STAIRCASE CODE – HOW SHORT FUNCTIONS ARE NOT ALWAYS THE BESTSOLUTION
Tags: JavaScript
Have you ever seen code which at first look seems good.. but then as you try to figure it out (maybe to fix a bug), it just feels… wrong? For some reason the code just feels really difficult to follow – forno obvious reason!
In this post, I’m going to explain one such occurrence that I ran into in a production codebase. The code looked ok, yet it was hard tounderstand. Why?
Let’s find out. We’ll also look at some examples of how you can avoid and discover problems like this more easily.Read More
* Page 1 of 37
*
* 1
* 2
* 3
* ...
* 37
* →
RECENT POSTS
* I spent my vacation programming * Quick JavaScript testing tip: How to structure your tests? * JavaScript Testing Tool Showdown: Sinon.js vs testdouble.js * 230 Curated Resources and Tools for Building Apps with React.js * Simplify your JavaScript code with normalizer functionsARCHIVES
Archives Select Month July 2017 May 2017 April 2017 February 2017 January 2017 November 2016 October 2016 September 2016 June 2016 May 2016 April 2016 March 2016 February 2016 January 2016 December 2015 November 2015 September 2015 April 2015 March 2015 February 2015 January 2015 December 2014 November 2014 October 2014 September 2014 August 2014 June 2014 February 2014 December 2013 November 2013 August 2013 July 2013 May 2013 April 2013 March 2013 February 2013 January 2013 November 2012 September 2012 July 2012 May 2012 April 2012 March 2012 February 2012 January 2012 December 2011 October 2011 August 2011 July 2011 June 2011 May 2011 April 2011 March 2011 February 2011 January 2011 December 2010 November 2010 October 2010 September 2010 August 2010 July 2010 June 2010 May 2010 April 2010 March 2010 February 2010 January 2010 December 2009 November 2009 October 2009 September 2009 August 2009 July 2009 June 2009 May 2009 April 2009 March 2009 February 2009 January 2009 December 2008 November 2008 October 2008 September 2008 August 2008 July 2008 June 2008 May 2008 April 2008 March 2008 February 2008 January 2008 December 2007 November 2007 October 2007 September 2007__ __
__
__
Copyright © 2006 - 2016 Jani Hartikainen Type and Press “enter” to SearchDetails
Copyright © 2024 ArchiveBay.com. All rights reserved. Terms of Use | Privacy Policy | DMCA | 2021 | Feedback | Advertising | RSS 2.0