pytest Tutorial – Part 2

In my last article pytest Tutorial Part 1  I showed some basic concepts of testing with pytest. Here are two additional concepts Parameterize Test parameterization follows the concept of DRY – Don’t repeat yourself Instead of writing a new testcase for every different value you annotate your test function and handover the different values. The…

Pandas Cheat Sheet

If you are new to Pandas feel free to read Introduction to Pandas I’ve assembled some pandas code snippets Reading Data Reading CSV import pandas as pd # read from csv df = pd.read_csv(“path_to_file”) Can also be textfiles. file suffix is ignored

Data Science Pipeline

Motivation Learning Data Science can be grueling and overwhelming sometimes. When I feel too overwhelmed it’s time to draw a picture. This my current overview of what a data scientist has to do: General tools Linear Algebra with numpy – Part 1 numpy random choice Numpy linspace function Data acquisiton Data Science Datasets: Iris flower…

New Blog Post

Sound and music with pygame

pip install pygame Sound import pygame if __name__ == ‘__main__’: pygame.mixer.init() sound = pygame.mixer.Sound(“./sound.wav”) channel = sound.play() while channel.get_busy(): pygame.time.wait(100) print(“Playing…”) print(“Finished.”)   Music import pygame if __name__ == ‘__main__’: pygame.mixer.init() pygame.mixer.music.load(“./sound.mp3”) pygame.mixer.music.play() while pygame.mixer.music.get_busy(): pygame.time.wait(100) # ms print(“Playing…”) print(“Finished.”)

New Blog Post

Getting Location Info in Android

Manifest <uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION” /> Activity   public static final int REQUEST_CODE = 123; LocationManager mLocationManager; LocationListener mLocationListener; @Override protected void onResume(){ super.onResume(); getCurrentLocation(); } private void getCurrentLocation() { Log.d(“Clima”, “getWeatherForCurrentLocation”); mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mLocationListener = new LocationListener() { @Override public void onLocationChanged(Location location) { Log.d(“Clima”, “onLocationChanged”); String longitude = String.valueOf(location.getLongitude()); String latitude = String.valueOf(location.getLatitude());…

New Blog Post

Passing data between AndroidActivities

Sending data private void openVideoActivity(String video) { Intent newActivity = new Intent(this, PlayerActivity.class); newActivity.putExtra(“videoId”, video); startActivity(newActivity); } Retrieving data final String videoID = getIntent().getExtras().getString(“videoID”);   In Kotlin it looks like this: val intent = Intent(this, NewActivity::class.java).apply { putExtra(“EXTRA_MESSAGE”, “Test 123”) } startActivity(intent) Retrieving val message = intent.getStringExtra(“EXTRA_MESSAGE”) Further Reading Passing data between fragments using SafeArgs…

Python variable length arguments

Ever wondered what these *varargs or *kwargs in python functions parameter mean? Let me explain! varargs varargs is short for variable arguments. It is declared like this: def print_person_varargs(name, *vargs): pass You can pass as many arguments as you like. In this case we pass two after the first positional argument ‘name:’ print_person_varargs(“Jörn”, 40, “Emskirchen”)…

New Blog Post

Android Services

Service Manager $ adb shell service list shell@g3:/ $ service list Found 132 services: 0 AtCmdFwd: [com.qualcomm.atfwd.IAtCmdFwd] 1 lge.apdu: [com.lge.smartcard.internal.apdu.uicc.IUiccAccess] 2 telecom: [com.android.internal.telecom.ITelecomService] 3 phone: [com.android.internal.telephony.ITelephony]