Categories
iPhone app

Some tips when creating WCF web service for iPad consumption

Reading Time: < 1 minute

Continuation of previous post.

1) WCF get does not like “NULL” column in the query results

2) // note the “id” should match in declaration and method

Categories
Fun

Some thoughts on work, election, and faith

Reading Time: 2 minutes

I changed my job this Jan. I started working for a coal company as mobile app developer. Coal and mobile app (iPhone, iPad) do usually go together in the same sentence, I think. As coal is described as “dirty” in the media, especially by the environmentalists, the “green” people both in and outside government (think Al Gore, president Obama and his EPA commissioner Lisa Jackson). On the other hand, Apple the forerunner of smartphone, tablet revolution is famous for its environment friendly too, just recently they announced initiatives to replace coal powered datacenter by natural gas (they are like tube and box like, think those as natural gas modules). Those are developed by Silicon Valley based start-ups.

Back to topic, for me the rationale of working for coal company goes like this. I am a pragmatist (a pragmatic programmer 🙂 Coal is not the cleanest energy source and not renewable source. But before this year, Coal made up more than 40% if the US power generation (this year the number dropped to lower 30s). So, if one person really wants to make a stand on the issue (instead of just talking like the former vice president does, he got a huge mansion and uses a lot of electricity), the person can simple use 1/3 less of the electricity. That means, uses less light, AC, heat,…in her/his daily life. I am trying to be energy conscious on my life but won’t go as far as cut 1/3 of usage. At the same time, working for a coal company (5 minutes commute time), will help me be a part of the solution (less gasoline for commute for sure). I will be a stake holder in coal mining, as I recently learned, coal mining uses a lot of energy too (diesels, electricity etc.)

I have worked for my new employer for about 9 months, and so far I like what I see. Most recently I went on 2 mines, and met some down-to-earth miners. Since I went to Rolla (the former Missouri School of Mines, miner), now I became a real miner.

Presidential election will play a part in the coal industry too, as the current administration is very coal-unfriendly. I think green (renewable) energy is fine, but the traditional energy source (oil, gas, coal) got to be a part of the solution.

Last but not least, I have 2 scene kinda imprinted in my mind during the mine visit: when I eat the lunch comfortably in the office, I recall the miners eat their lunch in the tunnel. The devotion during lunch time from a few surface miners. In the HQ we sometimes lost touch of the toughness of the front line work. Now I do. At the same time, the company continues to do good things around the community, in all the locations. Here in HQ, we have the united way campaign. In a sense, we are all in one community.

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