Skip to content

Instantly share code, notes, and snippets.

View KryptikOne's full-sized avatar
:octocat:
Slaying Code Dragons ⚔️🐲🧑🏽‍💻

Jason KryptikOne

:octocat:
Slaying Code Dragons ⚔️🐲🧑🏽‍💻
View GitHub Profile
@KryptikOne
KryptikOne / countries-select-menu.html
Created December 19, 2013 15:15
A fairly comprehensive select menu of all the countries around the world.
<select>
<option value=" " selected>(please select a country)</option>
<option value="--">none</option>
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
@KryptikOne
KryptikOne / find-and-append-placeholder.js
Last active December 31, 2015 20:49
This tests whether the <body> has a certain class, and if it does, it finds a child within a parent and appends the placeholder attribute to the child.
(function($){
var someParentElement = $('#id_of_parent'),
someChildElement = $('#id_of_child'),
theBodyElement = $('body');
if(theBodyElement.hasClass('some_class_on_the_body_element')) {
someParentElement.find(someChildElement).append(function(){
$(this).attr('placeholder', 'Your Placeholder Text');
});
}
})(jQuery);
@KryptikOne
KryptikOne / limiting-character-count.js
Created December 20, 2013 18:50
Limiting the character count of a particular element.
$("#some-element").text(function(index, text) {
return text.substr(0, 175);
});
@KryptikOne
KryptikOne / smooth-scrolling-jump-to-links.js
Last active March 28, 2019 20:11
Smooth scrolling jump to links. Perfect for use on a single page site that needs smooth scrolling to each section. .anchor-element could be simply a list of links or a navigation area, just make sure the href of the link corresponds with the section's id.
@KryptikOne
KryptikOne / 50-states-select-menu.html
Created December 20, 2013 19:00
Select Menu of all 50 United States and Minor Outlying Territories. All the states......All of 'em.
<select>
<optgroup>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
// This goes in the functions.php file in your theme
<?php
function the_breadcrumb() {
if (!is_home()) {
echo '<a href="';
echo get_option('home');
echo '">';
echo "Home";
echo " / </a>";
$('textarea').keyup(function() {
var characterCount = $(this).val().length,
current = $('#current'),
maximum = $('#maximum'),
theCount = $('#the-count');
current.text(characterCount);
/* ===| This isn't entirely necessary, just playin around |=== */
@KryptikOne
KryptikOne / show-or-hide-all-hidden-files-on-mac-osx
Created January 9, 2014 21:38
The two commands below will either show all files, (specifically hidden files), in finder on Mac OSX 10.9 or hide them depending on which you enter in terminal. By default Apple hides hidden files.
// This will show the hidden files
defaults write com.apple.finder AppleShowAllFiles 1 && killall Finder
// This will hide the hidden files
defaults write com.apple.finder AppleShowAllFiles 0 && killall Finder
@KryptikOne
KryptikOne / 301-redirect
Created January 24, 2014 04:47
301 Redirect
RewriteCond %{HTTP_HOST} ^www.example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.org [NC]
RewriteRule ^(.*)$ http://www.example.net/$1 [L,R=301]
@KryptikOne
KryptikOne / quick-mobile-detection.js
Created March 6, 2014 17:15
Quick Mobile Detection. Yes I know, it's probably better to do feature detection rather than UA sniff, but sometimes for smaller projects you just need to know whether or not you're on a mobile device without having to load in a larger library.
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},