Skip to content

Instantly share code, notes, and snippets.

Mardix mardix

Block or report user

Report or block mardix

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mardix
mardix / php-cs-fixer-pre-commit.php
Created Sep 4, 2012
A pre-commit hook to make PHP code PSR-2 compliant, check for syntax error
View php-cs-fixer-pre-commit.php
#!/usr/bin/php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP error (lint), and make sure the code
* is PSR compliant.
*
* Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
*
View CSVReader.php
<?php
/**
* CSVReader
* Class to parse and iterate CSV files on the fly
*
* <code>
* $myCsv = new CSVReader("$path/csv.csv");
*
* foreach ($myCsv as $data) {
* echo $data[2] ."\n";
@mardix
mardix / awesome-php.md
Created Nov 2, 2012 — forked from ziadoz/awesome-php.md
Awesome PHP Libraries
View awesome-php.md
View gist:5438109
{
{I have|I've} been {surfing|browsing} online more than {three|3|2|4} hours today, yet I never found any interesting article like yours. {It's|It
is} pretty worth enough for me. {In my opinion|Personally|In my view}, if all {webmasters|site owners|website owners|web owners} and bloggers made good content as
you did, the {internet|net|web} will be {much more|a lot more}
useful than ever before.|
I {couldn't|could not} {resist|refrain from} commenting. {Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I'll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch}
your {rss|rss feed} as I {can not|can't} {in finding|find|to find} your {email|e-mail} subscription {link|hyperlink} or {newsletter|e-newsletter} service. Do {you have|you've} any?
{Please|Kindly} {allow|permit|let} me {realize|recognize|understand|recognise|know} {so that|in order that} I {may just|may|could} subscribe.
Thanks.|
@mardix
mardix / Voodoo\CanOfSpam.php
Last active Dec 16, 2015
Voodoo\CanOfSpam, a PHP 5.4 implementation to parse and get random spam text for blog comments
View Voodoo\CanOfSpam.php
<?php
/**
* CanOfSpam, a PHP 5.4 implementation to parse and get random spam text for blog comments
* -> https://gist.github.com/shanselman/5422230
*
* License: MIT
* Author : Mardix - http://github.com/mardix
*
* How to use
*
View vhost.py
#! /usr/bin/python
from sys import argv
from os.path import exists
from os import makedirs
from os import symlink
import getopt
#
# Show Usage, Output to STDERR
View sqlalchemy_example.py
import sqlalchemy as sa
import sqlalchemy.orm as orm
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.orm import scoped_session, sessionmaker
DBSession = scoped_session(sessionmaker())
class BaseMixin(object):
query = DBSession.query_property()
id = sa.Column(sa.Integer, primary_key=True)
View gist:9588024
#!/usr/bin/env python
# sample usage: checksites.py eriwen.com nixtutor.com yoursite.org
import pickle, os, sys, logging
from httplib import HTTPConnection, socket
from smtplib import SMTP
def email_alert(message, status):
fromaddr = 'you@gmail.com'
@mardix
mardix / gist:38895305786610152efa
Created May 5, 2014
array_map is slower and more of memory hug than foreach in PHP
View gist:38895305786610152efa
While I was working on a personal project, I decided to compare foreach vs array_map to iterate over a large set of items.
So to support my decision, I ran a benchmark on both foreach and array_map.
With a simple array of 1,000,000 objects, I iterate over them with foreach and array_map. And surprisingly, foreach ran in 0.24sec average, while array_map took over 3.30sec.
Also array_map ran out of memory, I had to do an ini_set("memory_limit","512M"); to at least get some results.
My system:
Macbook
View .bash_profile
#############################################################################
# current prompt
#############################################################################
# \d – Current date
# \t – Current time
# \h – Host name
# \# – Command number
# \u – User name
# \W – Current working directory (ie: Desktop/)
# \w – Current working directory, full path (ie: /Users/Admin/Desktop)
You can’t perform that action at this time.