This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isInvalid($subject, $pattern) | |
{ | |
preg_match($pattern, $subject, $matches); | |
if ($matches[0] == $subject) | |
{ | |
return FALSE; | |
} | |
else | |
{ | |
return TRUE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: http://www.php.net/manual/en/book.simplexml.php#108035 | |
function toArray(SimpleXMLElement $xml) { | |
$array = (array)$xml; | |
foreach ( array_slice($array, 0) as $key => $value ) { | |
if ( $value instanceof SimpleXMLElement ) { | |
$array[$key] = empty($value) ? NULL : toArray($value); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Thanks to | |
http://www.php.net/manual/en/function.mb-detect-encoding.php#91051 | |
http://stackoverflow.com/questions/8907196/check-if-csv-file-is-in-utf-8-with-php | |
*/ | |
if (! mb_check_encoding($data, 'UTF-8')) { | |
exit("Not UTF-8"); | |
} | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gets the last commit date from .git repository | |
* @param string $gitLocation location of .git/logs/HEAD | |
* @return string date of last commit YYYY-mm-dd | |
*/ | |
function gitLastCommitInfo($gitLocation) | |
{ | |
$commitArray = file($gitLocation); // All commits from file | |
$lastCommit = array_pop($commitArray); // Latest commit | |
$lastCommitArray = explode("\t", $lastCommit); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Return base url automatically for Codeigniter | |
* Source: http://snipplr.com/view/16894/codeigniter-automatic-base-url-configuration/ | |
*/ | |
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http"); | |
$config['base_url'] .= "://".$_SERVER['HTTP_HOST']; | |
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Getting species/taxon images from EOL | |
$species = $_GET['species']; | |
$species = str_replace(" ", "+", $species); | |
// Id | |
// Documentation: http://eol.org/api/docs/pages | |
$idUrl = "http://eol.org/api/search/1.0.json?q=" . $species . "&page=1&exact=false&filter_by_taxon_concept_id=&filter_by_hierarchy_entry_id=&filter_by_string=&cache_ttl="; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Regex for matching strings that do not contain comma: | |
// BAsed on: http://stackoverflow.com/questions/717644/regular-expression-that-doesnt-contain-certain-string | |
^((?!,).)*$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-Type: text/html; charset=utf-8'); | |
?> | |
<style> | |
.number | |
{ | |
text-align: right; | |
} | |
</style> | |
<pre> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import colorsys | |
def rgb2hsv(rgb): | |
r = rgb[0] / 255 | |
g = rgb[1] / 255 | |
b = rgb[2] / 255 | |
hsvRaw = colorsys.rgb_to_hsv(r, g, b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pafy | |
import cv2 | |
import math | |
from datetime import datetime | |
url = "add url here" | |
video = pafy.new(url) | |
best = video.getbest(preftype="mp4") |
OlderNewer