Skip to main content

Posts

HTTPS for dummies - so how HTTPS really works in 5 mins

What is HTTPS? HTTPS (HyperText Transfer Protocol Secure) is a way of transferring data over internet in a secure manner. It's achieved through adding SSL (Secure Socket Layer)/TLS (Transport Layer Security) on top of standards HTTP. What HTTPS gives us? End-2-end encryption of data - from the browser to the server and back = even if someone reads the data you are sending, they will not be able to understand anything out of it Confirmation of the identity of the website we are accessing = you are sure that the website that looks like your bank is actually your bank (and not a phishing website) How does it work? First you need a pair of SSL certificates: One installed in your web browser (in most cases shipped together with your browser, provided by one of so-called trusted Certificate Authorities) One installed on the website (which is acquired by the website owner) Each of those SSL certificates includes the following information:  Public information: name of...

Spark 2 on Hortonworks Data Platform 2.5 Sandbox

Since apparently there are still issues with using Spark2 from Zeppelin, you may want to switch to shell to use Spark2 with HDP 2.5. Summarizing the flow (learned it the hard way): Connect via SSH to the sandbox (e.g. Putty  on Windows) on port 2122. This will allow you to use copy-paste (vs console in VirtualBox) username: root password (default): hadoop SSH into the docker container that runs HDP ssh root@172.17.0.2 username: root password (default): hadoop Make sure you use Spark2 export SPARK_MAJOR_VERSION=2 Run Spark shell cd /usr/hdp/current/spark2-client/bin ./spark-shell

Google Drive API - some helpful tips and code

I am not sure why, but there are not a lot of examples how to use Google Drive API from Android. If you're wondering about it, or you look for a working code, here it is... I assume you've already went successfully through the Google Drive SDK Quickstart -  https://developers.google.com/drive/quickstart-android  . 1) If you're using Eclipse as your IDE and you don't enjoy the command line, for step 1 in the Quickstart, you can find the right SHA1 fingerprint in Window->Preferences -> Android -> Build . 2) In Google Cloud Console (https://cloud.google.com/console) enable both Drive API and Drive SDK 3) Enabling Google Drive for your Activity. The code assumes that the main purpose of the activity is to synchronize your content (I called it BackupActivity - to backup all the content from the app to the Google Drive). a. In your Activity put the following: // change the following to your Activity name private final static String TAG = "Ba...

How to make Logitech Trackball Marble Wheel work

If you bought Trackball Marble from Logitech, the first challenge you encounter is probably related to the lack of the wheel button. Unfortunately the software provided with the device for Windows doesn't help (neither Universal or Auto Search aren't really working as I was expecting). Internet suggests mostly one option, app called Marble Mouse Scroll Wheel http://marble-mouse-scroll-wheel.software.informer.com/ To some extent it works, but I wasn't able to make it work in google maps or in picture viewer. Moreover setting where crashing very often (I am running windows 7 64 bits). Fortunately there is a way to have a semi-wheel button behavior with this trackball, but with a different software - X-Mouse Button Control: http://www.highrez.co.uk/downloads/XMouseButtonControl.htm Setup Mouse button 4 and 5 as wheel up and wheel down. Then also update Logitech SetPoint settings to replace the behavior of those button to default. Voila - now you can emulate wheel ...

Android Notifications - lesson learned from implementation

Recently some Conf Call Dialer users asked to add notifications to the application, so (since it seems to be a good idea) I've spent few hours implementing them in the app. Everything went smoothly, except of one rather funny problem, after executing NotificationManager.notify, notifications were not showing up and I was getting all the time the following warning in the LogCat (12345 is the id assigned to the notification): notify: id corrupted: sent 12345, got back 0 My code seemed to be rather simple (mostly copy paste from the javadoc, with some app specific logic added): NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this). setContentTitle(event.subject).setContentText(event.timeFrom + " " + additionalText); // ... NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(notificationId, mBuilder.build()); Googling didn't help, so I compare ...

Azure Storage Explorer - for all your Azure Storage management needs

If you are like me a heavy Azure user you may try the following tool that in an easy (and faster than the management UI) way allows you to manage content of your storages. Works like a dream, setup takes like 10 seconds. http://azurestorageexplorer.codeplex.com/

Rendering AdMob view on Canvas (SurfaceView) in android

If you're wondering how put a working AdMob view into your SurfaceView and are tired of looking in the Internet for solution (somehow most suggestions that I found on forums didnt work), here it is... Assumptions: A. We request the ad on creation (you may want to refresh it later though...) B. The AdView is put on the bottom of the screen C. It's a production ready code, but if you want to test it - add testDevices to the adRequest D. You've already set AndroidManifest properly as described in the Getting Started tutorial 1. In the activity that initializes your SurfaceView add a field representing your adView, for example: private AdView adView; 2. In the onCreate method of the same activity put the following code: // window manager preparation WindowManager.LayoutParams windowParams = new WindowManager.LayoutParams(); windowParams.gravity = Gravity.BOTTOM; windowParams.x = 0; windowParams.y = 0; windowParams.height = WindowManager.Lay...

ArrayAdapter notifyOnDataSetChanged doesn't refresh underlying ListView

If for any reason you're using ArrayAdapter to feed your ListView on Android you may be struggling with the fact that whatever you do - executing notifyOnDataSetChanged doesn't result in the corresponding ListView getting refreshed. There is one simple solution for this (and no, I am not talking about one that I saw on one forum where it was suggested to recreate the ArrayAdapter , which on a first glance may be a good idea at least until you're happy with the list jumping every time to the top). So what you need to do to have your ListView updated is: 1. Either execute  arrayAdapter.remove(itemToRemove); // if you want to delete item from the list or arrayAdapter.add(itemToAdd); // if you want to add an item to the list or 2. Execute arrayAdapter.clear(); // get rid of all elements arrayAdapter.addAdd(listOfItems); // add them back to the list Both work just fine.

How to join conference calls on Android

Since I am working for a global company for last few years, I spend quite a lot of time on conference calls. Still, joining conference calls especially if you're on a move isn't easy - I always had challenges when trying to memorize participant codes (again - especially while driving :)). But then - when you think about it, we have all the required information in the Android calendar, so it's only a matter of handling it properly. So here it is - Conference Call Dialer . I hope it will make your life easier (at least when it comes to joining conference calls :)) Additional information about the Conference Call Dialer : Functionality: - Retrieve information about meetings from the calendar - Dial into conference calls with conf code from the invitation - Manage and use multiple gateways (e.g. of your company and of your customers) - Review the invitations where conf code could be retrieved - A widgets for the home screen - Convenient "My conference call...

PreviewImage not showing up in widget list on android?

Few things to keep in mind when you're trying to set a preview image for your android widget: Set the android:icon attribute on the corresponding receiver in your AndroidManifest.xml to the same drawable as the one mentioned in the android:previewImag e attribute of your widget.xml file. Don't use too big (when it comes to resolution) preview images, as android anyway will scale them up. As a rule of thumb I've noticed that I have to scale down preview images (from their original size after doing screenshot in ddms) to 75% for small widgets (taking 1 row) and approx 50% for full screen widgets. Otherwise you'll get error saying that the widget dragging couldn't be initialized. Most widgets anyway don't use preview, so don't worry about it too much :)

Easy swipe gesture handling on android

Recently I wanted to implement swipe functionality for activity in my android app but couldn't find a nice and simple example that would explain what do you really need to do. There are multiple sites that are bloated with code, but somehow I couldn't believe that to implement such a simple (and kinda basic if you think about it) functionality you need to write tens of lines of code. So if you're like me, looking for a simple and elegant solution for swipe gesture handling, here it is... First some theory - to implement swipe you will need to: 1. Create a GestureDetector 2. Create an OnGestureListener by extending GestureDetector.SimpleOnGestureListener 3. Implement onFling method in listener created in step 2 4. Handle the onTouchEvent in your activity Now let's jump to the code: import android.app.Activity; import android.os.Bundle; import android.view.GestureDetector; import android.view.MotionEvent; public class MySwipeSupportedActivity extends ...

Free online learning

Recently I saw a great TED talk about high quality free online courses offered by some of the most famous universities around the world (like MIT, Stanford) , "Daphne Koller: What we're learning from online education", available at   http://www.ted.com/talks/daphne_koller_what_we_re_learning_from_online_education.html The whole talk is really great, with some tips how to improve the effectiveness of online trainings. I did also some googling and found following websites that offer free learning courses (or index them) from various disciplines. Really worth checking and signing up: https://www.coursera.org/  - site mentioned by Daphne Koller. 124 courses offered. https://www.edx.org/  - MIT, Berkley, Harvard - some of the courses start in September and beginning of October http://www.schneider-electric.com.au/sites/australia/en/company/data-center-free-online-training-courses.page  - Data Center University offers a lot of computer-related courses http://ocw....

Eclipse + EGit - "The authenticity of host ... can't be established" challenge

Recently while writing new Android code I decided that it's the highest time to have a Git repository not only on my hard drive, but also safe in the Internet. After quick search and finding out that I have accounts at almost every popular service that provides Git hosting, I figured out that one that covers everything I need (wiki, bug tracking, code hosting, forums) is the good old sourceforge. I used it also with no problems few months ago on another mobile project, so I was hoping that pushing code there will be a piece of cake. But then when I tried to do it (after configuring the project on the sourceforge site), I got very interesting error: ssh://USER@git.code.sf.net:22: org.eclipse.jgit.transport.CredentialItem$YesNoType:The authenticity of host 'git.code.sf.net' can't be established. RSA key fingerprint is 86:7b:1b:12:85:35:8a:b7:98:b6:d2:97:5e:96:58:1d. Are you sure you want to continue connecting? In theory it's nothing bad, you press the "Y...

Force.com REST API getting token with curl

Force REST API usage with curl is really well documented, there are at least two official HowTO's, but both of the assume that you will get your OATH token with Java. Below I've described steps required to get the token and verify your token with curl. 1. Retrieve token curl -v -k https://DOMAIN.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=CONSUMER_KEY" -d "client_secret=CONSUMER_SECRET" -d "username=USERNAME" -d "password=USER_PASSWORDSECURITY_TOKEN" where: DOMAIN - is your salesforce domain (e.g. na9) CONSUMER_KEY, CONSUMER_SECRET - as taken from App Setup -> Develop -> Remote Access USERNAME, USER_PASSWORD, SECURITY_TOKEN - properties for the user that you want to connect with. Note that USER_PASSWORD and SECURITY_TOKEN are concatenated. Note that I used -k parameter in curl which results in the SSL certificate validation skipped (otherwise you need to add it or t...

Visualforce - COUNT() vs COUNT_DISTINCT()

Having COUNT_DISTINCT() is a great advantage in apex over standard Salesforce reporting capabilities. Still what you need to remember is that it doesn't return Integer (as COUNT() is doing), but List<AggregateResult> with count stored in the expr0 attribute of the first element of the list. So while the following code is valid: public String getObjectsForSelectedApplication() { return String.valueOf([SELECT COUNT() FROM MyObjects__c WHERE Application__c = :selectedApplication]); } The following code will return a list: public String get UniqueUsersForSelectedApplication() { return String.valueOf([SELECT COUNT_DISTINCT(User__c) FROM MyObjects__c WHERE Application__c = :selectedApplication]); } What you need to do is take the count from the list, for example with the following code: public String getUniqueUsersForSelectedApplication() { List&ltAggregateResult&gt result = [SELECT COUNT_DISTINCT(User...

Visualforce - actionSupport for hiding/showing elements of the page

While working on a Visualforce page that would automatically show/hide parts of its content I've stumbled upon problems with actionSupport. So the following code doesn't work (to be precise - the "details" pageBlock is not rerendered upon change in the select element): <apex:pageBlock> <apex:form> <apex:selectList value="{! selectedApplication}" size="1">  <apex:actionSupport event="onchange" reRender="details"/>  <apex:selectOptions value="{! availableApplications}"></apex:selectOptions>               </apex:selectList>  </apex:form>  </apex:pageBlock>  <apex:pageBlock id ="details" title="Details for {! selectedApplication}" rendered="{! NOT(ISNULL(selectedApplication))}">  </apex:pageBlock> After googling a bit I've stumbled upon posts suggesting that this happens if you try to rerender page...

Salesforce custom objects with date/time column import

I was struggling a bit recently with importing few thousand rows into custom object in SF with Import Custom Objects feature. Everything was fine except of data for Date/Time column where I was always getting "Invalid format" error even though I tried multiple formats (including the one that was provided in files that I exported from SF). I tried also some of the format mentioned in the Data Loader Guide ( http://na1.salesforce.com/help/doc/en/salesforce_data_loader.pdf ). In the end, I downloaded the Data Loader and the same file was imported in a few seconds without any challenges. Kinda weird, I mean - you would expect the Import Custom Objects to support the same date formats as the Data Loader, but well, good news is that it works at least in one product :-)

Great application for sharing your android screen on PC

For everyone who wants to do a remote demo of android app you may want to check the Droid@Screen application ( http://blog.ribomation.com/droid-at-screen/ ). This little app streams your android device screen onto PC (then you can share it via virtual room/webex/go2meetings). It works just out of the box (yes, that's the first Java app that I was able to run without using a command line - respect to the developer :)). Advantages - applications run smoothly and from what I was told look better than on the emulator. Challenges - frame rate is not too high. It's around 1 fps (yes, that's one frame per second, for applications that include video/transitioning effects/animations you should consider using emulator or a camera).

Podcasts for today

Three non-technical topics podcasts: 1. http://hbr.org/multimedia/audio  - Harvard Business Review - a lot of interesting interviews concentrated on soft skills, business, career, etc. 2.  http://philmckinney.com/killer-innovations  - very interesting (although not published as frequently as you may wish to) podcast about innovation and creativity in general, created by Phil McKinney whom I had chance to meet and talk to twice (and yea, in real life he is also an interesting person :)) 3.  http://www.twis.org/  - this week in science is apparently back!

jQueryMobile in a weekend

I played with jQueryMobile during the weekend and was really surprised by the productivity you get with the framework. In like 4hrs I was able to create a great looking app that was running with any major glitches on my Android phone. Now when I compare that to the challenges I was experiencing when coding with Android :) Some lessons learned from the weekend: - Good IDE for javascript is a must. Aptana really rules in that area, you can add it to your Android Eclipse installation easily -  http://aptana.com/products/studio3/download - There are challenges on Android when you move between pages of the app. The whole screen blinks. Apparently you need to disable the transition effect on Android, like below: $.mobile.defaultDialogTransition = "none"; $.mobile.defaultPageTransition = "none"; - I18N is not built into the jQM, but there are some interesting workarounds, like  http://stackoverflow.com/questions/8134555/jquery-mobile-json-processing-before-mob...