Skip to content

Instantly share code, notes, and snippets.

View zverbatim's full-sized avatar
🚲
C'est la vie

Ivan Munteanu zverbatim

🚲
C'est la vie
View GitHub Profile
@zverbatim
zverbatim / Difference between @Mock, @MockBean and Mockito.mock().txt
Created March 5, 2018 22:34
Difference between @mock, @MockBean and Mockito.mock()
Source : https://stackoverflow.com/questions/44200720/difference-between-mock-mockbean-and-mockito-mock
Plain Mockito library
import org.mockito.Mock;
...
@Mock
MyService myservice;
and
@zverbatim
zverbatim / explanation.txt
Created March 5, 2018 22:26
@mock vs @InjectMock (mockito)
// Source: https://stackoverflow.com/questions/16467685/difference-between-mock-and-injectmocks
@Mock creates a mock. @InjectMocks creates an instance of the class and injects the mocks that are created with the @Mock (or @Spy) annotations into this instance. Note that you must use @RunWith(MockitoJUnitRunner.class) or Mockito.initMocks(this) to initialise these mocks and inject them.
@RunWith(MockitoJUnitRunner.class)
public class SomeManagerTest {
@InjectMocks
private SomeManager someManager;
@zverbatim
zverbatim / h2tests.txt
Created March 5, 2018 21:36
h2 config for tests
//pom.xml
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.194</version>
</dependency>
//src/test/resoures/application.properties
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
import React, {Component} from 'react';
import 'bootstrap/dist/css/bootstrap.css';
import 'font-awesome/css/font-awesome.css'
import './App.css';
import $ from "jquery";
window.jQuery = window.$ = $;
window.Popper = require('popper.js').default
require("bootstrap");
# filter an array
# version 1
areas = ["hallway", 11.25, "kitchen", 18.0, "living room", 20.0, "bedroom", 10.75, "bathroom", 9.50]
valid = lambda x: type(x) == float
sum = sum( filter (valid, areas) )
# version 2
out = [a for a in areas if type(a) != str]
@zverbatim
zverbatim / python stats util
Last active July 28, 2017 19:34
collection of function useful for doing statistical analysis
# Pearson correlation coeficient
# x, y are two arrays
np.corrcoef(x,y)[0,1]
def ecdf(list):
"""
Empirical cumulative distribution function
Afterwards can be called
plt.plot(x, y, marker='.')
"""
@zverbatim
zverbatim / react-timer-mixin component
Last active July 5, 2017 17:34
Get the status of of smtg based of and id by running a function passed as props
# Project: https://github.com/reactjs/react-timer-mixin
class Status extends Component {
constructor(props) {
super(props);
this.state = {
status: '...'
};
}
Kibana search criteria:
------------------------------------------------------
type: http
http transition only
http.response.headers["content-type"]: *json
regex operator
responsetime: [10 TO *]
range with 10 including
@zverbatim
zverbatim / gradle-groovy-init-script
Last active August 19, 2016 17:21
Create folders need for a new groovy project
#!/usr/bin/env bash
# Script: Create folders need for a new groovy project
# Takes: One argument for package name. Example : /com/acme/marketing
# Created: August 19, 2016
# Description: Based of the documentation from https://docs.gradle.org/current/userguide/groovy_plugin.html
if [ $# -ne 1 ]
then
echo "Usage: $0 <package_name>"
@zverbatim
zverbatim / crontab-notes
Last active August 19, 2016 17:22
Crontab notes
# Crontab table entries
________________________ Minute of the Hour (0–59)
| ______________________ Hour of the Day (0–23)
| | ____________________ Day of the Month (1–31)
| | | __________________ Month of the Year (1–12)
| | | | ________________ Day of the Week (0 – 6 for Sunday through Saturday)
| | | | | ______________ Command to Execute (Full path is required)
| | | | | |
| | | | | |