Tuesday, November 01, 2011

Nice syntax highlight plug-in

Windows Live Writer Plugin - Source Code Formatter

Accessing Stored Procedures Using ADO.NET

From here.

// create the connection
OracleConnection conn = new OracleConnection("Data Source=oracledb;
    User Id=UserID;Password=Password;");
// create the command for the stored procedure
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "SELECT_JOB_HISTORY.GetJobHistoryByEmployeeId";
cmd.CommandType = CommandType.StoredProcedure;
// add the parameters for the stored procedure including the REF CURSOR
// to retrieve the result set
cmd.Parameters.Add("p_employee_id", OracleType.Number).Value = 101;
cmd.Parameters.Add("cur_JobHistory", OracleType.Cursor).Direction =
    ParameterDirection.Output;
// createt the DataAdapter from the command and use it to fill the
// DataSet
OracleDataAdapter da = new OracleDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
// output the results.
Console.WriteLine(ds.Tables[0].Rows.Count);

Thursday, September 15, 2011

Set to array[T]

T[] array = set.toArray(new T[set.size()]);






Sunday, September 04, 2011

Starting activity from command line

am start -a android.intent.action.MAIN -n com.mydomain.mypackage/com.mydomain.mypackage.HomeActivity


-a action to perform


-n on this activity



Tuesday, August 16, 2011

Add static libraries *.jar to Android.mk based build

in Android.mk


LOCAL_STATIC_JAVA_LIBRARIES := mylocaljar


LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := mylocaljar: mylocaljar.jar


mylocaljar.jar should be in root directory of the project. Look at the Calculator app's Android.mk in Android tree as an example



Fragments for All

http://android-developers.blogspot.com/2011/03/fragments-for-all.html



Blogpost code highlighting

Here I found how to highlight code in my blogposts on Blogspot. It's still not ideal because it doesn't support the original indentation but better nothing.



Automatic thread

Nice piece of code from Android e-mail client



public static AsyncTask runAsync(final Runnable r)
{ return new AsyncTask() {
@Override
protected Void doInBackground(Void... params) {
r.run();
return null;
}}.execute();
}
runAsync(new Runnable() {
@Override
public void run() {}}
);



Monday, August 15, 2011

Friday, July 29, 2011

Market filters

Today's challenger was the defect where some Android devices did not see some apps on Android Market and some other did. Android is complicated in this area too. If your device is not good for a certain app Android Market hides the app rom the view. On one hand it's good. If your device cannot run an app why bother and display it? On the other what if I, a user, want this app so bad that I wanna buy a new phone just to make this app happy. How am I supposed to know what phone I need and what features or operating system version it should have?


Anyway the solution (not for newbies) lies here. This article explains a million complicated reasons why you don't see your app. I think Google should always display apps like that. But it should not let user to install them with explanations why.












Wednesday, July 13, 2011

Broadcast receiver problem

Today I saw a weird bug. I had a broadcast receiver in one app's AndroidManifest.xml


<receiver android:name=".MyReceiver">


<intent-filter>


<action android:name="com.my.intent.update" />


</intent-filter>


</receiver>




and another app sent broadcast with the intent the first app had to handle.




Intent intent = new Intent("com.my.intent.update");


sendBroadcast(intent);




The problem was it never did. I spent some time and asked my co-worker to look at it with me. While looking I found the problem (pair programming works after all). I had an activity in the same manifest file that had a receiver that handled the same intent!





<activity android:label="Test" android:name=".HomeActivity"


android:launchMode="singleTask" android:configChanges="orientation">


<intent-filter>


<action android:name="com.my.intent.update" />


</intent-filter>


</activity>




I don't know why it was there but it made receiver never handle the intent.



Tuesday, July 12, 2011

Echo from Android.mk

$(info YOUR MESSAGE HERE)



Wednesday, May 18, 2011

Amazon trade in program

Not a bad idea



Curse of SSD

"The problem with an SSD is [that] data is written in blocks. A block may be 256KB: 256 * 1000 * 8 binary digits. To change even ONE of these digits, you must rewrite the ENTIRE block. That is to say, your OS sees 1 bit being written, but the SSD wear is equivalent to 256KB being written: a 2.048 MILLION fold difference." From here



Friday, May 13, 2011

Simple sync adapter sample server cridentials

Use account user1/test on samplesyncadapter server.






Thursday, May 12, 2011

О как!

"Маме Джульетты на момент событий, описанных в пьесе, было 28 лет.


Марья Гавриловна из «Метели» Пушкина была уже немолода: «Ей шел 20-й год».


«Бальзаковский возраст» – 30 лет.


Ивану Сусанину на момент совершения подвига было 32 года (у него была 16-летняя дочь на выданье).


Старухе процентщице из романа Достоевского «Преступление и наказание» было 42 года.


Анне Карениной на момент гибели было 28 лет, Вронскому – 23 года, старику мужу Анны Карениной – 48 лет (в начале описанных в романе событий всем на 2 года меньше).


Старикану кардиналу Ришелье на момент описанной в «Трех мушкетерах» осады крепости Ла-Рошель было 42 года.


Из записок 16-летнего Пушкина: «В комнату вошел старик лет 30» (это был Карамзин).


У Тынянова: «Николай Михайлович Карамзин был старше всех собравшихся. Ему было тридцать четыре года – возраст угасания»




Взято с фейсбука.



Friday, May 06, 2011

Grep search

grep -i -n -r 'my search term' --include=*.java .



searches for 'my search term' in current directory and sub directories in all files






Thursday, May 05, 2011

How do you remove subversion control for a folder?

find . -iname ".svn" -type d -print0 | xargs -0 rm -r


taken from here



Monday, April 25, 2011

How to collapse or expand notification bar in Android programatically

final StatusBarManager statusBar = (StatusBarManager)mContext.getSystemService(Context.STATUS_BAR_SERVICE);
statusBar.collapse();
statusBar.expand();



Monday, April 04, 2011

Time machine issue solved

I had issues with Time Machine backups. After some time while backing up Time Machine gave me a finger: ". . . an error occurred while copying files to the backup volume" and a suggestion to repair disk. Nothing the error message suggested worked. I repaired disk, verified it and even formatted. Until I tried this tip.



Sunday, April 03, 2011

I like this command

find . -type f -name "file_to_remove" -exec rm -f {} \;



finds a file by name or mask in current directory and recursively and deletes it :) From here.






Saturday, April 02, 2011

Wednesday, March 30, 2011

Can one Android app have more than one icon in app launcher?

Why not! Just add this to your favorite AndroidManifest.xml:



<application>
<activity android:name="AActivity" android:icon="@drawable/a_icon" android:launchMode="singleTask"
android:screenOrientation="portrait"
android:label="@string/a_name" android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="BActivity" android:icon="@drawable/b_icon" android:launchMode="singleTask"
android:screenOrientation="portrait"
android:label="@string/b_name" android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="CActivity" android:icon="@drawable/c_icon" android:launchMode="singleTask"
android:screenOrientation="portrait"
android:label="@string/c_name" android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity></application>

and that's it. You'll get s single app with three different app icons: a_icon, b_icon, c_icon.



Some useful tools for Android shell

ps | grep "launcher" will look for all processes running on Android that have launcher in their name
pm path com.android.launcher will show where the process binary lives

Monday, March 28, 2011

ADB: error: insufficient permissions for device

Needs: 


adb kill-server 
sudo adb start-server
adb devices

to work

Thursday, March 24, 2011

Return in Java class constructor

I have never seen that before but looking at Android source tree found something like that:

class A {
    A(String arg){
    if (arg == null){
        return;
    }
  }
}

Tuesday, March 22, 2011

Android default wallpaper location

In system/frameworks/base/core/res/res/drawable/default_wallpaper.jpg

The rest of the wallpapers are in system/packages/apps/Launcher2/res/drawable-hdpi/wallpaper_ ...

Sunday, March 20, 2011

True

THE JOB DESCRIPTION GUIDE:
  • "Fast-paced" = we change our minds alot, shut up.
  • "Self-starter" = oops, last guy left quickly.
  • "Team-player" = our boss takes the credit.
  • "Good communicator" = you're the asshole we'll have talk to clients.
  • "Knowledge of HTML" = recruiter is 700 years old and thinks this is difficult.
  • "Benefits include health insurance and 401k" = we don't pay much, so this had to be in the ad.
  • "Flexible work schedule" = better enjoy unpaid OT, dickface.
  • "Java or C++" = we don't know what the fuck we're doing...
  • "Java or C++ or .NET" = ...maybe you know?
  • "Cutting edge technology" = we've upgraded to XP SP3.
  • "Bachelors in CS/IT or technical discipline or equivalent experience" = we used to hire people right out of high school, until the incident.

    Taken from here

Saturday, March 19, 2011

Remove Android application from app launcher

Just remove this:



<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
intent-filter>

from AndroidManifest.xml

Friday, March 18, 2011

Get local list of targets

./android list targets

Manage android emulator from command line

create: ./android create avd -n avd21 -t 3
launch: ./emulator -avd avd21
delete: ./android delete avd -n avd21

More

How do you delete a downloaded timesheet in QuickBooks so it can be resubmitted?

You need to delete the incorrect time from your QuickBooks first, and then ask this employee to use the following utility to re-submit his/her timesheet for that week.

This utility changes the status for a week's worth of time activities. The employee time trackers must perform the steps to update their own activities.

1. Login to the Row View and navigate to the week of time activities you would like to update the status for.

2. Click the Switch to Calendar View link.

3. From the Calendar View, click the Switch to Row View link.

4. Change the following parameters to the end of the URL of the page to invoke the repair utility:

&cmd=repair&status= submitted

The full URL should look something like this:

https://timetracking.quickbooks.com/j/tts/tts_timesheetweek=1222714800000&ampcmd=repair&ampstatus=subm...

5. When done adjusting the URL, press the Enter key on the keyboard to load the next page.

6. If the statuses were successfully updated, you will see a success message on the Timesheet Repair Status page.

7. Click on the Undo Submit button, make the necessary changes to the timesheet, and then submit the timesheet again.

Taken from here

Cheap memory

http://www.memoryupgrade.pro/

Creating a patch file in SVN

svn diff > ~/new_bug_fix.diff