This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo getNumPagesInPDF('iOS-zhangchao.pdf'); | |
function getNumPagesInPDF($PDFPath) | |
{ | |
$stream = @fopen($PDFPath, "r"); | |
$PDFContent = @fread ($stream, filesize($PDFPath)); | |
if(!$stream || !$PDFContent) | |
return false; | |
$firstValue = 0; | |
$secondValue = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Make sure you have nginx sub module compiled in | |
# nginx -V 2>&1 | grep --color=always '\-\-with\-http_sub_module' | |
# 2. add two directives below at HTTP level | |
# nginx.conf | |
http { | |
# ...... | |
sub_filter '</head>' '<style type="text/css">html{ filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); -webkit-filter: grayscale(100%); filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>WebSocket Demo</title> | |
</head> | |
<style type="text/css"> | |
textarea{width:400px;height:150px;display:block;overflow-y:scroll;} | |
#output{width:600px;height:400px;background:whiteSmoke;padding:1em .5em;color:#000;border:none;} | |
button{padding:.2em 1em;} | |
</style> | |
<link href="layout.css" rel="stylesheet" type="text/css" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
cmd=$(which tmux) | |
session=hjue | |
if [ -z $cmd ]; then | |
echo "You need to install tmux." | |
exit 1 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation MySharedThing | |
+ (id)sharedInstance | |
{ | |
DEFINE_SHARED_INSTANCE_USING_BLOCK(^{ | |
return [[self alloc] init]; | |
}); | |
} | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Minify; | |
use nginx; | |
use JavaScript::Minifier qw(minify); | |
sub handler { | |
my $r=shift; | |
my $cache_dir="/tmp"; | |
my $cache_file=$r->uri; | |
$cache_file=~s!/!_!g; | |
$cache_file=$r->header_in("Host").$cache_file; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <CoreLocation/CoreLocation.h> | |
#import <ImageIO/ImageIO.h> | |
@interface CLLocation (EXIFGPS) | |
- (NSDictionary*) EXIFMetadataWithHeading:(CLHeading*)heading; | |
@end | |
@interface NSDate (EXIFGPS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); | |
/* | |
* Created on 2013-10-25 by hjue | |
* Twig CI Library | |
* | |
*/ | |
require_once APPPATH . 'third_party/Twig/Autoloader.php'; | |
class Twig { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('BASEPATH') OR exit('No direct script access allowed'); | |
/** | |
* CodeIgniter Log Library | |
* | |
* @category Applications | |
* @package CodeIgniter | |
* @subpackage Libraries | |
* @author hjue | |
* @license BSD License |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define UA_isIPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) | |
#define UA_isIPhone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) | |
#define UA_isRetinaDevice ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] >= 2) | |
#define UA_isMultiTaskingSupported ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)] && [[UIDevice currentDevice] isMultitaskingSupported]) | |
#define UA_runOnMainThread if (![NSThread isMainThread]) { dispatch_sync(dispatch_get_main_queue(), ^{ [self performSelector:_cmd]; }); return; }; |
OlderNewer