Notes from a software developer
This blog is mainly meant as my own notepad where I can put tips and tricks about software development.
Wednesday, September 7, 2016
Wednesday, July 6, 2016
Danske Google Nu stemmekommandoer
Jeg har prøvet at samle nogle af de Google Nu stemmekommandoer, som virker på dansk.
Hvordan er vejret? *
Hvordan er vejret i [London]? *
Hvad er [182 miles] i [kilometer]?
Hvad er [135 divideret med 7]? *
Tag et billede
Optag en video
Åbn [Maps]
Tænd/sluk [Lommelygte]
Sæt en alarm i morgen klokken [8] **
Hvordan er vejret i [London]? *
Hvad er [182 miles] i [kilometer]?
Hvad er [135 divideret med 7]? *
Tag et billede
Optag en video
Åbn [Maps]
Tænd/sluk [Lommelygte]
Sæt en alarm i morgen klokken [8] **
Væk mig om [30 minutter] **
Stil min alarm til klokken [18] **
Start nedtælling på [10 minutter] *
Mind mig om at [købe kaffe] [når jeg kommer hjem] *
Start nedtælling på [10 minutter] *
Mind mig om at [købe kaffe] [når jeg kommer hjem] *
Husk mig på at [vande blomsterne] [om 4 timer/klokken 7] *
Ring til [min kone]/[navn] *
Ring til [min kone]/[navn] *
Ring til [navn]s [mobil] *
Send besked til [min kone] [jeg kommer hjem nu] *
Send besked til [min kone] [jeg kommer hjem nu] *
Send en SMS til [navn] [hvor er du?] *
Send en SMS til [navn] hvor der står [vi ses om en halv time] *
Hvor er nærmeste [tankstation]? *
Naviger til [Legoland] *
Hvor er [Legoland]? *
Seværdigheder i nærheden *
Hvordan siger man [farvel] på [tysk]? *
Hvad er [100 Euros] i [Dollars]? *
Spil noget musik
Spil musik med [AC/DC]
Hvornår spiller [Wales]? *
Hvornår går solen ned? *
Hvornår står solen op? *
Hvor gammel er [Morten Olsen]? *
Hvor er nærmeste [tankstation]? *
Naviger til [Legoland] *
Hvor er [Legoland]? *
Seværdigheder i nærheden *
Hvordan siger man [farvel] på [tysk]? *
Hvad er [100 Euros] i [Dollars]? *
Spil noget musik
Spil musik med [AC/DC]
Hvornår spiller [Wales]? *
Hvornår går solen ned? *
Hvornår står solen op? *
Hvor gammel er [Morten Olsen]? *
Send en mail til [navn]
Hjælp
*) Virker også på Android Wear
**) Sætter alarmen på uret hvis indtalt her
**) Sætter alarmen på uret hvis indtalt her
Wednesday, October 28, 2015
Agile Podcasts
Here's a list of great agile podcasts that I enjoy listening to.
This Agile Life, http://www.thisagilelife.com/
Agile for Humans, http://agileforhumans.com/
Scrum Master Toolbox, http://www.scrum-master-toolbox.com/
Sunday, January 18, 2015
Acer Aspire 5536 won't boot; black screen -> Solution!
So, my father came to me with his Acer Apire 5536 laptop and said that it wouldn't boot anymore; the screen was just black. At first I tried attaching an external display via the HDMI port and playing with the Fn-F5 and Fn-F6 key combinations. Nothing worked.
Then I turned to Google search and found a lot of stuff about the same problem with may solutions pointing to either fried GPU or dead BIOS battery. Changing the GPU was a rather expensive and/or difficult task, so I looked into changing the BIOS battery as it was a common CR2032 one.
This was inspired after reading this post on Notebook Review's forum. To get to the battery was not as easy as I thought. You pretty much have to tear the laptop apart, but luckily there's a service manual to follow.
So follow the disambly steps in the service manual until you can get to the BIOS battery; put in a new one; and then reverse assemble the laptop again. In my case: Viola!!! the laptop booted into the operating system and my father was happy.
Case closed! :-)
Then I turned to Google search and found a lot of stuff about the same problem with may solutions pointing to either fried GPU or dead BIOS battery. Changing the GPU was a rather expensive and/or difficult task, so I looked into changing the BIOS battery as it was a common CR2032 one.
This was inspired after reading this post on Notebook Review's forum. To get to the battery was not as easy as I thought. You pretty much have to tear the laptop apart, but luckily there's a service manual to follow.
So follow the disambly steps in the service manual until you can get to the BIOS battery; put in a new one; and then reverse assemble the laptop again. In my case: Viola!!! the laptop booted into the operating system and my father was happy.
Case closed! :-)
Monday, September 22, 2014
Getting rid of some boiler plate code in event handling
I came across an easy way to get rid of some boiler plate code I am always writing when writing event handlers. Consider this example:
public event EventHandler SomethingHappened;
private void OnSomethingHappened() {
var handler = SomethingHappened;
if (handler != null) {
handler(this, EventArgs.Empty);
}
}
In the OnSomethingHappened() method there's a lot of unnecessary boiler plate code to make sure that we don't run into a NullReferenceException.
With a small change to the setup we can do the same with much less coding. Consider another improved example:
public event EventHandler SomethingElseHappaned = delegate { };
private void OnSomethingElseHappened() {
SomethingElseHappened(this, EventArgs.Empty);
}
That was easy! I'm gonna do this from now on!
Happy coding!
public event EventHandler SomethingHappened;
private void OnSomethingHappened() {
var handler = SomethingHappened;
if (handler != null) {
handler(this, EventArgs.Empty);
}
}
In the OnSomethingHappened() method there's a lot of unnecessary boiler plate code to make sure that we don't run into a NullReferenceException.
With a small change to the setup we can do the same with much less coding. Consider another improved example:
public event EventHandler SomethingElseHappaned = delegate { };
private void OnSomethingElseHappened() {
SomethingElseHappened(this, EventArgs.Empty);
}
That was easy! I'm gonna do this from now on!
Happy coding!
Wednesday, October 9, 2013
How to add unit tests to Android Studio project
Modify the build.gradle file
First of all remeber to modify the module's build.gradle file and not the one in the project.In the android, defaultConfig section add this
testPackage "<package>.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
In the dependencies section add this
instrumentTestCompile 'junit:junit:3.8'
Save the file and click the Sync Project with Gradle Files button.
Add unit tests
Under <Project>, <Module>, src add a folder named instrumentTest. Under this create a folder named java and here create a new package named <package>.test.
Now create a class named <ClassName>Test that inherits from android.test.InstrumentationTestCase. In this class individual tests of the class <ClassName> can be written, e.g.
public void testSomeMethodInClass() throws Exception {
final int expected = 1;
final int actual = Class.Method();
assertEquals(expected, actual);
}
Execute test
Right-click on the test method, e.g. testSomeMethodInClass in the example above, choose Run and testSomeMethodInClass. Take the one with the Android icon!
Now a dialog to choose device or emulator will most likely appear. Choose which one to run the test on.
Project structure
<Project>+-.idea
+-gradle
+-<Module>
| +-build
| +-src
| | +-instrumentTest
| | | +-java
| | | +-<package>.test
| | | +-<ClassName>Test
| | +-main
| | +-java
| | | +-<package>
| | | +-<ClassName>
| | +-res
| | | +-drawable...
| | | + ...
| | | +-values...
| | +-AndroidManifest.xml
| +-build.gradle <<------------ THIS ONE!
+-build.gradle <<-------------- *NOT* THIS ONE!
Sunday, June 2, 2013
Make the Google+ SDK Sample app work
I was following the Google+ quick start guide for Android to the letter and found the last step quite frustrating:
I/dalvikvm(9444): Failed resolving Lcom/google/android/gms/samples/plus/PlusOneActivity; interface 556 'Lcom/google/android/gms/common/GooglePlayServicesClient$ConnectionCallbacks;'W/dalvikvm(9444): Link of class 'Lcom/google/android/gms/samples/plus/PlusOneActivity;' failed E/dalvikvm(9444): Could not find class 'com.google.android.gms.samples.plus.PlusOneActivity', referenced from method com.google.android.gms.samples.plus.PlusSampleActivity.<clinit>
W/dalvikvm(9444): VFY: unable to resolve const-class 590 (Lcom/google/android/gms/samples/plus/PlusOneActivity;) in Lcom/google/android/gms/samples/plus/PlusSampleActivity;
D/dalvikvm(9444): VFY: replacing opcode 0x1c at 0x0018
W/dalvikvm(9444): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/google/android/gms/samples/plus/PlusSampleActivity;
W/dalvikvm(9444): Class init failed in newInstance call (Lcom/google/android/gms/samples/plus/PlusSampleActivity;)
D/AndroidRuntime(9444): Shutting down VM
W/dalvikvm(9444): threadid=1: thread exiting with uncaught exception (group=0x4203e2a0)
E/AndroidRuntime(9444): FATAL EXCEPTION: main
Select Run > Run to test the PlusSampleActivity
sample app. Choose Android application if prompted. The sample application will launch on your device.
When I launched the app from Eclipse I kept getting a crash. My LogCat looked like this:I/dalvikvm(9444): Failed resolving Lcom/google/android/gms/samples/plus/PlusOneActivity; interface 556 'Lcom/google/android/gms/common/GooglePlayServicesClient$ConnectionCallbacks;'W/dalvikvm(9444): Link of class 'Lcom/google/android/gms/samples/plus/PlusOneActivity;' failed E/dalvikvm(9444): Could not find class 'com.google.android.gms.samples.plus.PlusOneActivity', referenced from method com.google.android.gms.samples.plus.PlusSampleActivity.<clinit>
W/dalvikvm(9444): VFY: unable to resolve const-class 590 (Lcom/google/android/gms/samples/plus/PlusOneActivity;) in Lcom/google/android/gms/samples/plus/PlusSampleActivity;
D/dalvikvm(9444): VFY: replacing opcode 0x1c at 0x0018
W/dalvikvm(9444): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/google/android/gms/samples/plus/PlusSampleActivity;
W/dalvikvm(9444): Class init failed in newInstance call (Lcom/google/android/gms/samples/plus/PlusSampleActivity;)
D/AndroidRuntime(9444): Shutting down VM
W/dalvikvm(9444): threadid=1: thread exiting with uncaught exception (group=0x4203e2a0)
E/AndroidRuntime(9444): FATAL EXCEPTION: main
E/AndroidRuntime(9444): java.lang.ExceptionInInitializerErrorE/AndroidRuntime(9444): at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime(9444): at java.lang.Class.newInstance(Class.java:1319)
E/AndroidRuntime(9444): at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
E/AndroidRuntime(9444): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2025)
E/AndroidRuntime(9444): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
E/AndroidRuntime(9444): at android.app.ActivityThread.access$700(ActivityThread.java:140)
E/AndroidRuntime(9444): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
E/AndroidRuntime(9444): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(9444): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(9444): at android.app.ActivityThread.main(ActivityThread.java:4921)
E/AndroidRuntime(9444): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(9444): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(9444): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
E/AndroidRuntime(9444): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
E/AndroidRuntime(9444): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(9444): Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.samples.plus.PlusOneActivity
E/AndroidRuntime(9444): at com.google.android.gms.samples.plus.PlusSampleActivity.<clinit>(PlusSampleActivity.java:46)
E/AndroidRuntime(9444): ... 15 more
I/Process(9444): Sending signal. PID: 9444 SIG: 9
After some googling around I stumbled upon this solution on StackOverflow: http://stackoverflow.com/questions/2247998/noclassdeffounderror-eclipse-and-android/9916751#9916751
E/AndroidRuntime(9444): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2025)
E/AndroidRuntime(9444): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
E/AndroidRuntime(9444): at android.app.ActivityThread.access$700(ActivityThread.java:140)
E/AndroidRuntime(9444): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
E/AndroidRuntime(9444): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(9444): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(9444): at android.app.ActivityThread.main(ActivityThread.java:4921)
E/AndroidRuntime(9444): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(9444): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(9444): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
E/AndroidRuntime(9444): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
E/AndroidRuntime(9444): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(9444): Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.samples.plus.PlusOneActivity
E/AndroidRuntime(9444): at com.google.android.gms.samples.plus.PlusSampleActivity.<clinit>(PlusSampleActivity.java:46)
E/AndroidRuntime(9444): ... 15 more
I/Process(9444): Sending signal. PID: 9444 SIG: 9
After some googling around I stumbled upon this solution on StackOverflow: http://stackoverflow.com/questions/2247998/noclassdeffounderror-eclipse-and-android/9916751#9916751
It pretty much explains that the way external libraries has to be included in an Eclipse project have changed. The Google Play Services library was included in the project properties under Android > Library.
Reference: ..\..\libproject\google-play-services_lib
Project: google-play-services_lib
Remove this reference and instead add it in the project properties under Java Build Path > Libraries tab. Click "Add External JARs..." and browse to <android-sdk-folder>\extras\google\google_play_services\libproject\google-play-services_lib\libs. Select "google-play-services.jar". Now go to the Order and Export tab and select "google-play-services.jar".
Now the Google+ SDK Sample app runs and works!
Subscribe to:
Posts (Atom)