Skip to content

Instantly share code, notes, and snippets.

View go-cristian's full-sized avatar
💭
Never stop learning!

Cristian Gómez go-cristian

💭
Never stop learning!
View GitHub Profile
/**
* Defaul base interactor. This class describes in the practical Clean Architecture how a use case
* it can be perfomed. For practical pruposes a use case has two phases the moment when is executed
* an the moment when needs to return a response, it depends on a default {@link InteractorExecutor}
* wich handles the basic flow. At the end of the process the {@link InteractorResponse} sends the
* response to the class that generates the call. For practical purposes an inner class model is
* needed and must be implemented for every {@link Interactor}.
*/
public abstract class Interactor<E, J> {
/**
* Copyright (C) 2015 Cristian Gomez Open Source Project <p/> Licensed under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
* may obtain a copy of the License at <p/> http://www.apache.org/licenses/LICENSE-2.0 <p/> Unless
* required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/**
* Copyright (C) 2015 Cristian Gomez Open Source Project <p/> Licensed under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
* may obtain a copy of the License at <p/> http://www.apache.org/licenses/LICENSE-2.0 <p/> Unless
* required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/**
* Copyright (C) 2015 Cristian Gomez Open Source Project <p/> Licensed under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
* may obtain a copy of the License at <p/> http://www.apache.org/licenses/LICENSE-2.0 <p/> Unless
* required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/**
* Copyright (C) 2015 Cristian Gomez Open Source Project <p/> Licensed under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
* may obtain a copy of the License at <p/> http://www.apache.org/licenses/LICENSE-2.0 <p/> Unless
* required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/**
* Copyright (C) 2015 Cristian Gomez Open Source Project <p/> Licensed under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
* may obtain a copy of the License at <p/> http://www.apache.org/licenses/LICENSE-2.0 <p/> Unless
* required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
@RunWith(AndroidJUnit4.class) @LargeTest public class RatesActivityShould {
@Rule public ActivityTestRule<RatesActivity> rule =
new ActivityTestRule<RatesActivity>(RatesActivity.class);
@Test public void show_rates_widget_on_load() throws Exception {
RatesActivity activity = rule.getActivity();
activity.setContentView(new AwesomeTextView(activity));
onView(isAssignableFrom(AwesomeTextView.class)).perform(typeText("ModerFoka"))
@go-cristian
go-cristian / MergeSort.swift
Last active August 18, 2016 11:48
Merge sort implementation on Swift
import Foundation
/**
Sorts an array using the merge arrangement, which relays in order the left & right half arrays in a major set of elements. giving a complexity of O(n log n).
- Returns: An ordered array.
*/
func mergeSort(arr:[Int]) -> [Int] {
guard arr.count > 1 else {return arr}
let middle: Int = Int(ceil(Double(arr.count/2)))
let left: [Int] = mergeSort(Array(arr[0..<arr.count/2]))
import Foundation
/**
Counts the number of inversions on the given array.
- Returns: the number of the inversions.
*/
func countInversions(arr:[Int]) -> Int {
guard arr.count > 1 else {return 0}
let middle: Int = Int(ceil(Double(arr.count/2)))
let left: [Int] = Array(arr[0..<arr.count/2])
func partition<T: Comparable>(inout array: [T], first: Int, last: Int) -> Int {
let pivot = first
let pivotVal = array[pivot]
(array[first], array[pivot]) = (array[pivot], array[first])
var i = first + 1
var j = first + 1
while j < last {
if array[j] < pivotVal {
(array[i], array[j]) = (array[j], array[i])
i += 1