Skip to content

Instantly share code, notes, and snippets.

View rgutierrez1014's full-sized avatar

Robert Gutierrez rgutierrez1014

View GitHub Profile
@rgutierrez1014
rgutierrez1014 / condition_evaluation.py
Last active November 10, 2017 20:17
An example of my condition evaluation algorithm
# utility function
def cast_to_strings(varlist):
"""Cast all values in a list to string"""
new_list = []
for v in varlist:
if type(v) in (int, long):
new_list.append(str(v))
else:
new_list.append(v)
return new_list
@rgutierrez1014
rgutierrez1014 / python_functions.php
Created November 9, 2017 02:05
An assortment of python functions written in PHP
function any($arr, $filter=NULL) {
$filtered = isset($filter) ? array_filter($arr, $filter) : array_filter($arr);
return sizeof($filtered) > 0 ? TRUE : FALSE;
}
function all($arr, $filter=NULL) {
$filtered = isset($filter) ? array_filter($arr, $filter) : array_filter($arr);
return sizeof($filtered) == sizeof($arr) ? TRUE : FALSE;
}
@rgutierrez1014
rgutierrez1014 / hipster_logo_shortcode.php
Created November 9, 2017 01:07
Hipster logo - Wordpress shortcode
function hipster_logo($atts) {
/**
* Wordpress shortcode for generating one of those
* hipster X logos. Provides defaults for each
* position on the X to make sure the logo will
* render.
*
* Arguments:
* id - ID of HTML element that is output.
* class - Extra class name(s) of HTML element that