Skip to content

Instantly share code, notes, and snippets.

View toddnestor's full-sized avatar

Todd D Nestor toddnestor

View GitHub Profile
@toddnestor
toddnestor / gist:8605330
Last active December 13, 2016 19:52
What PHP OOP can do...
<?php
//require prepend file
require('minicore/_conf/conf.php');
//Call for necessary class families from herccore
using ('System.Data');
using ('System.Validation');
//make class definitions
@toddnestor
toddnestor / Reusable and flexible solution
Created January 24, 2014 20:16
The FizzBuzz problem
<?php
//I already posted this in response to another post, but I wanted to get it to where you all could see it
//classes which would typically be kept in separate files named htmlCode.class.php and numberFunctions.class.php respectively
class htmlCode
{
public function __construct()
{
<?php
function PostInit()
{
if( !isset($_GET['dbfix']) )
return;
$this->Helper('tools')->remove_server_limits();
global $db;
@toddnestor
toddnestor / aweber_opt_in_html
Created September 10, 2015 19:21
HTML version of aweber opt in
<!-- AWeber Web Form Generator 3.0.1 -->
<style type="text/css">
#af-form-1143881060 .af-body .af-textWrap{width:98%;display:block;float:none;}
#af-form-1143881060 .af-body .privacyPolicy{color:#CCCCCC;font-size:10px;font-family:Tahoma, serif;}
#af-form-1143881060 .af-body a{color:#46B46C;text-decoration:underline;font-style:normal;font-weight:normal;}
#af-form-1143881060 .af-body input.text, #af-form-1143881060 .af-body textarea{background-color:#46B46C;border-color:#D9D9D9;border-width:1px;border-style:solid;color:#FFFFFF;text-decoration:none;font-style:normal;font-weight:normal;font-size:12px;font-family:Tahoma, serif;}
#af-form-1143881060 .af-body input.text:focus, #af-form-1143881060 .af-body textarea:focus{background-color:#46B46C;border-color:#030303;border-width:1px;border-style:solid;}
#af-form-1143881060 .af-body label.previewLabel{display:block;float:none;text-align:left;width:auto;color:#46B46C;text-decoration:none;font-style:normal;font-weight:normal;font-size:12px;font-fa
@toddnestor
toddnestor / aweber_optin_form_js
Created September 10, 2015 19:22
JS version of aweber opt-in form
<div class="AW-Form-1143881060"></div>
<script type="text/javascript">(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//forms.aweber.com/form/60/1143881060.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "aweber-wjs-14oz0n6cd"));
</script>
<h2>Original: </h2>
<div id="original">http://0e24f87c32490a111f93f3579380e24d7f3579f.0e24f87c32490a1117f3579380e24f87c32490a111a3d7f3579f.0e24f87c32490a111f.0e24f87c32490a111f937ffffa3.0e24f82490af111f9f373d7f3579380e24f87c2490a111f937a3d7f3579f.tdneffsdsafstor.sometdhing.smarffffftmefsmbffff.com.uk/whaffdffffffffffffffffffsadffdsarg+whatev?he=that http://google.com/somewhere toddnestor.com yourmom.com google.com http://google.com somewhere.so whatever.sow.u whatever.sow.uk wow.wo https:something.com https://something.com //solid.online <img src="http://google.com" /> toddnestor.com, toddnestor.com. toddnestor.com: toddnestor.com? toddnestor.com!</div>
<h2>Linkified: </h2>
<div id="linkified"></div>
<script>
var linkify = function( string ) {
var re = /(?:^|\ )(((?:(?:http(?:s)?\:)?(?:\/\/))|(?:\/\/))?(?:(?=[a-z0-9\-\.]{1,255}(?=\/|\ |$|\:|\?|\,|\!))(?:(?:(?:[a-z0-9]{1}(?:[a-z0-9\-]{1,62})?\.){1,127})[a-z]{2,}(?:\.[a-z]{2})?))(?:[a-z0-9\/\-\_\%\?\&\!\$\'\,\(\)\*\+\=\;])*?)(?=$|\.(?=\ |$)|\:|\ |\?(?=\ |$)
@toddnestor
toddnestor / cart.html
Last active March 14, 2016 21:02
Simple jQuery cart for Ed
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h3>Items</h3>
<ul class="display_items"></ul>
<hr>
@toddnestor
toddnestor / angular cart sample
Last active March 14, 2016 21:03
Angular cart sample for Ed
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div ng-app="app" ng-controller="myAppController">
<h3>Items</h3>
<ul>
def pig_latinize_word( word )
parts = word.split(/\b([^a,e,i,o,u]{0,}qu|[^a,e,i,o,u]+)?([a,e,i,o,u][a-z]{0,})?/i) #https://regex101.com/r/yP8yF9/3 <-- this is where I worked out the regex
parts.shift if parts.first.empty? #getting rid of that first empty element that results from the regex matching the entire word, adding the conditional just in case there are outliers where the first word is not blank that I haven't thought of
parts << parts.shift #moving the first element to be the last element
"#{parts.join('')}ay"
end
def translate( words )
( words.split(' ').inject([]) {|pig_latinized_words,word| pig_latinized_words << pig_latinize_word( word )} ).join(' ') #did it all in one line because I was curious if Ruby would let me, it just splits the words up by spaces, makes a new array of the pig latinized words, and then joins them back with spaces
end
@toddnestor
toddnestor / pig_latinize.rb
Last active July 28, 2016 23:16
Another ruby Pig Latin translator
def translate( words )
words.translate
end
class String
def grab_punctuation
punctuation = ''
if !self[-1].match(/[a-z]/i)
punctuation = self[-1]