Category Archives: Passion

LG G6 review

Just wanted to keep a log of complaints with my LG G6. Things a person wouldn’t know until they buy it.

  • – Default message limit means your messages will start getting automatically deleted in the background after the limit reaches. I’ve lost so much history this way.
  • – No flash on low battery. At least give me the option to use flash in low-battery mode.
  • – Low light or over-sharp photos. This is probably a problem with almost every phone ever.
  • – Android 8 is not coming I think. Promised at launch. It’s been over a year.
  • + Knock to start or wake immediately after it goes dark is awesome.

iPhone vs Android

I’ve used Android phones most of my smartphone life. I started with Google’s G1, then came Google Nexus 5, Google Nexus 5X, Samsung Galaxy, LG G6. I’m very familiar with the Android ecosystem. I’ve dabbled with plenty of ROMs, like CyanogenMod, Cataclysm, etc. Along with my regular smartphone usage, I’ve developed apps for both Android and iOS. My only exposure to iOS has been an iPod Touch before smartphone days and my development experience with the emulators

Recently, I was given the opportunity to use an iOS device, iPhone SE, since MetroPCS offered free ones on no-contract signup. I figured I should give it a shot for a few months. I want to detail some pros and cons for both ecosystems.

Android:

  • + More customizable: the home screen, widgets, launcher, unknown source apps, etc.
  • + Better notifications system. Ability to dismiss things easily enough compared to iOS. Notification groupings! Reply within notifications. Etc!
  • + Awesome integrations with lots of password managers. Personally I prefer LastPass to keep them synchronized with all my devices.
  • + Change default apps for anything.
  • + Consolidated Google Now to keep up with appointments, shipments, NBA/NFL scores, news. Automatically pieced together from my emails.
  • + Google Assistant able to pick up any accent you can throw at it. My family has thick Punjabi/Indian accents.
  • – Slow and inconsistent apps. Seem like second citizens compared to iOS apps from the same brands/app-makers.

iOS

  • + Faster apps loads with better graphics
  • + Smooth camera operation
  • – Annoying notifications seem to never go away. Tough to dismiss all of them.
  • – No integration with password managers like LastPass. Each app has to subscribe to specific password managers. In other words, no app ever happens.
  • – Limited browsers. Every browser runs the Webkit backend, so if a website is broken in your browser, you’re out of luck.
  • – Default iOS keyboard has no swiping. And it will keep coming up for apps that don’t want to use custom keyboards (i.e. Contacts, almost all the iOS apps, any financial app, logins/passwords). Inconsistent and NO thanks!!!

TLDR: I can’t wait to go back to my “slow yet complete” smartphone that is Android.

Things learned from Wordcamp 2012

I attended most of the developer track presentations at Boston’s Wordcamp 2012. I learned about some interesting tools and techniques that I’d like to document for myself and others.

Talk Optimizing for Speed by Ben Metcalfe

  1. YouGetSignal’s Reverse IP Lookup – Shows you how many other hosts live on the same IP Address. This can be helpful for anyone using shared hosting or maybe VPS.
  2. Debug Bar – Get debugging information from each page WordPress page load.
  3. Google XML Sitemaps – Delete this plugin if you have it. (I had it.)
  4. YSlow – Get load times and optimization tips of a page request.

WordPress as a Web Framework by Sam Hotchkiss

  1. MVC frameworks for WordPress
    1. WP MVC – Provides a singleton object and eliminates the metadata bottleneck by providing tables indexed by post IDs.
    2. Tina MVC
  2. _s Theme – Use Automattic’s Blank Theme as a good starting point.

Automating frontend workflow by Aaron Jorbin (blog post, slides)

  1. Autojump – Jump to frequently used directories
  2. Commander.js (nodejs) – Script working with CLI
  3. watch (nodejs) – Watch files/dirs
  4. mockjax – Fake your ajax calls (good for protyping or testing un-related, yet dependent functionality)
  5. Travis CI – continuous integration service (wordpress plugin tests)
  6. Glue – generate css sprites

Microdata for SEO by Dave Ross

  1. Add itemprop, itemscope, etc to any identifiable schema
  2. Google Rich Snippets Tool – Test your microdata
  3. Examples: SiteNavigation element for navigation, Blog element for blog posts, etc
  4. Some quick tidbits: Bing rates sites with microdata higher than sites without, and Google uses the microdata in search results

Enterprise WordPress by Jake Goldman (1up)

  1. Sites to show clients: showcase, WordPress VIP
  2. Maintaining a beautiful WordPress admin

Shortcodes by Jon Bishop

  1. Use oembed rather than plugins to support embedding media from sites like youtube, facebook, etc

Codex by Erick Hitler

  1. Use santize_* functions to save to db: santize_text_field(), sanitize_title()
  2. Use esc_* functions to show data to user (esc_url_raw() is the exception, it is the opposite of esc_url())

Javascript hooks by Luke Gedeon (1up)

  1. Javascript custom events are coming, they will provide functionality similar to WordPress’ action and filter hooks (list of hooks)

Command line python script to get context lines on a search string

grep -B and -B flags don’t work when grep is used on the command line with readline support. So I created this little script that does work on the command line. use -h flag to learn. Here’s how I’ve used it:

ls -al | ./printcontext.py -b 1 -a 1 -d test.txt

This finds the test.txt file and prints the 2 files around it.


#!/usr/bin/python
# print context when using a python script with readline support (command line piping)
# by inderpreetsingh.com

import sys, re
from optparse import OptionParser

def main():
    usage = "usage: %prog [options] needle"
    parser = OptionParser(usage)
    parser.add_option("-b", "--before", type="int", dest="before", default=0,
            help='Before context lines (a la grep)')
    parser.add_option("-a", "--after", type="int", dest="after", default=0,
            help='After context lines')
    parser.add_option("-d", "--debug", action="store_true", dest="debug", default=False,
            help='Debug information.')

    #Not implemented
    #parser.add_option("-o", "--output", type="string", dest="output")
    
    (options, args) = parser.parse_args()
    
    if len(args) != 1:
        parser.error("Specify what you want to search")
    
    needle = args[0]
    if options.debug:
        print "\nNeedle: %s\nBefore context lines: %s\nAfter context lines: %s\n" % (needle, options.before, options.after)
    

    lines = sys.stdin.readlines()
    lines = [x.strip() for x in lines]
    
    lastline = ''
    i = 0
    for line in lines:
        if needle in line:
#        if re.search(needle, line):
            first = max(0, i - options.before)
            last = min(len(lines), i + options.after + 1)
            
            if options.debug:
                print "Found '%s' on line %d, printing line %d to %d" % (needle, i, first, last)
                
            for println in lines[first:last]:
                print println
            print ""
        lastline = line
        i += 1

if __name__ == "__main__":
    main()

Include admin scripts/styles in WordPress plugin

There are two ways of including custom scripts/styles in an admin page for a WordPress 3 plugin.

Solution 1 (Deprecated):


$slug = add_submenu_page('myplugin.php', 'My Plugin', 'My Plugin', 'upload_files', __FILE__, 'myplugin_options');

add_action('admin_print_scripts-'. $slug, 'myplugin_enqueue_admin_scripts');
add_action('admin_print_styles-'. $slug, 'myplugin_enqueue_admin_styles');

function myplugin_enqueue_admin_scripts($suffix) {
	$plugin_path = plugin_dir_url(__FILE__) . 'resources/';
	wp_enqueue_script('jquery.js', $plugin_path . 'jquery.pack.js');
}

function myplugin_enqueue_admin_styles($suffix) {
	$plugin_path = plugin_dir_url(__FILE__) . 'resources/';
	wp_enqueue_style('jquery.css', $plugin_path . 'jquery.css');
}

Solution 2 (recommended):

$slug = add_submenu_page('myplugin.php', 'My Plugin', 'My Plugin', 'upload_files', __FILE__, 'myplugin_options');

add_action('admin_enqueue_scripts', 'myplugin_enqueue_admin_scripts');


function myplugin_enqueue_admin_scripts($hook_suffix) {
	if ($hook_suffix == 'myplugin/slug') {
		$plugin_path = plugin_dir_url(__FILE__) . 'resources/';
		wp_enqueue_script('jquery.js', $plugin_path . 'jquery.pack.js');
		wp_enqueue_style('jquery.css', $plugin_path . 'jquery.css');
	}
}