Skip to content

Instantly share code, notes, and snippets.

View fjarrett's full-sized avatar

Frankie Jarrett fjarrett

View GitHub Profile
@beiyuu
beiyuu / select-text-range.js
Last active September 23, 2022 19:52
jQuery:Select a text range (input/textarea)
//USE CASE
$('#q').selectRange(0, 10);
$('#q').selectRange(searchVal.indexOf('{'), (searchVal.indexOf('}')+1));
//Source here : http://plugins.jquery.com/project/selectRange
$.fn.selectRange = function(start, end) {
var e = document.getElementById($(this).attr('id')); // I don't know why... but $(this) don't want to work today :-/
if (!e) return;
@fjarrett
fjarrett / rogers_radio-post_list-shortcode_params.php
Created March 16, 2012 20:09
Post List Shortcode Parameter Reference
partial // default: loop,post_list
wrap // default: true (boolean)
wrapper_class // class attribute for the <ul> element
post_status // default: publish
posts_per_page // default: Settings > Reading > Blog pages show at most
paged // default: paged (if shortcode is in a custom page template use paged="page")
offset // number of posts to displace
orderby // default: date
order // default: DESC
p // post ID
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 27, 2024 00:18
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
<?php
/*
Plugin Name: Easy Digital Downloads - Variable Pricing License Activation Limits
Plugin URL: http://easydigitaldownloads.com/extension/
Description: Limit the number of license activations permitted based on variable prices
Version: 1.0
Author: Pippin Williamson
Author URI: http://pippinsplugins.com
Contributors: mordauk
*/
@HarishChaudhari
HarishChaudhari / country-code-to-currency-code-mapping.csv
Last active April 26, 2024 12:10
Country, Country Code, Currency code mapping in CSV format Taken from https://gist.github.com/304261 Contains 249 countries.
Country CountryCode Currency Code
New Zealand NZ New Zealand Dollars NZD
Cook Islands CK New Zealand Dollars NZD
Niue NU New Zealand Dollars NZD
Pitcairn PN New Zealand Dollars NZD
Tokelau TK New Zealand Dollars NZD
Australian AU Australian Dollars AUD
Christmas Island CX Australian Dollars AUD
Cocos (Keeling) Islands CC Australian Dollars AUD
Heard and Mc Donald Islands HM Australian Dollars AUD
@fjarrett
fjarrett / gist:5224398
Last active December 15, 2015 07:38
Restricts certain menu items from appearing the WordPress Admin area. Useful for hiding unused features such as Posts or Comments from non-Administrator users.
<?php
/**
* Restricts certain menu items from appearing the WP Admin area. Does not
* affect Administrator users.
*
* @action admin_menu
*/
function fjarrett_restrict_admin_menu_items() {
// Don't restrict Administrator users.
@westonruter
westonruter / readme.md
Last active December 19, 2015 17:38
vassh: Vagrant Host-Guest SSH Command Wrapper/Proxy/Forwarder

THIS REPO HAS MOVED! It has graduated to a dedicated GitHub project: https://github.com/x-team/vassh

The big pain of doing vagrant ssh is that it doesn’t drop you into the corresponding working directory in the Vagrant guest’s synced_folder, so you have to cd to the dir and then run whatever you needed to do (e.g. wp core update). This is the problem that vassh solves: it will make sure you start out in the corresponding directory. So if you’re in your WordPress project on your host machine, all you need to do is:

$ vassh wp core update

There’s also a wrapper called vasshin which will shell you into Vagrant at the current directory, with a prompt for entering commands. This gets you colors and interactive TTY. You can also pass commands as arguments to vasshin to have them executed right away in the colorized TTY (with some additional Vagrant .bash_login echoes and SSH connection close):

PS1='\[\033[31m\]$(retval=$?;if [[ $retval != 0 ]]; then echo "^E$retval "; fi)\[\033[00m\]\[\033[32m\]\u@\h\[\033[00m\][$(date "+%H:%M:%S")]:\[\033[35m\]\w\[\033[31m\]$(__git_ps1 " (%s)")$(__svn_ps1 " (%s)")\[\033[00m\]\n\!\$ '
{
"status": "success",
"code": 0,
"message": "ok",
"data": {
"last_name": "Alba",
"domain_verified": false,
"following_count": 71,
"image_medium_url": "http://media-cache-ec0.pinimg.com/avatars/jessicamalba_1360689715_75.jpg",
"implicitly_followed_by_me": false,
@chrisjhoughton
chrisjhoughton / wait-el.js
Last active October 6, 2023 09:46
Wait for an element to exist on the page with jQuery
var waitForEl = function(selector, callback) {
if (jQuery(selector).length) {
callback();
} else {
setTimeout(function() {
waitForEl(selector, callback);
}, 100);
}
};