Categories
iPhone app

Creating WCF web service II

Reading Time: < 1 minute

A continuation of previous post.

1) Visual Studio, publish web service: check destination IIS app
Before the change, the error was “cannot show the content of the folder”.

2) Add this line to the service.cs (service class C# file), to work around/avoid a problem, asp .net compatibility issue. Do something like this:

[ServiceBehavior]
[AspNetCompatibilityRequirements(RequirementsMode=
AspNetCompatibilityRequirementsMode.Allowed)]
class BarService : IHelloContract
{
// …
}

Refer to wenlong

3) Bad request: it appears to be a class rename problem, Visual Studio has a “red” warning sign, follow it and accept “update”, rebuild.

Categories
Uncategorized

Mine trip to Charleston/WV

Reading Time: < 1 minute

Two impressions:
1) It’s not easy to get the coal, both underground (long wall), and surface (excavator, loader, truck). The geological condition (thinner seam) is making the job more difficult. One scene remains in my mind is miners eating lunch in the tunnel, while I was eating lunch in the office.

2) Commercial air travel is changed. No more spare capacity, and if affected by weather, the delay and cancellation will make travel less pleasant. We (travelers) are commodity anyway.

Categories
Uncategorized

Growing up

Reading Time: < 1 minute

This evening I was talking to my daughter: mommy and daddy will get older, will you help/support (in Chinese, it’s Yang, same words as raise kids in English) mommy and daddy. Because that word “yang” has same sound as “yang” for “itchy”, she started tickle me. But on a more serious note, she did say she will “wei” (feed) us 🙂

Categories
iPhone app

Two mac tips

Reading Time: < 1 minute

1) This puzzelled me for a while, my macbook air run out of space often. I was trying to use the build “Finder” to find large files, delete files and some unused apps, to no avail. I did some more google and used this Mac App “FindSpace”. And I found this directory /var/vm has some large swap files. Aha. Found the culprit. This article from osxdaily has more explanation.

2) Old Macbook heat. My 3 years old macbook air recently has the problem of overheat. It heated up fairly quickly after using 10 to 15 minutes. Did some google and found this one described my symptom well. The solution appears to be “SMC reset”. I did it yesterday and it works better at least for now…

(01-02-2017) I found chrome can take a lot space too, as well as the iTunes (iPhone) backup file (appears under mobile sync). Also the MacBook Pro retina has similar battery issue (cannot charge), did Smc reset, worked a while. Eventually had to send to Apple Store for a complete fix.

Categories
iPhone app

Three way to create customized input control for UITextField

Reading Time: < 1 minute

Recently I need to create some customized textfield to input numbers and text on iPad. I don’t like the default keyboard on iPad because it takes too much of the screen, and in some cases covers up the input field.

1) From iphonedevsdk: What is proper way to do UITextField text change call back? (this also mentioned by stackoverflow)

[textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventTouchDown];

The downside of this approach is: it takes a press (a tap and hold) to trigger the event.

2) InputView
Create a customized view such as this one at raywenderlich, then set the inputView of textfield. I used this approach to create a number pad that used to only input numbers. There is some limit to this approach as well: the location of customized input view is usually fixed, and in my case (a double picker) for text field (table cell), that is not ideal. I was using pop over controller (again raywenderlich), combined with approach 1, the user does not like the “hold”. After I changed to approach 2, the user does not like the fixed location of input view. So I did more research, and eventually I found the following approach that works for me.

One tip: make sure lock the input view, otherwise it will mess up things after iPad rotation.
– (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return NO;
}

3) self delegate, UITextFieldDelegate

Make sure do this in viewDidLoad (or other place initialize the text field):
myTextField.delegate = self;

This way I could have both “single tap” and the pop over controller.

Categories
Fun

I can repair it

Reading Time: < 1 minute

Our new camry

I was involved into a car accident in the past weekend. We are all fine, so as the other party. The main thing is both cars got some damage. It’s funny when I drove the broken car on the road, I got quite a few “look back” from other drivers. And yesterday, at McDonald parking lot, the lady who looks after the parking lot, said “what happened to your car”. Not to mention, our daughter Serenity volunteered to repair the car.

Last but not least, my wife insisted I declare “Minjie is the one who got involved in the accident” 🙂

Fun aside, we are truly blessed we were not hurt.

Categories
Fun

Some updates for myself and my family

Reading Time: 2 minutes

Have not done this for a while. I have changed job again, and in the new year started a developer position very close to home, doing mobile (iOS, iPhone, iPad) development. I love what I am doing now, because I got opportunity to create an app from back end (database, web service) to front end (iOS UI, local database). At the same time, I have set up the source code control system (SVN), and web server (MS IIS).

My wife started as purchase assistant job at a local manufacturing company, the main task is communicate with Chinese suppliers, involves both Chinese language and mechanical engineering. As I was ME major, I got opportunity to talk to my wife about some of her tasks. Back to ME.

Baby is still a very important part of our life. She grew quite a bit, in terms of language (both Chinese and English), and other skills. We think the Hope Montessori Toddler program (Creve Coeur) helped quite a bit. It helped her be more confident as a person.

In my spare time, I still pay attention to the stock market, US politics, and last but not least, volunteer (serve) in Church. I have a change of heart on politics: in the past I think the government should take care of at least two things: health care and education. Now I think the family and individual should take more responsibility. Also I felt some of the welfare program is not necessarily good for the recipients in the long term. As I read from the news one welfare recipient (woman) is alleged helping her husband kill another person (lady) in Maine. On the tax, it seems local tax is always rising as time goes, and the federal deficit cannot sustain if we don’t raise the overall rate for all the tax payers. The buffett rule (have the rich pay a little more) is just a cup of water on the fire.

Last but not least, we bought a new car (Camry, our first), I like the blue booth audio very much, besides its signature smoothness.

More later…

Categories
iPhone app

Create .NET WCF Restful web service for iOS

Reading Time: < 1 minute

I need to create a .NET web service consumable by iOS device. Did some research and found out WCF Restful service is the way to go. I used the following examples (tutorials) to construct my web service.

0) Basic Resource Service (link here).
This is basically a self hosting web service run in a main program. A good starting point to learn dataContract, webHttp, etc.

1) I need to change from a console app to a web service, and host on IIS, for this refer to
project 1
and
2(Space Service, a WCF web service app)

2) I need to combine 2 services into one program, and I referred to endPoint.tv plural sight podcast “Building RESTfil services with WCF”

The video above mentioned the httputil.js, HTTP POST/PUT utility, which is handy to test “POST” method. Another tool I used to test GET/POST, is “fiddler”.

A Guide to Designing and Building RESTful Web Services with WCF 3.5, also by Aaron Skonnard, Pluralsight

Essentially here we need to design a scheme (end points) for hosting multiple services.

3) Database connection, I used sql client, which is pretty vanilla.

4) Use pretty path instead of port number (routing service, refer to SimpleREST service again)

Also “code project” example
http://www.codeproject.com/Articles/105273/Create-RESTful-WCF-Service-API-Step-By-Step-Guide

Categories
Software development

Some Oracle and Java interview questions

Reading Time: 4 minutes

(Update 02-27-2019) It’s 5 and half years since last update. And two more jobs for me :] Noticed from recent job search in STL, code exercise and code testing (at the spot, pair programming, TDD) is becoming common now in STL, which is unthink of 5.5 years back. I did add a few blog posts on this fronts recently.

Javascript jasmine node.js based testing

Code exercise : linear chamber animation / simulation

Spring, Spring Boot and React

Also, on pure concepts side, Java (J2SE) and J2EE (Spring and Hibernate) are still important and questions were asked around both areas too.

Example questions:
JPA annotations
Hibernate configuration (XML file)
OOP Concepts
Java Interface vs Abstract class (do we need to implement abstract method to use the class)
final finally finalize java
spring model view controller annotation
classpath loading

(Updated 08-31-2013) For those brave hearts venture out the silicon valley/seattle, here is the must-do homework (LeetCode). Chinese version (here and here).

(Original)
Oracle
SQL: Inner join and out join

Function, (stored) procedure and package

What is a trigger in Oracle

“…Oracle lets you define procedures called triggers that run implicitly when an INSERT, UPDATE, or DELETE statement is issued against the associated table or, in some cases, against a view, or when database system actions occur. These procedures can be written in PL/SQL or Java and stored in the database, or they can be written as C callouts.

Triggers are similar to stored procedures. A trigger stored in the database can include SQL and PL/SQL or Java statements to run as a unit and can invoke stored procedures. However, procedures and triggers differ in the way that they are invoked. A procedure is explicitly run by a user, application, or trigger. Triggers are implicitly fired by Oracle when a triggering event occurs, no matter which user is connected or which application is being used…”

A shorter version at orafaq forum

Longer version at orafaq.com/wiki

7. Compare and contrast TRUNCATE and DELETE for a table.
Both the truncate and delete command have the desired outcome of getting rid of all the rows in a table. The difference between the two is that the truncate command is a DDL operation and just moves the high water mark and produces a now rollback. The delete command, on the other hand, is a DML operation, which will produce a rollback and thus take longer to complete.

8. Give the reasoning behind using an index.
Faster access to data blocks in a table.

11. Give some examples of the types of database contraints you may find in Oracle and indicate their purpose.
A Primary or Unique Key can be used to enforce uniqueness on one or more columns.
A Referential Integrity Contraint can be used to enforce a Foreign Key relationship between two tables.
A Not Null constraint – to ensure a value is entered in a column
A Value Constraint – to check a column value against a specific set of values.

DDL vs DML
Data Definition Language (DDL) statements are used to define the database structure or schema. Some examples:
CREATE – to create objects in the database
ALTER – alters the structure of the database
DROP – delete objects from the database
TRUNCATE – remove all records from a table, including all spaces allocated for the records are removed
COMMENT – add comments to the data dictionary
RENAME – rename an object

Data Manipulation Language (DML) statements are used for managing data within schema objects. Some examples:
SELECT – retrieve data from the a database
INSERT – insert data into a table
UPDATE – updates existing data within a table
DELETE – deletes all records from a table, the space for the records remain
MERGE – UPSERT operation (insert or update)
CALL – call a PL/SQL or Java subprogram
EXPLAIN PLAN – explain access path to data
LOCK TABLE – control concurrency

1. Describe the difference between a procedure, function and anonymous pl/sql block. Candidate should mention use of DECLARE statement, a function must return a value while a procedure doesn?t have to.

PL/SQL developer vs. Toad

Reporting
SQL Server Reporting Services (Microsoft); SQL Server Reporting Services (wiki)

Oracle 10g reports (PDF); Oracle Reports Tutorial

LIMS (wiki)

Java
(Updated 08-31-2013) OOPS Interview Questions

Top 20 Core Java Interview questions answers asked in Investment Bank

(Original) 30 Core Java questions (sys-con)

J2EE interview questions (techInterviews.com)

more j2ee interview questions

Java: hashMap and hashTable

Hashtable is synchronized, whereas HashMap is not. This makes HashMap better for non-threaded applications, as unsynchronized Objects typically perform better than synchronized ones.

Difference between Get and Post method on web (link one)

Lazy initialization, dependency injection

3 Things in OO:
data encapsulation, polymorphism, dynamic dispatch (when a method is invoked on an object, the object itself determines what code gets executed by looking up the method at run time in a table associated with the object. This feature distinguishes an object from an abstract data type (or module), which has a fixed (static) implementation of the operations for all instances. It is a programming methodology that gives modular component development while at the same time being very efficient.)

How to use static method? (Include class name)

Aggregation

Throwable interface (exception)

What is reflection

Interface vs. abstract class
non-static method
final: immutable, e.g. String
finalized method

tree-reflection

Categories
Fun

Youyou’s new words

Reading Time: < 1 minute

Last week (Friday), when at friends’ house, and the hostess offered snack, she asked “这是什么呀?(what is this)”?

Today, after we put her to crib, when my wife and I both read iPhone on bed (her crib is next to our bed), she said “在看什么呀?(what are you reading)?”…Later, she also said “what are you doing?”