RSS
 

Debugging Javascript on Android

25 Apr

Debugging webpages on Android has been a notoriously tedious task for developers. The lack of a console makes simple debugging very difficulty.

Fortunately, Android 4.0 (Ice Cream Sandwich) now offers access to the JavaScript console. Simply type in the address bar: about:debug and a console will be displayed over top your webpage. Finally!

Related Tweets

view search results for "Android console" on twitter
 

Force www to your domain

17 Mar

If you have domain.com, it might be preferable if all your users are on www.domain.com.

There are a few reasons why one would want to force redirection to www:

  • Cosmetic reasons. Some people just prefer to reinforce the www part of the domain, especially for branding purposes
  • Scripts and cookies. Sometimes you’ll run into issues if your visitor interchanges between domain.com and www.domain.com
  • Consistency. It just looks better if your visitor doesn’t see both www.domain.com and domain.com
  • Third party tools. If you’re trying to authenticate a user via Facebook, and you provide http://domain.com as your url, and a user arrives via http://www.domain.com it will give you issues or not even work. Marketing affiliates such as TrialPay will also see http://domain.com and http://www.domain.com as different domains and will cause 4 or 5 days of endless issues.

Whatever the reason, if you want to force users to stick to www.domain.com and you’re using Apache, you will need to modify your .htaccess to include the following:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]


With nginx, you would add the following to your configuration file:

# Add a www with this block
server {
listen 80;
server_name domain.com;
rewrite ^(.*)$ $scheme://www.domain.com$1;
}

Related Tweets

view search results for "the htaccess" on twitter
 

Running a web server locally – can’t start apache?

14 Mar

I was recently stuck trying to figure out why my local apache instance was not starting. I changed the port that it listened to from 80 to 8080 to 8001, and no luck. After running “netstat -ano” from the command line, I could see an application was listening to port 443, which is required for https. After enabling the PID column in Task Manager (View->Select Columns…), I was able to see which application corresponded to the PID that netstat was reporting, and it turned out to be Skype. After exitting Skype, I tried to start apache again and it worked! So just something to keep in mind, not just port 80 but port 443 have to be open and Skype listens on that port.

 
 

My Twitter Account as a Wordle

10 Mar

My Twitter Account as a Wordle

 
 

Javascript – Dropping the last parts of an array and randomizing the order of an array

14 Feb

Let’s say you have an array with 15 elements, and you only want it to contain the first 10 elements, you can literally just change the length to 10 and Javascript will drop the last 5 elements and resize your array.

myArray.length = 10; // anything after the 10th element will be removed.

Also, if you need to randomize the order of an array, the following does the trick:

myArray.sort(function(a, b) {
return Math.random() - 0.5;
})

Related Tweets

view search results for "javascript arrays" on twitter
 

locate and updatedb where you don’t have admin priviledges

10 Feb

Sometimes I need the locate command to work, even if it’s only for areas accessible to me. To use locate, you need to call updatedb at least once, which fails since it usually writes to an area you don’t have permission for.

The way to get around it is to have the updatedb database file be written to an area that is accessible by you, like this:
updatedb --output=~/updatedb.db
This puts the db in your home directory.
Then you can call locate this way:
locate --database=updatedb.db
You can even put this into a bash script so you don’t need to add the –database flag every time.

Related Tweets

view search results for "linux updatedb" on twitter
 
No Comments

Posted in Linux

 

Android Image Maps by @tofuejoe

04 Feb

If you ever need to implement “image map” like functionality that mimics HTML’s image map, Scott Lund has a great library that allows you to implement an image map directly into your apps. It’s regularly updated by the author himself. Anyway head over here if you’re interested:

Android Image Maps

 

Modifying hosts file for Android devices

15 Jan

If you need to modify the Android hosts file on your device, three things need to happen:

1) Your phone must be rooted. I won’t go into the details here, but you can google it to find out how you can do it for your phone/tablet.
2. At this point, your file system has to be set to be read/write enabled (as opposed to read only). From your command line/terminal application, type the following (after plugging in your phone via USB of course):

adb shell
su
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system

3. You can now use vi to modify /system/etc/hosts, but if you’re using a Windows device, vi won’t display properly in the default CMD program. What you can do is create a hosts file on your machine, then copy it over to your android device with the following:

adb push hosts /system/etc/hosts

Related Tweets

view search results for "Android linux" on twitter
 

Weird MySQL Workbench issue with Enums

09 Jan

If you try to add an Enum field when creating a table through MySQL workbench, it will repeatedly fail if you put a space between the comma seperator.

ENUM(‘active’, ‘disabled’) fails and returns the column type back to the default of VARCHAR(45).
ENUM(‘active’,'disabled’) works.

Related Tweets

view search results for "Mysql Workbench" on twitter
 
No Comments

Posted in MySQL

 

Companies that support SOPA

30 Dec

Now that GoDaddy has rescinded its support of the draconian Stop Online Piracy Act (SOPA), it is interesting to see what companies are still in support. Below is the U.S. Congressional list of Stop Online Piracy Act (SOPA) supporters. Some of these supporters make sense (Content holders such as BMI, CBS, ESPN or even MLB) and some are just… weird? Americans for Tax Reform, I’m looking at you.

http://judiciary.house.gov/issues/Rogue%20Websites/List%20of%20SOPA%20Supporters.pdf

60 Plus Association
ABC
Alliance for Safe Online Pharmacies (ASOP)
American Bankers Association (ABA)
American Federation of Musicians (AFM)
American Federation of Television and Radio Artists (AFTRA)
American Society of Composers, Authors and Publishers (ASCAP)
Americans for Tax Reform
Artists and Allied Crafts of the United States
Association of American Publishers (AAP)
Association of State Criminal Investigative Agencies
Association of Talent Agents (ATA)
Beachbody, LLC
BMI
BMG Chrysalis
Building and Construction Trades Department
Capitol Records Nashville
CBS
Cengage Learning
Christian Music Trade Association
Church Music Publishers’ Association
Coalition Against Online Video Piracy (CAOVP)
Comcast/NBCUniversal
Concerned Women for America (CWA)
Congressional Fire Services Institute
Copyhype
Copyright Alliance
Coty, Inc.
Council of Better Business Bureaus (CBBB)
Council of State Governments
Country Music Association
Country Music Television
Creative America
Deluxe
Directors Guild of America (DGA)
Disney Publishing Worldwide, Inc.
Elsevier
EMI Christian Music Group
EMI Music Publishing
Entertainment Software Association (ESA)
ESPN
Estée Lauder Companies
Fraternal Order of Police (FOP)
Gospel Music Association
Graphic Artists Guild
Hachette Book Group
HarperCollins Publishers Worldwide, Inc.
Hyperion
Independent Film & Television Alliance (IFTA)
International Alliance of Theatrical and Stage Employees (IATSE)
International AntiCounterfeiting Coalition (IACC)
International Brotherhood of Electrical Workers (IBEW)
International Brotherhood of Teamsters (IBT)
International Trademark Association (INTA)
International Union of Police Associations
L’Oreal
Lost Highway Records
Macmillan
Major County Sheriffs
Major League Baseball
Majority City Chiefs
Marvel Entertainment, LLC
MasterCard Worldwide
MCA Records
McGraw-Hill Education
Mercury Nashville
Minor League Baseball (MiLB)
Minority Media & Telecom Council (MMTC)
Motion Picture Association of America (MPAA)
Moving Picture Technicians
MPA – The Association of Magazine Media
National Association of Manufacturers (NAM)
National Association of Prosecutor Coordinators
National Association of State Chief Information Officers
National Cable & Telecommunications Association (NCTA)
National Center for Victims of Crime
National Crime Justice Association
National District Attorneys Association
National Domestic Preparedness Coalition
National Football League
National Governors Association, Economic Development and Commerce Committee
National League of Cities
National Narcotics Offers’ Associations’ Coalition
National Sheriffs’ Association (NSA)
National Songwriters Association
National Troopers Coalition
News Corporation
Pearson Education
Penguin Group (USA), Inc.
Pharmaceutical Research and Manufacturers of America (PhRMA)
Pfizer, Inc.
Provident Music Group
Random House
Raulet Property Partners
Republic Nashville
Revlon
Scholastic, Inc.
Screen Actors Guild (SAG)
Showdog Universal Music
Sony/ATV Music Publishing
Sony Music Entertainment
Sony Music Nashville
State International Development Organization (SIDO)
The National Association of Theatre Owners (NATO)
The Perseus Books Groups
The United States Conference of Mayors
Tiffany & Co.
Time Warner
True Religion Brand Jeans
Ultimate Fighting Championship (UFC)
UMG Publishing Group Nashville
United States Chamber of Commerce
United States Olympic Committee
United States Tennis Association
Universal Music
Universal Music Publishing Group
Viacom
Visa Inc.
W.W. Norton & Company
Wallace Bajjali Development Partners, L.P.
Warner Music Group
Warner Music Nashville
Wolters Kluewer Health
Word Entertainment