スキップしてメイン コンテンツに移動

投稿

5月, 2014の投稿を表示しています

Quick Tip for avoid trouble on Internet Explore Document Mode

When I was writing my post using IE, pls don't ask why I don't use Chrome :), I suddenly realized the document of my IE is 7 !! I launched Developer Tool by pressing F12 button, and tried to force document mode to &quotEdge&quot. However somehow when I loaded my blogspot again, it was soon back to IE7 mode :\ I investigated for a while and found that the cause was meta tag on my blog page! See below! <meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible'/> I deleted above line on my blog template, the browser use &quotEdge&quot document mode by default.

Check Black List Words in Files by Bash Script

I wrote tiny bash script for checkin files contains black listed words or not. The aim of this script is to automate verifying php or javascript files does not have any debugging code, such as "var_dump","alert" etc. #!/bin/bash PHP_BLACK_LIST_WORDS=("var_dump(") JAVASCRIPT_BLACK_LIST_WORDS=("alert(") verify_words_are_not_contained(){ words="$1" len=${#words[@]} if [ $len -ge 0 ] then grep_words="" for word in "${words[@]}" do grep_words+="$word\|" done # remove last 2 characters grep_words=${grep_words%?} grep_words=${grep_words%?} grep_command="grep \"$grep_words\" $2 -nr --include=$3 > $OUTPUT_DIR/$4" echo "running $grep_command" eval $grep_command fi } setup_output_dir(){ target_dir_name=${1##*/} OUTPUT_DIR=$target_dir_name"_detected_black_list_words" echo "$OUTPUT_DIR" rm -r -f

Loading Javascript On Demand (When User Click Button etc.)

Recently, everyone must know placing js script tag at the bottom of html or using "async" attribute so that the page can be rendered not blocked by the scripts loading or excecution. In this post, I will exaplain how to load javascript on demand - e.g. event based. The technique is applicable when javascript is loaded only for a event - like after click button. The usecase might be limited and code becomes a bit complicated so I suggest you should only use this technique at the situation: The script doesn't have to be loaded on user' initial page load. The script is loaded only when user do some interaction on the page - like click button, etc. Most user doesn't trigger the event. That is, if most user trigger the event, then you should simply write script tag. Ok, then now I will show you the code and demo. $(function(){ var scriptLoaded = false; $("#load_button").click(function (){ if (!scriptLoaded) { sc

Loading Facebook Like Button Faster

In this post, I will explain how to load facebook like button faster. The Official Method Explained on Facebook The official method to load Facebook Button for HTML5 is below. There is another option - using iframe. See below. In my experience, using iframe is relatively faster than using HTML5. I think it's because if we use the HTML5 method, the facebook javascript SDK should be loaded before rendering the like button. Actually, this is important fact, even if you choose the html5 way to load like button, the loaded like button is iframe in the end. So question comes up - "What about load iframe like button manually by my self wrinting javascript?". Loading ifram Like Button by Javascript The below code shows loading iframe like button by javascript. To be honest nothing special at all - create iframe like button and append it to html by javascript. $(function(){ $("#fblike").append(createLike("http://dukesoftware00.blogspot.com"

Java: Create Indexed PNG Image Using Standard Java Image API

Hello guys! I have written Java: How to Create Indexed PNG Using PNGJ Library a few years ago. Recently I investigated how to create indexed png by standard Java image API. I have googled and tested various methods, finally I figureed out how to create indexed png image. Still my program is not perfect (of course most of the case it worked well), I believe that this program gives you the hint to creating indexed png and image manipulation on standard Java API. Code Actually the method is quite straigt forward. Please see the code below :) The advantedge of this code is the code doesn't require any library. The code below contains all of the stuffs needed for creating indexed png image! package com.dukesoftware.util.image; import java.awt.color.ColorSpace; import java.awt.image.BufferedImage; import java.awt.image.ColorConvertOp; import java.awt.image.ColorModel; import java.awt.image.DataBuffer; import java.awt.image.IndexColorModel; import java.io.File; import java.

Bash Script: Convert File Extension Lower Case

I wrote a small bash script for converting file extension to lower. #!/bin/bash PATH="/somwhere_in_the_world/" EXTS=("jpg" "gif" "png") for ((I=0; I<${#EXTS[@]}; ++I )) do FILES=`find $PATH ! -type f -iname "*."${EXTS[$I]}`; for FILE in $FILES; do FNAME=`expr $FILE : '\(.*\)\.\w\+'` LOWER=$FNAME"."${EXTS[$I]} if [ $FILE != $LOWER ]; then mv $FILE $LOWER echo "$FILE converted to lower case."; fi; done; done;