Skip to content

Instantly share code, notes, and snippets.

View Manikkumar1988's full-sized avatar

Manikkumar Manikkumar1988

View GitHub Profile
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: markhobson/node-chrome
private ViewModelProvider.Factory fuelLogViewModelFactory;
private FuelLogViewModel fuelLogViewModel;
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
fuelLogViewModel = ViewModelProviders.of(getActivity(),fuelLogViewModelFactory)
.get(FuelLogViewModel.class);
observeForAverageConsumption();
private MutableLiveData<FuelStat> averageFuelConsumption = new MutableLiveData<>();
....
....
public void calculateFuelStat() {
averageFuelConsumption.postValue(fuelLogs.calculateFuelStat());
}
package com.mani.fuellog;
@RunWith(AndroidJUnit4.class)
public class HomeFragmentTest {
@Mock
private FuelLogViewModel fuelLogViewModel;
private MutableLiveData<FuelStat> doubleMutableLiveData = new MutableLiveData<>();
@Manikkumar1988
Manikkumar1988 / sample.java
Created May 8, 2019 23:57
Unit Test on UI
FragmentScenario.launchInContainer(HomeFragment.class,null,new FragmentFactory(){
@NonNull
@Override
public Fragment instantiate(@NonNull ClassLoader classLoader, @NonNull String className) {
return YourFragment.newInstance(mockedClass);
}
});
@Manikkumar1988
Manikkumar1988 / app.gradle
Last active May 9, 2019 00:05
Fuellogger Android App
apply plugin: 'com.android.application'
apply plugin: 'jacoco'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.mani.fuellog"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
@Manikkumar1988
Manikkumar1988 / Board.java
Last active April 16, 2019 16:39
Skeleton of Tictactoe Game Guided by TDD Using object oriented design
public class Board {
private final int BOUNDARY;
private final Square boardLayout[][];
public Board(int boundary) {
this.BOUNDARY = boundary;
boardLayout = new Square[BOUNDARY][BOUNDARY];
}
@Manikkumar1988
Manikkumar1988 / min_or_max_gt_or_le_x
Created November 17, 2017 17:06
GETTING MIN/MAX IN A SEQUENCE GREATER/LESS THAN SOME VALUE
def min_gt(seq, val):
return min([v for v in seq if v > val])
def min_ge(seq, val):
return min([v for v in seq if v >= val])
def max_lt(seq, val):
return max([v for v in seq if v < val])
def max_le(seq, val):
@Manikkumar1988
Manikkumar1988 / slack_upload.sh
Created September 21, 2017 11:56
CURL command to upload file on Slack
curl https://slack.com/api/files.upload -F token="${SLACK_TOKEN}" -F channels="${SLACK_CHANNEL}" -F title="${message_title}" -F filename="${filename}" -F file=@"${path_to_file}"
{
if(timer != null) {
timer.cancel();
}
timer = new Timer();
MyTimerTask myTimerTask = new MyTimerTask();
timer.schedule(myTimerTask, 1000, 5000);
}