Skip to content

Instantly share code, notes, and snippets.

View muhittin's full-sized avatar

Muhittin Özer muhittin

View GitHub Profile
@muhittin
muhittin / email_url_phone_check.php
Last active August 29, 2015 14:04
Regex check for e-mail address, url and phone number in given string.
public static function findEmail($string)
{
$pattern = '/[a-z0-9_\-\+]+@[a-z0-9\-]+\.([a-z]{2,4})(?:\.[a-z]{2})?/i';
preg_match_all($pattern, $string, $matches);
return (count($matches[0]) > 0);
}
public static function findUrl($string)
{
@muhittin
muhittin / select2_with_jqueryValidationEngine
Created May 29, 2014 11:39
select2 with jquery validation engine fix
$.each($(".select2-container"), function (i, n) {
$(n).next().show().fadeTo(0, 0).height("0px").css("left", "auto"); // make the original select visible for validation engine and hidden for us
$(n).prepend($(n).next());
$(n).delay(500).queue(function () {
$(this).removeClass("validate[required]"); //remove the class name from select2 container(div), so that validation engine dose not validate it
$(this).dequeue();
});
});
@muhittin
muhittin / jquery.uppercase
Created February 24, 2014 15:28
jquery uppercase (Türkçe Karakterler için)
(function($){
var mets = {
init : function(options){
var settings = $.extend({
"chars" : {
"i" : "Ä°",
"ÅŸ" : "Åž",
"ö" : "Ö",
"ü" : "Ü",
@muhittin
muhittin / setup.sh
Created November 4, 2013 15:48
Setup shell
#!/bin/sh
hosts_config(){
hosts_file=/private/etc/hosts
echo "\n127.0.0.1 $1\n">>$hosts_file
echo "Hosts file was updated."
}
apache_config(){
site_name=$1
Save this as ~/.inputrc:
# make the up and down arrows cycle through commands that match the start of a line
"\e[A": history-search-backward
"\e[B": history-search-forward
Option-up would be \e\e[A and control-p \C-p. You can see the escape sequences of other key combinations by pressing control-v.
yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel
cd /usr/local/src
wget http://git-core.googlecode.com/files/git-1.7.9.tar.gz
tar xvzf git-1.7.9.tar.gz
cd git-1.7.9
./configure
make
make install
BTW yum has last Redis too, remi repository at least.
$ sudo -i
$ yum list redis
$ redis.x86_64 2.6.13-1.el6.remi remi
But today we want compile redis from source (see http://redis.io/download)
$ yum install make gcc tcl
$ cd /usr/local/src
@muhittin
muhittin / credit_card_type.php
Created February 12, 2013 15:03
MasterCard: Must have a prefix of 51 to 55, and must be 16 digits in length. Visa: Must have a prefix of 4, and must be either 13 or 16 digits in length. American Express: Must have a prefix of 34 or 37, and must be 15 digits in length. Diners Club: Must have a prefix of 300 to 305, 36, or 38, and must be 14 digits in length. Discover: Must have…
function credit_card_type($ccNum)
{
if (ereg("^5[1-5][0-9]{14}$", $ccNum))
return "Mastercard";
if (ereg("^4[0-9]{12}([0-9]{3})?$", $ccNum))
return "Visa";
if (ereg("^3[47][0-9]{13}$", $ccNum))
return "American Express";
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
# Eğer sitenize doğrudan www.siteniz.com domaini ile girilirse:
RewriteCond %{HTTP_HOST} www.siteniz.com$ [NC]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
@muhittin
muhittin / resize_to_screen.js
Created August 25, 2012 10:01
resize element to screen resolution (with jQuery)
function resize(oran){
var newH = parseFloat( $(window).height() );
var newW = parseFloat( $(window).width() );
var rat = newW / newH;
if(rat > oran)
{
var targetHeight = newH;
var targetWidth = newH * oran;
}