Skip to content

Instantly share code, notes, and snippets.

<?php
/*
function to get all x,y coords of specified rgb color
4 arguments: path/to/image, and red, green, blue values
of target pixel to search for. function assumes $pic
to be a .jpg type image. You will have to change the
code if you are using a different image type, or else
setup some conditions to determine which image type
$pic is, and use the proper GD functions for it.
$r, $g, $b each takes a 0-255 dec format value.
<?php
/**
*
* 相似图片搜索hash的php实现
* @author welefen
*
*/
class Imghash{
private static $_instance = null;
@wgm89
wgm89 / simpleimage.php
Created November 30, 2012 03:52 — forked from miguelfrmn/simpleimage.php
SimpleImage PHP Class
<?php
/*
* File: SimpleImage.php
* Author: Simon Jarvis
* Modified by: Miguel Fermín
* Based in: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@wgm89
wgm89 / gist:4353631
Created December 21, 2012 15:55
php 模拟浏览器
http://sourceforge.net/projects/snoopy/
@wgm89
wgm89 / gist:5027668
Created February 25, 2013 04:03
some functions
------------------------- 前端
/**
* 前端公共函数方法整理
* @author Weige
* 备注: 配合jqury.js 使用
* 2012-04
*/
//获取字符串长度
function getWordSize(str)
@wgm89
wgm89 / gist:5028369
Created February 25, 2013 07:45
php 正则匹配邮箱 (php match mail address)
function ValidateAddress($address) {
if (defined('PCRE_VERSION')) { //Check this instead of extension_loaded so it works when that function is disabled
if (version_compare(PCRE_VERSION, '8.0') >= 0) {
return (boolean)preg_match('/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', $address);
}
//This is how HTML, Controller & Directive looked in my actual app at this point.
//Notice that we are applying masonry for every element as they are added by ng-repeat.
//HTML
/*
<div id="photoContainer" style="position:relative;height:800px;zoom:1;">
<div class="photo" ng-repeat="photoPost in photoPosts">
<img ng-src="{{photoPost.photo.url}}" add-masonry="photoPost"></div>
</div>
</div>
function loadModel($type, $id, $errorMessage='This page does not exist', $errorNum=404)
{
$model = CActiveRecord::model($type)->findByPk($id);
if ($model === null)
throw new CHttpException($errorNum, $errorMessage);
return $model;
}
@wgm89
wgm89 / gist:5531475
Last active December 17, 2015 01:49
c thread
#include <pthread.h>
#include <stdio.h>
#include <sys/time.h>
#include <string.h>
#define MAX 100000000
pthread_t thread[2];
pthread_mutex_t mut;
void *thread1()
{
echo '=================================================';
echo 'Enter master';
echo '=================================================';
git checkout master
echo '=================================================';
echo 'Merging dev branch commits';
echo '=================================================';
git merge mini_dev --no-ff