Skip to content

Instantly share code, notes, and snippets.

View skoskie's full-sized avatar

Shelton Koskie skoskie

View GitHub Profile
@skoskie
skoskie / css-minimizing-regex.txt
Last active September 27, 2015 02:58
CSS Minimizing Regex
(\/\*(.|\s)*?\*\/|(\n|\t|\r|\v|\f|\a){1,}|\s(?=\s)|(?<=})\s|(?<={)\s|\s(?={)|\s(?=})|(?<=;)\s|[[:blank:]](?=;)|(?<=:)[[:blank:]]|(?<=,)[[:blank:]])
@skoskie
skoskie / getJquery2.html
Last active January 12, 2019 19:44
The unofficial new way to call jQuery 2.0. #jquery #cdn
<!-- https://twitter.com/paul_irish/status/218395508018921472 -->
<!--[if lte IE 8]>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript">
window.jQuery || document.write('<script src="js/libs/jquery-1.9.0.min.js"><\/script>')
</script>
// call old jQuery plugin 1
// call old jQuery plugin 2
<![endif]-->
<!--[if (gt IE 8)|!(IE)]>
@skoskie
skoskie / Domain Regex
Created January 2, 2013 14:56
Very simple regex to check if a url is of a particular domain. Doesn't support subdomains except for "www".
^(http(s?):\/\/(www\.?)amazon.com)
@skoskie
skoskie / acf-metabox-hack.html
Last active January 12, 2019 19:42
This is a temporary work-around for the Advanced Custom Fields Wordpress plugin's lack of support for blank meta boxes. A feature request for this capability was made on the plugin's Github page: https://github.com/elliotcondon/acf/issues/19. #wordpress #acf
<p>Here you may add a new row for every new question and answer set you wish to display.</p>
<div class="postbox">
<h3>Tips</h3>
<div class="inside">
<ul style="list-style-type:disc; list-style-position:inside; margin-left:30px;">
<li>Hover your cursor over the <span id="highlight-left-margin" style="text-decoration:underline; font-weight:bold; cursor:pointer;">left margin</span> and click to drag our FAQ items into a different order.</li>
<li>Hover over the <span id="highlight-right-margin" style="text-decoration:underline; font-weight:bold; cursor:pointer;">right margin</span> and click on the <i>plus<i> to add a new FAQ item. Click on the <i>minus</i> to delete an tem.</li>
<li>Some fields allow you to use basic <abbr title="Hypertext Markup anguage." style="border-bottom:1px dotted;">HTML</abbr> tags, like &lt;b&gt;<b>bold</b>&lt;/b&gt; and &lt;i&gt;<i>italic</i>&lt;/i&gt;.</i>
</ul>
</div>
@skoskie
skoskie / todo-html.sublime-completions
Last active December 14, 2015 14:58
Sublime Text auto-completions for TODO, FIXME, CHANGED, and NOTE comments. Intended to be compatible with SublimeTODO: https://github.com/robcowie/SublimeTODO
{
"scope": "text.html",
"completions":
[
{
"trigger" : "todo",
"contents" : "<?php\n/**\n *\t\tTODO: ${1:New Todo Item}\n */\n?>"
},
{
"trigger" : "fixme",
@skoskie
skoskie / all-shortcode-args.php
Last active March 4, 2019 02:42
In Wordpress, this function will get a list of all parameters defined in all functions that are used as shortcodes. Why anyone would ever need something like this, I have no idea.
<?php
/**
* Gets all arguments for all shortcode functions and returns them as an array.
*
* @method get_all_shortcode_args
*
* @param boolean $ignore_native Whether to ignore the native Wordpress shortcodes.
*
* @param boolean $dedupe Whether to return unique values or allow duplicates.
*
@skoskie
skoskie / main-slide-reversed.scss
Last active August 29, 2015 14:03
Automatic Slider Scale Down Concept
// What if we wanted to reverse the calculations to align with pre-defined breakpoints?
// You must start mobile-first.
// Maximum cropable area will be the size of the largest change between breakpoints.
// 1 - 768/992 = 22.6% <-- Winner! We may have to crop ~23% of the image width before snapping to the next size.
// 1 - 992/1200 = 17.3%
.img{
display:none; // $screen-xs-min
height: auto; // Again, this should be constant on all sizes. The opposite of the previous method.
Snippet: [[SnippetName]]
Chunk: [[$ChunkName]]
System Setting: [[++SettingName]]
TV: [[*fieldName/TvName]]
Link tag: [[~PageId? &paramName=`value`]]
Placeholder: [[+PlaceholderName]]
<?php
@skoskie
skoskie / highlightCompensatedAmazonReviews.js
Created October 30, 2015 17:50
Highlight Compensated Reviews on Amazon.com
// Amazon pages seem to intermittently have jQuery loaded.
if (!window.jQuery) {
var jqlib = document.createElement('script');
jqlib.setAttribute('type', 'text/javascript');
jqlib.setAttribute('src','//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js');
document.head.appendChild(jqlib);
}
// Make sure jQuery before executing.
function defer(method) {
@skoskie
skoskie / monit-setup.sh
Last active October 8, 2022 02:01
Monit -- Quick Download and Config
#!/bin/bash
# Must run this as sudo. How to make sure of that??
if [ "$EUID" -ne 0 ]
then
# Turn off history expansion to make it easier to echo exlaimation points
set +H
printf "%s\n" "Error: Monit installation and setup must be run as root. Type 'sudo !!' at the prompt, enter your password, in order to try again."