Skip to content

Instantly share code, notes, and snippets.

View elliotboney's full-sized avatar

Elliot Boney elliotboney

View GitHub Profile
@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 / 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 / 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 / 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);
}
/* 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;
}
<?php
// Remove duplicates from a php array
$array = array_unique($array, SORT_REGULAR);
@elliotboney
elliotboney / uninstall-foreign-fonts.sh
Created December 4, 2015 13:12 — forked from jm3/uninstall-foreign-fonts.sh
uninstall the 162 non-English fonts that Apple installs that clog up Photoshop's font menu.
#!/bin/sh
# jm3.net
# uninstall the 162 non-English fonts that Apple installs that clog up Photoshop's font menu.
# ========================
## RUN AT YOUR OWN RISK ##
# ========================
# if this formats your hard drive or deletes your fonts or changes the sex
# of your dog, I'm super sorry, but there's nothing I can do.
@elliotboney
elliotboney / cookie.js
Created June 7, 2016 23:06 — forked from blankyao/cookie.js
cookie
@elliotboney
elliotboney / Simplify3d_to_octoprint.sh
Created August 3, 2017 19:01
Allows sending files directly from simplify3d to octoprint
# In Simplify3D go to:
# - Edit Process Settings -> Scripts
# At the very bottom there is a box titled "Post Processing"
# Add the following command line to the box titled "Addidional Terminal Commands for Post Processing"
curl -k -H "X-Api-Key: 1111111222222233333444455555" -F "select=false" -F "print=false" -F "file=@[output_filepath]" "http://octopi.local/api/files/local"