Skip to content

Instantly share code, notes, and snippets.

View danielmartins's full-sized avatar

Daniel Martins danielmartins

View GitHub Profile
@danielmartins
danielmartins / get_posts_between.php
Created March 16, 2013 01:29
Wordpress: Get posts between dates based on specific post meta field
<?php
/**
* Get posts in range date by a specific custom field(post meta)
* But, the date needs to be in the format YYYYMMDD
*
* @param string $start start date
* @param string $end end date
* @param string $field specific custom field
* @param string $ctype
@danielmartins
danielmartins / array_remove_similar.php
Created March 18, 2013 01:05
PHP: Remove duplicates items of an array based on similarities
<?php
/**
* This functions runs like array_unique but is based on similarity
* and the math is based on similar_text to know better, see: php.net/similar_text
*
* @param [type] $array [description]
* @param integer $howMuch [description]
* @param [type] $callback [description]
* @return [type] [description]
@danielmartins
danielmartins / gist:5184426
Created March 18, 2013 01:22
Wordpress: insert a new post programmatically
// Create post object
$newpost = array(
'post_title' => 'My post',
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_author' => 1, // admin
);
// Insert the post into the database
@danielmartins
danielmartins / runsatisbuild.py
Created May 22, 2013 13:13
Run Satis Build on Webfaction via CronJob
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
import subprocess
from os import putenv
PHP_ABS_PATH = '/home/danielm/bin/php'
SATIS_ABS_PATH = '/home/danielm/satis/bin/satis'
PACKAGIST_BUILD_CONF_PATH = '/home/danielm/packagist/config.json'
PACKAGIST_OUTPUT_PATH = '/home/danielm/webapps/lumecomposerpackages/'
from munch import munchify
class Locator:
locator_kinds = {"id", "xpath"}
_context = None
def __init__(self, *args, **kwargs):
self.valid_parameters = [f"find_by__{kind}" for kind in self.locator_kinds]
self._locators = {}
from munch import munchify
class Locator:
locator_kinds = {"id", "xpath"}
_context = None
def __init__(self, *args, **kwargs):
self.valid_parameters = [f"find_by__{kind}" for kind in self.locator_kinds]
self._locators = {}