Skip to content

Instantly share code, notes, and snippets.

View danielrohers's full-sized avatar
🏠
Working from home

Daniel Röhers Moura danielrohers

🏠
Working from home
View GitHub Profile
@danielrohers
danielrohers / jest-mock.js
Last active February 1, 2021 17:50
window.location.reload jest mock
// tests/__mocks__/browserMocks.js
Object.defineProperty(window, 'location', {
value: {
...window.location,
reload: jest.fn()
}
});
// Example of use:
expect(window.location.reload).toHaveBeenCalled();
function sum (value) {
sum1(value, function (value) {
sum2(value, function (value) {
sum3(value, function (value) {
sum4(value, function (value) {
sum5(value, function (value) {
sum6(value, function (value) {
sum7(value, function (value) {
sum8(value, function (value) {
sum9(value, function (value) {
var quickSort = function(arr, key, reverse) {
reverse = reverse || false
if (arr.length <= 1) {
return arr;
}
var less = Array(),
greater = Array();
@danielrohers
danielrohers / git-commands.md
Last active August 29, 2015 14:11
git commands

Git commands resume

Creating repo

mkdir repo
cd repo
git init
touch README
git add README
git commit -m "first commit"
@danielrohers
danielrohers / LogType.groovy
Last active August 29, 2015 14:03
Example of enumeration, if you want to save in database to be some value of your enum. Just override getId(), returning what you want.
/**
* @author Daniel Moura
*
*/
public enum LogType {
CHANGE('C', 'Change'),
INCLUSION('I', 'Inclusion'),
EXCLUSION('E', 'Exclusion')
@danielrohers
danielrohers / parent-node.js
Last active August 29, 2015 14:01
Example to fetch the parent node
;(function (w, d, undefined) {
'use strict';
var PN = (function () {
var exports = {};
var _forEach = function (array, callback) {
for (var i = 0; i < array.length; i++) {
function _forEach (array, callback) {
if (array) {
var length = array.length;
for (var i = 0; i < length; i++) {
callback(array[i]);
}
}
};
var links = document.querySelectorAll('a');
@danielrohers
danielrohers / app.js
Last active February 13, 2017 13:57
My JavaScript Module Pattern
;(function (w, d, undefined) {
'use strict';
var app = (function () {
var exports = {};
var _privateMethod = function () {
return 'private method';