Skip to content

Instantly share code, notes, and snippets.

View MMTE's full-sized avatar
🐢
Moving!

Mahdi Taleghani MMTE

🐢
Moving!
View GitHub Profile
@cam-gists
cam-gists / validate.php
Created July 9, 2012 06:56
PHP: Regex Validation
<?php
// ref: http://komunitasweb.com/2009/03/10-practical-php-regular-expression-recipes/
// Validate Email
if (filter_var('test+email@fexample.com', FILTER_VALIDATE_EMAIL)) {
echo "Your email is ok.";
} else {
echo "Wrong email address format.";
}
//Validate Username
@baghayi-gist
baghayi-gist / gist:4009084
Created November 3, 2012 22:15
PHP: Converting Persian Numbers To English One (function).
function convertPersianNumbersToEnglish($number)
{
$persian = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');
$num = range(0, 9);
return (int)str_replace($persian, $num, $number);
}
@tobysteward
tobysteward / BlogController.php
Last active March 4, 2024 23:11
Laravel AJAX Pagination with JQuery
<?php
class BlogController extends Controller
{
/**
* Posts
*
* @return void
*/
public function showPosts()
@jsor
jsor / ddd_cqrs_event-sourcing_in_php.md
Last active April 23, 2024 19:48
DDD, CQRS and Event Sourcing in PHP

DDD, CQRS and Event Sourcing in PHP

  • Broadway - Infrastructure and testing helpers for creating CQRS and event sourced applications
  • EventCentric.Core - Event Sourcing and CQRS in PHP
  • LiteCQRS - Small convention based CQRS library for PHP
  • predaddy - Common DDD classes including an annotation driven message bus and tools for CQRS and Event Sourcing
  • ProophEventSourcing - Provides basic functionality for event-sourced aggregates
  • ProophEventStore - PHP 5.4+ EventStore Implementation
  • ProophServiceBus - PHP Enterprise Service Bus Implementation supporting CQRS and DDD
@leomelin
leomelin / gist:1ad4b29b4a38464234ec
Created January 26, 2015 10:32
dynamic svg gradient generator with PHP
public function generateSvgGradientAction() {
$from_stop = isset($_GET['from']) ? $_GET['from'] : '000000';
$to_stop = isset($_GET['to']) ? $_GET['to'] : '000000';
header('Content-type: image/svg+xml; charset=utf-8');
echo '<?xml version="1.0"?>
';
<?php
/**
* Description of VideoStream
*
* @author Rana
* @link http://codesamplez.com/programming/php-html5-video-streaming-tutorial
*/
class VideoStream
{
private $path = "";
@zurie
zurie / linear-gradient.php
Created September 23, 2015 17:33
Dynamic Linear Gradient in PHP outputs in SVG
<?php
/**
* This function takes in a color string and test whether it is in hex format.
* If so it will simply return a '#' prefixed version to make it the standard
* hex format, or return it as-is.
*
* This is done to make linking to this file within css a bit easier, since we'd
* need to escape the '#' so the browser doesn't treat it as a hash and ignore
* it when requesting content. Otherwise users would have to link using:
*
@hamidreza-s
hamidreza-s / calc.erl
Last active June 23, 2023 19:42
Sieve of Eratosthenes algorithm for finding all prime numbers up to N written in Erlang.
-module(calc).
-export([prime_numbers/1]).
% Source: https://wbear.wordpress.com/2011/12/08/prime-numbers-with-erlang/
% Sieve of Eratosthenes algorithm for finding all prime numbers up to N.
% http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
% Generate list of prime numbers up to N.
prime_numbers(N) when is_number(N) ->
prime_numbers(N, generate(N)).
@jbanety
jbanety / build_pcntl.sh
Last active February 6, 2024 02:50
(Updated) Build PCNTL ext for MAMP PHP 7.4.2
#!/bin/bash
PHP_VERSION=7.4.2
# Command lines tools
xcode-select --install
# Install dependencies
brew install wget autoconf openssl lzlib curl imap-uw readline postgresql gettext libxslt libiconv bison pkg-config krb5 bzip2 openldap tidy-html5
# Dirs
@001101
001101 / accounting.sql
Created February 18, 2017 09:08 — forked from NYKevin/accounting.sql
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE accounts(
id serial PRIMARY KEY,
name VARCHAR(256) NOT NULL
);
CREATE TABLE entries(
id serial PRIMARY KEY,
description VARCHAR(1024) NOT NULL,
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0),
-- Every entry is a credit to one account...