Skip to content

Instantly share code, notes, and snippets.

View elliotboney's full-sized avatar
😁
vibin

Elliot Boney elliotboney

😁
vibin
View GitHub Profile
<?php
// Remove duplicates from a php array
$array = array_unique($array, SORT_REGULAR);
/* I use Stylish (a chome addin) to set these styles
* URLs on the domain workflowy
*/
.next-row {
border: 2px solid #46A546 !important;
border-top-left-radius:0.5em;
background-color: #CCFFCC !important;
}
/* I use Stylish (a chome addin) to set these styles
* URLs on the domain workflowy
*/
.next-row {
border: 2px solid #46A546 !important;
border-top-left-radius:0.5em;
background-color: #CCFFCC !important;
}
@elliotboney
elliotboney / createcsv.php
Created July 3, 2014 02:03
Create csv file from php array
<?php
function generateCsv($data, $delimiter = ',', $enclosure = '"') {
$handle = fopen('php://temp', 'r+');
foreach ($data as $line) {
fputcsv($handle, $line, $delimiter, $enclosure);
}
rewind($handle);
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
@elliotboney
elliotboney / getparams.php
Last active August 29, 2015 14:03
Create matching variable names to $_GET parameters
<?php
$expected=array('module','act','gal_id','page_id','view','reply','post_id');
foreach($expected as $key){
if(!empty($_GET[$key])){
${key}=$_GET[$key];
} else{
${key}=NULL;
}
}
?>
@elliotboney
elliotboney / getemail.php
Created June 24, 2014 01:28
Grab emails from a string
<?php
function extract_emails_from($string){
preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches);
return $matches[0];
}
// Example useage
$text = "blah blah blah [email protected] blah blah blah [email protected]";
@elliotboney
elliotboney / jquery.onAvailable.js
Last active August 29, 2015 14:02
Wait until ready w/javascript
$.fn.onAvailable = function(fn) {
var sel = this.selector;
var timer;
if (this.length > 0) {
fn.call(this);
} else {
timer = setInterval(function() {
if ($(sel).length > 0) {
fn.call($(sel));
clearInterval(timer);
@elliotboney
elliotboney / clearfix.css
Created May 31, 2014 14:59
Modern micro clearfix
/**
* For modern browsers
* 1. The space content is one way to avoid an Opera bug when the
* contenteditable attribute is included anywhere else in the document.
* Otherwise it causes space to appear at the top and bottom of elements
* that are clearfixed.
* 2. The use of `table` rather than `block` is only necessary if using
* `:before` to contain the top-margins of child elements.
*/
.cf:before,
(function (window, document) {
function onLoad(callback) {
if (document.readyState === "complete") {
setTimeout(callback, 1);
} else if (document.addEventListener) {
window.addEventListener("load", callback, false);
} else {
window.attachEvent("onload", callback);
}
@elliotboney
elliotboney / Lighten Darren.js
Created May 1, 2014 20:18
Lighten and Darken colors in js
function LightenDarkenColor(col, amt) {
var usePound = false;
if (col[0] == "#") {
col = col.slice(1);
usePound = true;
}
var num = parseInt(col,16);