I was following a scala tutorial and I was using SBT as the build tool. This SBT version required JDK 7 but I had environmental variables set for JDK8 even though I had both installed on my machine.
To make SBT use JDK7 without changing JAVA_HOME environmental variable, this is what I did.
First created a new environmental variable JAVA_HOME7(any name which is not already being used) with the path to JDK7 as the value.
Then replaced JAVA_HOME in the sbt.bat file(which is inside the sbt folder inside program files folder) with JAVA_HOME7.
Translate
MATLAB - Applying a function for each element in an array using arrayfun
I'm not a big matlab fan. For a project I needed to apply a function for each element in an array. For that arrayfun can be used.
Here is a simple example.
Say you have 3 arrays as follows.
A = [1,2,3,4]
B = [5,6,7,8]
C = [9,10,11,12]
And you need to calculate the value of a function myf, for A[i], B[i] and C[i] (i=1,2,3,4) which returns A[i] x B[i] + C[i]
You can do it as follows.
First define your function considering a single element.
function output=myf(a,b,c)
output=a*b + c;
end
Then,
A = [1,2,3,4]
B = [5,6,7,8]
C = [9,10,11,12]
D = arrayfun(@myf,A,B,C)
Remember to have "@" before myf. It denotes a handle in matlab. If you forget it, matlab will try to evaluate the function instead of considering its handle, which may result in "Not enough input arguments" error.
Here is a simple example.
Say you have 3 arrays as follows.
A = [1,2,3,4]
B = [5,6,7,8]
C = [9,10,11,12]
And you need to calculate the value of a function myf, for A[i], B[i] and C[i] (i=1,2,3,4) which returns A[i] x B[i] + C[i]
You can do it as follows.
First define your function considering a single element.
function output=myf(a,b,c)
output=a*b + c;
end
Then,
A = [1,2,3,4]
B = [5,6,7,8]
C = [9,10,11,12]
D = arrayfun(@myf,A,B,C)
Remember to have "@" before myf. It denotes a handle in matlab. If you forget it, matlab will try to evaluate the function instead of considering its handle, which may result in "Not enough input arguments" error.
Because a bit of Art must be a part :) - No 2
The Cycle
He cried in a rhythm when he was born
It’s the joke among his peers
When he sings the wind slows down
Hares freeze and turn their ears
He is singing, just singing
He never knew the meaning of the song
He doesn't try, he never did
Bewitching the world, sings along
Charming young ladies,
Dancing like glimmering flames
Neither they ever knew
What’s the meaning? Is it deep or lame?
The lyricists, did they know?
Their only aim, do words rhyme?
Are they hollow, are they rich?
Who cares? It’s not a crime
Some wrote, he sang, all danced
The cycle went on and on…
No one asked why,
‘cause no danger was yet known…
It’s the joke among his peers
When he sings the wind slows down
Hares freeze and turn their ears
He is singing, just singing
He never knew the meaning of the song
He doesn't try, he never did
Bewitching the world, sings along
Charming young ladies,
Dancing like glimmering flames
Neither they ever knew
What’s the meaning? Is it deep or lame?
The lyricists, did they know?
Their only aim, do words rhyme?
Are they hollow, are they rich?
Who cares? It’s not a crime
Some wrote, he sang, all danced
The cycle went on and on…
No one asked why,
‘cause no danger was yet known…
Scroll to a given item in a dataview - Sencha Touch
In my Sencha Touch app I had a component dataview. I had included an index bar and I needed to scroll to the relevant items when I click on index bar. This is what I did.
Here recordIndex is the index of the component in dataview that we need to scroll to.
Here recordIndex is the index of the component in dataview that we need to scroll to.
Adding a custom theme for the android preview screen in a Sencha Touch - Cordova app
In android on app launch, a preview screen is shown. This is before the splash screen. In a Sencha - Cordova app even if we have added the splash screen plugin, before the splash screen this preview window will appear. In my last post I have written how to change the theme of this preview screen in a pure Sencha Touch app. Here I'm writing how to add a custom theme for Sencha Touch+cordova app.
First create an xml file inside,
project-folder/cordova/platforms/android/res/values
The name of the XML file could be anything. Let's call it themes.xml. Then define your theme inside it.
Eg:
I'm going to override the NoTitleBar theme.. To do that this is what we should put inside themes.xml
Now, in the android manifest XML file which is inside,
project-folder/cordova/platforms/android
change the theme as follows.
android:theme="@style/MyTheme"
Black screen before splash screen in Sencha Touch android app?
I built a native Sencha Touch app using Sencha cmd.
I could not find a "nice" way to get rid of this black preview window. This is the only solution I found.
1. Go to AndroidManifest.xml inside the path_to_sencha_cmd/Sencha/Cmd/4.0.4.84/stbuild/st-res/android/
(I was using the version 4.0.4.84. The path depends on that.)
2. Inside application tag change the theme as android:theme="@android:style/Theme.Light"
If you do not want the title bar use this instead of the above one.
android:theme="@android:style/Theme.Light.NoTitleBar"
I don't think this is a good way to solve the problem. But I could not find a better way rather than changing Sencha cmd code.
References
[1] https://plus.google.com/+AndroidDevelopers/posts/VVpjo7KDx4H
I was having a problem. When I open the app before my splash screen loads a black screen was appearing. I found that the reason for this black screen is that on app launch, Android displays a simple preview window (based on your activity theme) as an immediate response to the user action. Then the preview window crossfades with the actual UI, once that has fully loaded [1].
I could not find a "nice" way to get rid of this black preview window. This is the only solution I found.
1. Go to AndroidManifest.xml inside the path_to_sencha_cmd/Sencha/Cmd/4.0.4.84/stbuild/st-res/android/
(I was using the version 4.0.4.84. The path depends on that.)
2. Inside application tag change the theme as android:theme="@android:style/Theme.Light"
If you do not want the title bar use this instead of the above one.
android:theme="@android:style/Theme.Light.NoTitleBar"
I don't think this is a good way to solve the problem. But I could not find a better way rather than changing Sencha cmd code.
References
[1] https://plus.google.com/+AndroidDevelopers/posts/VVpjo7KDx4H
Sencha native build - App doesn't go beyond app loading screen after installing in phone
I has developed a sencha touch application and I wanted to do a native build using Sencha cmd. I went through a really bad time trying to find out what exactly to do.
First, there is a difference in below two builds.
1. Sencha app build native
2. Sencha app package build
The first one creates the actual application using sencha native packager. The second creates the source to be put into a packager(eg: Cordova). Say you are going to build for android. Either way you will get an apk which can be installed in an android phone. But if you are planning to access native APIs then either you should do the native build or you should do the package build plus another wrapper.
I first packaged my app using "sencha app package build". But later I wanted to access native APIs(for example accessing the network status of the device).Therefore I ran sencha app build native command. I got a nice apk and I installed it in my phone.
Problems I faced and how I solved them
1. The app got stuck on app loading screen and none of the pictures I had on app loading screen were visible.
There is a file called app.json inside the application folder. You need to put paths to all the JS, CSS assests and resources inside this file.
2. Even after solving above problem app was still stuck at app loading screen.
I ran "Sencha app build production" command. This creates a minimized version of the app inside
./build/production folder. I pointed localhost to this. Then when app loads I could see the errors on console. The problem had been that I had included my "sencha-touch-all.js" file inside my index.html.(<script type="text/javascript" src="touch/sencha-touch-all.js"></script>)
Actually there is no need to put this inside index.html because we have already included this inside app.json as a JS assest. In the native build this file is not inside the app anymore but index file requires this because I have put it there. Once I removed this from index.html and did the native build again, my app didn't stuck at app loading screen anymore.
Subscribe to:
Posts (Atom)
