Posts

Configure Linksys WRT400N as an access point

The WRT400N is a rather basic router so I use another router with more memory and a faster processor to connect to the internet. I had originally configured the 400N on its own subnet. Today I tried configuring it to be on the same subnet as my main router. I found useful advice here: http://homecommunity.cisco.com/t5/Wireless-Routers/How-to-configure-WRT400n-as-an-access-point/m-p/277101/highlight/true#M144970 To summarize: Turn off DHCP Server on the 400N  still want the 400N to get it's IP via DHCP  Turn of NAT and the stateful fire wall settings  not sure this is essential after you move the Ethernet cable below.  NAT is in Setup, Advanced Routing  Stateful fire wall is in Security as SPI Firewall protection  be sure the Network Setup shows the same subnet mask as your main router.  I set the IP address to the address reserved for the 400N on the other router.  some suggest using a class C address you are _not_ using.  save your setting...

Change two colors by percentage

In Android, it is not good when most of the views has alpha value. Therefore, it is better by changing color of the view. Below is the color interplation between a and b with given proportion: private float interpolate(float a, float b, float proportion) { return (a + ((b - a) * proportion)); } /** Returns an interpoloated color, between a and b */ private int interpolateColor(int a, int b, float proportion) { float[] hsva = new float[3]; float[] hsvb = new float[3]; Color.colorToHSV(a, hsva); Color.colorToHSV(b, hsvb); for (int i = 0; i < 3; i++) { hsvb[i] = interpolate(hsva[i], hsvb[i], proportion); } return Color.HSVToColor(hsvb); } Thanks to: http://stackoverflow.com/questions/4414673/android-color-between-two-colors-based-on-percentage

Change XML Layout automatically when orientation happens

Image
Most of Android developers know that Android has lots of unique and useful features. One of them is changing the layout based on current orientation. But it seems that it is not easy to manage what to do before and after changing the layout. Before manage/control the layout, you must have two layouts, landscape (in layout-land/ folder) and portrait (in layout/ folder). Then, we start to manage/control the layouts. If you don't want to manage/control all stuffs, just let Android do it for you, by doing: Remove android:configChanged="orientation" of your activity. This will cause that you don't receive onConfigurationChanged event. By doing this, there are some pros and cons: Pros: Android will reset the ContentView when onConfigurationChanged (we can't see it anymore). We just prepare the layouts easily. Cons: All parameters/properties will be reset when Android resets the ContentView. In the first step, it is hard to ...

Customize view using XIB

Image
This is the example of how to customize UITableViewCell using XIB. 1. Create your XIB: 2. Load XIB and create it as a view: 3. Done

Force using english localized if current localized does not exists

Create a class: CLocale.h #undef NSLocalizedString#define NSLocalizedString(key, comment) \ [CLocale localizedString:(key)] @interface CLocale : NSObject + (NSString*) localizedString:(NSString*)key; @end CLocale.m #import "CLocale.h" @implementation CLocale + (NSString*) localizedString:(NSString*)key { NSArray* languages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"]; NSString* currentLocale = [languages objectAtIndex:0]; NSString* localized = [[NSBundle mainBundle] localizedStringForKey:key value:@"" table:nil]; // if key and localized are same, also it is not english, // then force to use english language if ([localized compare:key] == NSOrderedSame && [currentLocale compare:@"en"] != NSOrderedSame) { NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"en" ofType:@"lproj"]]; localized = NSLocalizedStringFro...

What should every programmer know about web development?

The idea here is that most of us should already know most of what is on this list. But there just might be one or two items you haven't really looked into before, don't fully understand, or maybe never even heard of. Interface and User Experience Be aware that browsers implement standards inconsistently and make sure your site works reasonably well across all major browsers. At a minimum test against a recent  Gecko  engine ( Firefox ), a WebKit engine ( Safari ,  Chrome , and some mobile browsers), your supported  IE browsers  (take advantage of the  Application Compatibility VPC Images ), and  Opera . Also consider how  browsers render your site  in different operating systems. Consider how people might use the site other than from the major browsers: cell phones, screen readers and search engines, for example. — Some accessibility info:  WAI  and  Section508 , Mobile development:  MobiForge . S...

Cannot drop index needed in a foreign key constraint

When you receive the message "MySQL Cannot drop index needed in a foreign key constraint" You have to drop the foreign key. Foreign keys in MySQL automatically create an index on the table (There was a SO Question on the topic). ALTER TABLE mytable DROP FOREIGN KEY mytable_ibfk_1; Then, try again! http://stackoverflow.com/questions/8482346/mysql-cannot-drop-index-needed-in-a-foreign-key-constraint