Skip to content

Instantly share code, notes, and snippets.

View 4sskick's full-sized avatar
🏠
Working from home

tian 4sskick

🏠
Working from home
View GitHub Profile
first we have to edit sources.list file using gedit
remember this method is using terminal!
To open up terminal hit "ctrl+alt+T"
then type "gedit /etc/apt/sources.list"
delete all text inside, then replace with the new one,
#repo ITB :
deb ftp://ftp.itb.ac.id/pub/ubuntu oneiric main restricted universe multiverse
This gonna be usefull when U have some pattern actvities to done continously wo/ doing it manually
1. Problem: need to execute `arp -d` continously, the command to delete host on arp table to reset it to first time connect to wifi or other connection gateway. This could even be prevent the user in same connection's gateway which use `internet cut` software (might be myth). Every time the command execute, your computer delete the inet_addr that already chaced to your computer then re-request to gateway point to give you new chace. This usually used when your computer have problem to connect to internet, so your computer need to refresh the chace inet_addr. (I might be wrong sorry, I'm not expert)
#!/bin/bash
echo 'Running command'
set -x #echo on everything the command executed
while true;
@4sskick
4sskick / pick random element list java
Last active August 15, 2019 07:21
this methods useful whenever you build dummy data using model
private static <E> List<E> pickNRandomElements(List<E> list, int n, Random r) {
int length = list.size();
if (length < n) return null;
//don't need to shuffle the whole list
for (int i = length - 1; i >= length - n; --i) {
Collections.swap(list, i, r.nextInt(i + 1));
}
return list.subList(length - n, length);
#!/bin/bash
mongo --eval "db.stats()" # do a simple harmless command of some sort
RESULT=$? # returns 0 if mongo eval succeeds
if [ $RESULT -ne 0 ]; then
echo "MongoDB service is not running, try to run with admin"
sleep 3 #3 secs
exit 1
else
#!/bin/bash
echo 'Trying to STOP service MongoDB'
set -x #for echo on
net stop MongoDB
echo 'Done STOP service MongoDB'
sleep 3 #3 secs
@4sskick
4sskick / KoinJavaUtils.kt
Created July 18, 2020 10:46 — forked from fredy-mederos/KoinJavaUtils.kt
Koin java utility functions to inject components and properties in java classes.
package com.common.utils
import org.koin.KoinContext
import org.koin.standalone.StandAloneContext
import kotlin.jvm.internal.Reflection
/**
* @author @fredy_mederos
*/
based on tutorial in http://stackoverflow.com/a/12800042
and this tutorial to upload existing project into github.
so, you need to create new repository first
Steps:
- make sure you have installed git in your computer
- open the directory project then open CMD in it
- type 'git init'. This will say "Initialized empty git repository in ....git" (... is the path).
- type 'git add .' Dont forget 'pull stop' mark in the end of add after 'space'. I assume you wanna upload a whole file inside the directory.
- type 'git commit -m "massage here for commit"
@4sskick
4sskick / nvm setup with windows 10
Created October 4, 2021 04:43
NVM setup with windows 10
- take a look git repo [over here](https://github.com/coreybutler/nvm-windows/releases)
- or you can see mine I've downloaded [here](https://bit.ly/nvmSetup) version 1.1.17
- finished downloaded, execute & follow installation as regular
- finished installation, check with command `nvm --version` if doesn't show anything try to restart windows
- check again till version `nvm --version` shown
- install node version you wanna use with command `nvm install node_version` it will download required files node js along with NPM
- finished installed node_version, then type `nvm use node_version` you just installed
- type `nvm list` to see node version installed you able to use directly
- or `nvm list available` to see all list you ready to install with version LTS and latest version
- DONE
@4sskick
4sskick / Android parameterize test
Last active October 5, 2021 07:51
unit test with parameter input
as regular test using unit test we can use jUnit roboelectric Mockito etc. There are some condition which class with parameter more than 1
ex. inteface class
`double getPriceAfterSurcharge(double baseCost, double surchargeFixedPrice, double surchargePercentage, Integer quantity);`
implementation class:
@Override
public double getPriceAfterSurcharge(double baseCost, double surchargeFixedPrice,
double surchargePercentage, Integer quantity) {
double productPrice;
@4sskick
4sskick / Jacoco Setup Android
Last active October 5, 2021 11:48
Jacoco setup report coverage
see here https://medium.com/nerd-for-tech/setup-jacoco-code-coverage-with-your-multimodule-android-app-kotlin-a0f82573a1
exclude file agregation here https://liviutudor.com/2016/02/11/jacoco-gradle-excluding-source-files-and-classes/