Skip to content

Instantly share code, notes, and snippets.

View cloudsben's full-sized avatar
🏠
Working from home

Ben cloudsben

🏠
Working from home
View GitHub Profile
@cloudsben
cloudsben / gist:3293287
Created August 8, 2012 07:56
Use PHP judge GIF image animation
function check_gif($path)
{
// Reads entire file into a string
$content = file_get_contents($path);
// Find GIF89a in a string
$bool = strpos($content, 'GIF89a');
if($bool === FALSE)
{
// Find NETSCAPE2.0 in a string
return strpos($content, chr(0x21).chr(0xff).chr(0x0b).'NETSCAPE2.0')===FALSE?0:1;
@cloudsben
cloudsben / click_sum.sql
Created August 16, 2012 10:01
Mysql event procedure project
USE db_article;
drop procedure click_insert;
DELIMITER //
CREATE PROCEDURE click_insert()
BEGIN
DECLARE rarcid INT;
@cloudsben
cloudsben / border.css
Created August 29, 2012 06:04
css 用border实现三角形
.message-box {
position:relative;
width:240px;
height:60px;
line-height:60px;
background:#E9FBE4;
box-shadow:1px 2px 3px #E9FBE4;
border:1px solid #C9E9C0;
border-radius:4px;
text-align:center;
@cloudsben
cloudsben / gist:3528913
Created August 30, 2012 13:49
js创建对象
var person = new Object();
person.name = 'cloudsben';
person.age = 23;
person.job = 'Web Developer';
person.sayName = function(){
alert(this.name);
}
person.sayName();
@cloudsben
cloudsben / oauth2_lib.php
Created October 17, 2012 07:18
codeigniter新浪微博 SDK
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* @ignore
*/
class OAuthException extends Exception {
// pass
}
class Oauth2_lib {
cat new_fix_click.txt|awk '/^[0-9 ]+$/ {print "call fix_click("$1","$2");"}'
@cloudsben
cloudsben / pdf.sh
Created October 18, 2012 08:59
转换图片shell脚本
#!/bin/sh
for i in $(seq 0 $2)
do
echo $i
convert -density 72 $1[$i] thumb-$i.png
done
@cloudsben
cloudsben / get_pdf_page_num.php
Created October 19, 2012 07:42
获取pdf总页数方法
function getNumPagesInPDF($PDFPath)
{
$stream = @fopen($PDFPath, "r");
$PDFContent = @fread ($stream, filesize($PDFPath));
if(!$stream || !$PDFContent)
return false;
$firstValue = 0;
$secondValue = 0;
if(preg_match("/\/N\s+([0-9]+)/", $PDFContent, $matches)) {
$firstValue = $matches[1];
@cloudsben
cloudsben / format_time.php
Created October 31, 2012 09:02
格式化时间
public function format_time($create_time)
{
$time = time() - $create_time;
switch ($time) {
case $time < 3600:
$now = ceil($time/60).'分钟前';
break;
case $time < 3600*24:
@cloudsben
cloudsben / substring.php
Created November 7, 2012 02:08
截取字符串到指定位置
<?php
for($i=0;$i< 90000; $i++)
{
$a .= ','.rand(10000,99999);
}
// $b = explode(',', $a);
// $c =array_slice($b, 0, 20);
// var_dump($c);
$cc = 0;$pos = 0;
echo $a[0];