Skip to content

Instantly share code, notes, and snippets.

Export:

import {createStore} from 'redux';

var store = createStore(dispatcherMethod, defaultState);
export {store};

Import:

import {store} from "./App";
@haintwork
haintwork / csharp-moq-notes.md
Created August 3, 2017 10:12
C#: Moq notes

Mock object

var mockWebResponse = new Mock<WebResponse>();

Get mock object

WebResponse webResponse = mockWebResponse.Object;

Mock return object when method call

  • No param in method call
@haintwork
haintwork / csharp-moq-assign-value-property.md
Created August 3, 2017 09:44
How to assign values to properties in moq?

1. Using setAllProperties()

moqUser.SetupAllProperties();
moqUser.Object.Name = username;

2. Using Setup Get/Set

input.SetupGet(x => x.ColumnNames).Returns(temp);

Reference:

@haintwork
haintwork / csharp-convert-string-to-stream.md
Created August 3, 2017 09:19
Convert String to System.IO.Stream
// convert string to stream
byte[] byteArray = Encoding.UTF8.GetBytes(contents);
//byte[] byteArray = Encoding.ASCII.GetBytes(contents);
MemoryStream stream = new MemoryStream(byteArray);

// convert stream to string
StreamReader reader = new StreamReader(stream);
string text = reader.ReadToEnd();
@haintwork
haintwork / csharp-moq-verify-method-call.md
Created August 3, 2017 09:02
Verify a method call using Moq
class MyClassTest
{
    [TestMethod]
    public void MyMethodTest()
    {
        string action = "test";
        Mock<SomeClass> mockSomeClass = new Mock<SomeClass>();

 mockSomeClass.Setup(mock =&gt; mock.DoSomething());
@haintwork
haintwork / junit-exception-message.md
Last active August 3, 2017 03:25
Expected Exception Message with JUnit
@Rule
public ExpectedException expectedEx = ExpectedException.none();

@Test
public void shouldThrowRuntimeExceptionWhenEmployeeIDisNull() throws Exception {
    expectedEx.expect(RuntimeException.class);
    expectedEx.expectMessage("Employee ID is null");
    // do something that should throw the exception...
}
@haintwork
haintwork / java-date-localdate-conversion.md
Created August 1, 2017 02:47
Java Date/LocalDate conversion

1. Date -> java.time

Idea:

Date -> Instant + System default time zone = LocalDate
Date -> Instant + System default time zone = LocalDateTime
Date -> Instant + System default time zone = ZonedDateTime
public class DateToJavaTime {
@haintwork
haintwork / 42 Web Developer Tools to Boost Productivity.md
Created July 30, 2017 02:16
42 Web Developer Tools to Boost Productivity

The web is constantly changing and web developers face quite frankly, an everlasting battle to remain up to date on which of the web developer tools are ideal for top web development. Whilst this may be exciting and challenging, to many developers these new tools require learning new programming languages and techniques to successfully and professionally implement.

For website developers the challenge to meet the needs of the business includes testing for technical issues, adapting existing frameworks and ensuring the process is optimised for back-end infrastructure.

The team at Opus Online has compiled a list of several web developer tools they can recommend. These tools enable you to be more productive and provide the best web development for your clients or your own company. Due to the unlimited range of tools, the team separated each into categories to allow better comparison and easier understanding of which ones are the most useful.

Web Developer Tools

@haintwork
haintwork / Productive Tips from 100 books.md
Created July 30, 2017 01:42
Productive Tips from 100 books

1. Don’t wait for others to set your deadlines, set them for yourself

2. Keep track of your time like you do your bank account

3. Don’t focus on your weaknesses, work on your strengths instead

4. Rank tasks by importance, not the order you received them

5. Don't spend major time on minor things

6. Don’t bite off more than you can chew

7. Smart people know when to delegate

8. Use your brain for thinking, not remembering

9. Review your productivity at the end of the day

  • What have I done well?