[iOS] UIWebView Helper Methods Inject JavaScript and Meta to HTML

One thing you should keep in mind is DO Call these Methods when your UIWebView Complete Loading.


-(void)webViewDidFinishLoad:(UIWebView *)webView{
    
    NSString *jqueryPath = [[NSBundle mainBundle] pathForResource:@"jquery" ofType:@"js" inDirectory:@"webview/js/"];
    NSURL *url = [NSURL fileURLWithPath:jqueryPath];
    [self addScriptSRC:url.absoluteString toWebView:webView];
    
    NSString *manuJSPath = [[NSBundle mainBundle] pathForResource:@"someother_javascript" ofType:@"js" inDirectory:@"webview/js/"];
    NSURL *manu_url = [NSURL fileURLWithPath:manuJSPath];
    [self addScriptSRC:manu_url.absoluteString toWebView:webView];
    
    [self addDefaultUserScalableTwiceMeta2WebView:webView];
    
//    NSString *html = [webView stringByEvaluatingJavaScriptFromString:
//                      @"document.getElementsByTagName('head')[0].innerHTML"];
//
//    NSLog(@"html:\n%@",html);
    
}




-(void)addScript:(NSString *)scriptString toWebView:(UIWebView *)aWebView{

NSString *execStr = [NSString stringWithFormat:@"var script = document.createElement('script');"

"script.type = 'text/javascript';"

"script.text = \"%@\";"

"document.getElementsByTagName('head')[0].appendChild(script);",scriptString];

[aWebView stringByEvaluatingJavaScriptFromString:execStr];

//    NSString *html = [aWebView stringByEvaluatingJavaScriptFromString:

//                      @"document.getElementsByTagName('head')[0].innerHTML"];

//

//    NSLog(@"html:\n%@",html);

}

 

-(void)addScriptSRC:(NSString *)scriptPathString toWebView:(UIWebView *)aWebView{

NSString *execStr = [NSString stringWithFormat:@"var script = document.createElement('script');"

"script.type = 'text/javascript';"

"script.src = \"%@\";"

"document.getElementsByTagName('head')[0].appendChild(script);",scriptPathString];

[aWebView stringByEvaluatingJavaScriptFromString:execStr];

}

/*

*

*  Add Default Meta to HTML Head Element

*

*

*  Default Value:

*

*   'name', 'viewport'

*   'content':'width=100%; minimum-scale=1.0; maximum-scale=2.0; user-scalable=yes'

*

*

*/

 

-(void)addDefaultUserScalableTwiceMeta2WebView:(UIWebView *)aWebView{

// @"<meta name=\"viewport\" content=\"width=100%; minimum-scale=1.0; maximum-scale=1.0; user-scalable=no\">";

NSString *addMetaElementJS =

@"var meta = document.createElement('meta'); " \

"meta.setAttribute( 'name', 'viewport' ); " \

"meta.setAttribute( 'content', 'width=100%; minimum-scale=1.0; maximum-scale=2.0; user-scalable=yes' ); " \

"document.getElementsByTagName('head')[0].appendChild(meta)";

[aWebView stringByEvaluatingJavaScriptFromString:addMetaElementJS];

}

 

/*

*      'name'='viewport'

'content'='width=100%; minimum-scale=1.0; maximum-scale=2.0; user-scalable=yes'

*

*/

-(void)addMetaElementName:(NSString *)name content:(NSString *)content toWebView:(UIWebView *)aWebView{

if (name == nil || [name isEqualToString:@""]) {

return;

}

if (content == nil || [content isEqualToString:@""]) {

return;

}

NSString *addMetaElementJS = [NSString stringWithFormat:

@"var meta = document.createElement('meta'); " \

"meta.setAttribute( 'name', '%@' ); " \

"meta.setAttribute( 'content', '%@' ); " \

"document.getElementsByTagName('head')[0].appendChild(meta)",name,content,nil];

[aWebView stringByEvaluatingJavaScriptFromString:addMetaElementJS];

}

Howto write a WordPress Plugin

http://codex.wordpress.org/Writing_a_Plugin

http://pelfusion.com/20-tutorials-to-develop-wordpress-plugin/

http://hardcorewp.com/2012/how-to-write-a-basic-wordpress-plugin/

http://www.devlounge.net/extras/how-to-write-a-wordpress-plugin

 

 

WordPress plugin developers are earning good amount online. Most of them release two versions of plugin, one is free version and other is premium with some enhanced features. If you are new to plugin development or want to extend your experience this article is best for you.

WordPress has become more important application for bloggers and even for those who need small web site. To extend its functionality beyond the basic features there are too many plugins. You can do almost anything with WordPress using different plugins. If you are a developer you can develop your own plugin or use plugins developed by others.

I have compiled 20 tutorials for developers to know how to develop wordpress plugin.

1. WP Tutorial: Your First WP Plugin

Here it is, a video guide to creating your first WordPress plugin (in under 5 minutes!).

First WP Plugin

2. How to Create a WordPress Plugin

Writing your own WordPress plugin is not that difficult if you are a web developer with basic PHP skills.

Create a WP Plugin

3. How to Write a WordPress Plugin – Introduction

For any WordPress user, plugins are essential. WordPress Plugins allow those with little to no programming skills to extend the functionality of their blog.

Write a WordPress Plugin

4. Create a Custom WordPress Plugin From Scratch

This tutorial will describe the implementation of a WordPress plugin starting from scratch. The plugin will connect to an external OSCommerce database and display random products on your WordPress site.

Custom WordPress Plugin

5. Anatomy of a WordPress Plugin

This tutorial will guide you through every step of building a simple, widgetized WordPress plugin with settings.

Anatomy of WordPress Plugin

6. A Crash-Course in WordPress Plugin Development

Despite an extensive codex, many WordPress users remain unfamiliar with how to create their own custom plugins. In today’s screencast, we’ll start from scratch and build our first usable plugin.

Crash-Course in WP Plugin Development

7. WordPress Plugin Development Short Tutorial

A short video tutorial on wordpress plugin development.

Plugin Development Short Tutorial

8. WordPress Plugin Tutorial – Hello World

Learning to develop a WordPress plugin can be both fun and rewarding. In this Tutorial we will go over how to make a simple Hello World plugin that you can create.

Hello World Tutorial

9. The Ultimate Guide to Building a WordPress Plugin

There are often plugins created for basic extended functionality, but what happens when you can’t find the perfect plugin for your needs? It might be easier to just create the plugin yourself.

Ultimate Guide to Building WP Plugin

10. Beginner’s Guide To WordPress Plugin Development

The steps in this tutorial are fairly simple and don’t require a large dedication to study.

Beginner’s Guide To WordPress Plugin Development

11. WorPress Plugin Development with PHP

Nice video tutorial on plugin development.

Plugin Development with PHP

12. How to Create WordPress Plugin from Scratch

In this tutorial you will learn how to create a wordpress plugin from scratch.

Create WordPress Plugin from Scratch

13. Seven Reasons to Write a WordPress Plugin

Listed below are seven reasons why a WordPress user should consider writing a WordPress plugin.

Seven Reasons to Write WP Plugin

14. WordPress Plugin Actions

An example of an action would be that you want a execute some code after a user has published a post or left a comment.

WordPress Plugin Actions

15. WordPress Plugin Filters

WordPress filters allow to you modify virtually any kind of text displayed and are extremely powerful.

Plugin Filters

16. Constructing a WordPress Plugin Admin Panel

This tutorial will go into what it takes to successfully create an admin panel for your plugin.

Construct a WP Plugin Admin Panel

17. Constructing a WordPress Plugin User’s Panel

This tutorial will go over the steps to add in your own User’s Administration Panel.

Construct a User’s Panel

18. Using JavaScript and CSS with your WordPress Plugin

This portion of the series will cover how to load JavaScript and CSS files for your plugin.

Using JavaScript and CSS

19. Using AJAX with your WordPress Plugin

This post will show you how to use AJAX with your WordPress plugin.

Using Ajax with WP Plugin

20. Releasing and Promoting Your WordPress Plugin

After you have finished writing your awesome WordPress plugin, there are a few things to consider before releasing and promoting your WordPress plugin.

Releasing and Promoting the Plugin

HTML Escape Characters: Complete List

HTML Escape Characters: Complete List

Symbol Code Entity Name
™
€
Space    
! !
" "
# #
$ $
% %
& & &
'
( (
) )
* *
+ +
, ,
-
. .
/ /
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
: :
; &#59;
< &#60; &lt;
= &#61;
> &#62; &gt;
? &#63;
@ &#64;
A &#65;
B &#66;
C &#67;
D &#68;
E &#69;
F &#70;
G &#71;
H &#72;
I &#73;
J &#74;
K &#75;
L &#76;
M &#77;
N &#78;
O &#79;
P &#80;
Q &#81;
R &#82;
S &#83;
T &#84;
U &#85;
V &#86;
W &#87;
X &#88;
Y &#89;
Z &#90;
[ &#91;
\ &#92;
] &#93;
^ &#94;
_ &#95;
` &#96;
a &#97;
b &#98;
c &#99;
d &#100;
e &#101;
f &#102;
g &#103;
h &#104;
i &#105;
j &#106;
k &#107;
l &#108;
m &#109;
n &#110;
o &#111;
p &#112;
q &#113;
r &#114;
s &#115;
t &#116;
u &#117;
v &#118;
w &#119;
x &#120;
y &#121;
z &#122;
{ &#123;
| &#124;
} &#125;
~ &#126;
Non-breaking space &#160; &nbsp;
¡ &#161; &iexcl;
¢ &#162; &cent;
£ &#163; &pound;
¤ &#164; &curren;
¥ &#165; &yen;
¦ &#166; &brvbar;
§ &#167; &sect;
¨ &#168; &uml;
© &#169; &copy;
ª &#170; &ordf;
« &#171;
¬ &#172; &not;
­ &#173; &shy;
® &#174; &reg;
¯ &#175; &macr;
° &#176; &deg;
± &#177; &plusmn;
² &#178; &sup2;
³ &#179; &sup3;
´ &#180; &acute;
µ &#181; &micro;
&#182; &para;
· &#183; &middot;
¸ &#184; &cedil;
¹ &#185; &sup1;
º &#186; &ordm;
» &#187; &raquo;
¼ &#188; &frac14;
½ &#189; &frac12;
¾ &#190; &frac34;
¿ &#191; &iquest;
À &#192; &Agrave;
Á &#193; &Aacute;
 &#194; &Acirc;
à &#195; &Atilde;
Ä &#196; &Auml;
Å &#197 &Aring;
Æ &#198; &AElig;
Ç &#199; &Ccedil;
È &#200; &Egrave;
É &#201; &Eacute;
Ê &#202; &Ecirc;
Ë &#203; &Euml;
Ì &#204; &Igrave;
Í &#205; &Iacute;
Î &#206; &Icirc;
Ï &#207; &Iuml;
Ð &#208; &ETH;
Ñ &#209; &Ntilde;
Ò &#210; &Ograve;
Ó &#211; &Oacute;
Ô &#212; &Ocirc;
Õ &#213; &Otilde;
Ö &#214; &Ouml;
× &#215; &times;
Ø &#216; &Oslash;
Ù &#217; &Ugrave;
Ú &#218; &Uacute;
Û &#219; &Ucirc;
Ü &#220; &Uuml;
Ý &#221; &Yacute;
Þ &#222; &THORN;
ß &#223; &szlig;
à &#224; &agrave;
á &#225; &aacute;
â &#226; &acirc;
ã &#227; &atilde;
ä &#228; &auml;
å &#229; &aring;
æ &#230; &aelig;
ç &#231; &ccedil;
è &#232; &egrave;
é &#233; &eacute;
ê &#234; &ecirc;
ë &#235; &euml;
ì &#236; &igrave;
í &#237 &iacute;
î &#238; &icirc;
ï &#239; &iuml;
ð &#240; &eth;
ñ &#241; &ntilde;
ò &#242; &ograve;
ó &#243; &oacute;
ô &#244; &ocirc;
õ &#245; &otilde;
ö &#246; &ouml;
÷ &#247; &divide;
ø &#248; &oslash;
ù &#249; &ugrave;
ú &#250; &uacute;
û &#251; &ucirc;
ü &#252; &uuml;
ý &#253; &yacute;
þ &#254; &thorn;
ÿ &#255;
Ā &#256;
ā &#257;
Ă &#258;
ă &#259;
Ą &#260;
ą &#261;
Ć &#262;
ć &#263;
Ĉ &#264;
ĉ &#265;
Ċ &#266;
ċ &#267;
Č &#268;
č &#269;
Ď &#270;
ď &#271;
Đ &#272;
đ &#273;
Ē &#274;
ē &#275;
Ĕ &#276;
ĕ &#277
Ė &#278;
ė &#279;
Ę &#280;
ę &#281;
Ě &#282;
ě &#283;
Ĝ &#284;
ĝ &#285;
Ğ &#286;
ğ &#287;
Ġ &#288;
ġ &#289;
Ģ &#290;
ģ &#291;
Ĥ &#292;
ĥ &#293;
Ħ &#294;
ħ &#295;
Ĩ &#296;
ĩ &#297;
Ī &#298;
ī &#299;
Ĭ &#300;
ĭ &#301;
Į &#302;
į &#303;
İ &#304;
ı &#305;
IJ &#306;
ij &#307;
Ĵ &#308;
ĵ &#309;
Ķ &#310;
ķ &#311;
ĸ &#312;
Ĺ &#313;
ĺ &#314;
Ļ &#315;
ļ &#316;
Ľ &#317
ľ &#318;
Ŀ &#319;
ŀ &#320;
Ł &#321;
ł &#322;
Ń &#323;
ń &#324;
Ņ &#325;
ņ &#326;
Ň &#327;
ň &#328;
ʼn &#329;
Ŋ &#330;
ŋ &#331;
Ō &#332;
ō &#333;
Ŏ &#334;
ŏ &#335;
Ő &#336;
ő &#337;
Π&#338;
œ &#339;
Ŕ &#340;
ŕ &#341;
Ŗ &#342;
ŗ &#343;
Ř &#344;
ř &#345;
Ś &#346;
ś &#347;
Ŝ &#348;
ŝ &#349;
Ş &#350;
ş &#351;
Š &#352;
š &#353;
Ţ &#354;
ţ &#355;
Ť &#356;
ť &#357
Ŧ &#358;
ŧ &#359;
Ũ &#360;
ũ &#361;
Ū &#362;
ū &#363;
Ŭ &#364;
ŭ &#365;
Ů &#366;
ů &#367;
Ű &#368;
ű &#369;
Ų &#370;
ų &#371;
Ŵ &#372;
ŵ &#373;
Ŷ &#374;
ŷ &#375;
Ÿ &#376;
Ź &#377;
ź &#378;
Ż &#379;
ż &#380;
Ž &#381;
ž &#382;
ſ &#383;
Ŕ &#340;
ŕ &#341;
Ŗ &#342;
ŗ &#343;
Ř &#344;
ř &#345;
Ś &#346;
ś &#347;
Ŝ &#348;
ŝ &#349;
Ş &#350;
ş &#351;
Š &#352;
š &#353;
Ţ &#354;
ţ &#355;
Ť &#356;
ť &#577;
Ŧ &#358;
ŧ &#359;
Ũ &#360;
ũ &#361;
Ū &#362;
ū &#363;
Ŭ &#364;
ŭ &#365;
Ů &#366;
ů &#367;
Ű &#368;
ű &#369;
Ų &#370;
ų &#371;
Ŵ &#372;
ŵ &#373;
Ŷ &#374;
ŷ &#375;
Ÿ &#376;
Ź &#377
ź &#378;
Ż &#379;
ż &#380;
Ž &#381;
ž &#382;
ſ &#383;

[Mac OS]Show Hide Files

Enter this code to show the hidden files & folders:

defaults write com.apple.Finder AppleShowAllFiles YES

Finder has to be restarted.
To do this enter:

killall Finder

Enter this code to hide the hidden files & folders:

defaults write com.apple.Finder AppleShowAllFiles NO

Finder has to be restarted.
To do this enter:

killall Finder

The above codes work perfectly fine for me on every test I’ve run however it has been reported that the last part of the code, “YES” and “NO” does not work for some people. If showing or hiding the hidden files with “YES” or “NO” does not work for you then replace it with “TRUE” or “FALSE”.

Permanently show the Hidden Library Folder When Apple released OS X Lion they decided they wanted to hide the Library folder.
If you want to get it back permanently, it’s incredibly easy to do.

Open Terminal and enter:

 chflags nohidden ~/Library/ 

Press Enter. Now your Library folder will be shown in your Home folder.

To go back to the default setting of having the Library folder hidden enter this into Terminal:

chflags hidden ~/Library/

Lua Pattern Match

一  <a href=”http://hanyu.iciba.com/hy/%E4%B8%80%C2%A0%C2%A0/” target=”_blank”>一</a>

乛  <a href=”http://hanyu.iciba.com/hy/%E4%B9%99/” target=”_blank”>乙</a>

indexhtml = io.open(“/Users/andy/Desktop/7000hanzi.html”,”r”)
html = indexhtml:read(“*all”)
–for k in html:gmatch(“([\194-\244][\0-\255]+)”) do print(k) end

for k,v in html:gmatch(“&lt;a%s*href=\”http://hanyu.iciba.com/hy/([^/]-)/\”%s*target=\”_blank\”&gt;(.-)”)

for k,v in html:gmatch(“&lt;a%s*href=\”http://hanyu.iciba.com/hy/([^/]-)/\”%s*target=\”_blank\”&gt;(.-)”)
do print(k,v) end

%E4%B8%80 一
%E4%B9%99 乙
%E4%BA%8C 二
%E5%8D%81 十
%E4%B8%81 丁
%E5%8E%82 厂
%E4%B8%83 七
%E5%8D%9C 卜
%E5%85%AB 八
%E4%BA%BA 人
%E5%85%A5 入
%E4%B9%82 乂
%E5%84%BF 儿
%E4%B9%9D 九
%E5%8C%95 匕
%E5%87%A0 几
%E5%88%81 刁
%E4%BA%86 了
%E4%B9%83 乃
%E5%88%80 刀
%E5%8A%9B 力
%E5%8F%88 又
%E4%B9%9C 乜
%E4%B8%89 三
%E5%B9%B2 干
%E4%BA%8D 亍
%E4%BA%8E 于
%E4%BA%8F 亏
%E5%A3%AB 士
%E5%9C%9F 土
%E5%B7%A5 工
%E6%89%8D 才
%E4%B8%8B 下
%E5%AF%B8 寸
%E4%B8%88 丈
%E5%A4%A7 大
%E5%85%80 兀
%E4%B8%8E 与
%E4%B8%87 万
%E5%BC%8B 弋
%E4%B8%8A 上
%E5%B0%8F 小
%E5%8F%A3 口
%E5%B1%B1 山
%E5%B7%BE 巾
%E5%8D%83 千
%E4%B9%9E 乞
%E5%B7%9D 川
%E4%BA%BF 亿
%E5%BD%B3 彳
%E4%B8%AA 个
%E4%B9%88 么
%E4%B9%85 久
%E5%8B%BA 勺
%E4%B8%B8 丸
%E5%A4%95 夕
%E5%87%A1 凡
%E5%8F%8A 及
%E5%B9%BF 广
%E4%BA%A1 亡
%E9%97%A8 门
%E4%B8%AB 丫
%E4%B9%89 义
%E4%B9%8B 之
%E5%B0%B8 尸
%E5%B7%B2 已
%E5%B7%B3 巳
%E5%BC%93 弓
%E5%B7%B1 己
%E5%8D%AB 卫
%E5%AD%91 孑
%E5%AD%90 子
%E5%AD%93 孓
%E4%B9%9F 也
%E5%A5%B3 女
%E9%A3%9E 飞
%E5%88%83 刃
%E4%B9%A0 习
%E5%8F%89 叉
%E9%A9%AC 马
%E4%B9%A1 乡
%E5%B9%BA 幺
%E4%B8%B0 丰

Continue reading Lua Pattern Match