Skip to content

Instantly share code, notes, and snippets.

View rxnlabs's full-sized avatar

De'Yonte W. rxnlabs

View GitHub Profile
@rxnlabs
rxnlabs / sublime-text-sftp-plugin-settings.json
Created September 14, 2015 18:17
Sublime Text - SFTP Plugin Settings
{
// The tab key will cycle through the settings when first created
// Visit http://wbond.net/sublime_packages/sftp/settings for help
// sftp, ftp or ftps
"type": "sftp",
"save_before_upload": true,
"upload_on_save": true,
"sync_down_on_open": true,
@rxnlabs
rxnlabs / sort-stock-portfolio-table.js
Created July 31, 2015 21:30
JS - Sort a table with stocks into groups using the Footable plugin and jQuery
// sort the table after window object is done loading
jQuery(window).ready(function($){
var $ = jQuery;
// sort Portfolio table by the portfolio group
sort_portfolio_group();
});
// sort the portfolio by group and by the selected sorting order
function sort_portfolio_group(){
var $ = jQuery;
@rxnlabs
rxnlabs / vagrant-up-error
Created July 23, 2015 15:07
Vagrant - Fix Vagrant Up error on Mac OSX. Fix to issue where Vagrant won't reload and provision the virtual machine for error NFS is reporting that your exports file is invalid. Vagrant does this check before making any changes to the file. Please correct the issues below and execute "vagrant reload": conflicting exports for /projects/vm/www, 1…
# http://nicolasleroy.be/blog/vagrant-error
vagrant halt // As the machine will have booted, even with the error above
rm -rf /etc/exports // Remove the exports file.
vagrant up // Let's try again, fingers crossed
@rxnlabs
rxnlabs / solution-1.php
Created July 16, 2015 15:47
Programming interview question
<?php
/*
Output a list of numbers multiple times depending on their value (e.g. output 9 nine times, or 18 eighteen times). Works well if it doesn't matter if you listall the numbers preceding the last number
*/
$array = array(1,2,3,4,5,6,7,8,9,12,18);
foreach ($array as $num) {
$string = '';
$count = 1 * $num;
for ($i=0;$i < $count; $i++) {
@rxnlabs
rxnlabs / dr-disqus-top-comments
Created April 8, 2015 15:18
MySQL - DR Get the websites that Disqus users visit who also comment on the DR
SELECT disqus_forum_users.forum_id, COUNT(disqus_forum_users.forum_id) AS `count`, disqus_forums.description, website FROM disqus_forum_users LEFT JOIN disqus_forums ON disqus_forums.forum_id = disqus_forum_users.forum_id WHERE disqus_forum_users.forum_id != "dailyreckoning" GROUP BY forum_id ORDER BY count DESC;
@rxnlabs
rxnlabs / mysql-drop-all-tables-in-database
Created March 5, 2015 16:08
MySQL - Drop All Tables in a database (without dropping the database) using the command line.
mysqldump -u db_user -p db_password -h db_host --add-drop-table --no-data db_name | grep ^DROP | mysql -u db_user -p db_password -h db_host db_name
@rxnlabs
rxnlabs / wordpress-get-paragraph-excerpt-end-of-sentence.php
Last active June 21, 2018 14:27
WordPress - WP Get the excerpt starting at the end of a sentence. Get an excerpt of a paragraph and show the "Read More" link after the end of a sentence. Can be modified to use in other PHP apps.
<?php
/**
* Get the excerpt of a paragraph or string of long text.
*
* Get the shortened version of text for the wyisiwig. Use with custom wysiwyg (e.g. Advanced Custom Fields). This will print the paragraph and breaks tag but will strip all other tags
*
* @since 2014-11-06
* @version 2016-03-09
* @author De'Yonte W.<rxnlabs@github.com>
@rxnlabs
rxnlabs / windows-create-alias-wp-cli.bat
Created February 26, 2015 13:25
Windows - create an alias in Windows similar to a Linux and Mac environments
doskey wp=php D:\devtools\wp-cli\wp-cli.phar
@rxnlabs
rxnlabs / htaccess-redirect-load-images-from-production
Last active November 18, 2022 15:06
htaccess - Redirect image and file request from the localhost to the production host if the file does not exist on the localhost. Needs to be placed in the root htaccess if you're using WordPress or another system that redirects all request to a index.php file.
#place above all other rewrite rules if using a cms or program that redirects all request to index.php file (e.g. WordPress, Drupal, Laravel, etc...)
#if a file or directory does not exist on the local host, 302 redirect the request to the production host so the browser doesn't cache the file in case you replace the file locally
<IfModule mod_rewrite.c>
RewriteEngine On
#Redirect WordPress uploads
#Prevent infinite redirect. Only apply this if not on any subdomains of the live domain. Comment out line if not needed
RewriteCond %{HTTP_HOST} !^(.*)example\.com
#Prevent infinite redirect. Only apply this if not on the root domain of the live domain. Uncomment line if needed
#RewriteCond %{HTTP_HOST} !^example\.com [NC]
#Prevent infinite redirect. Only apply this if not on the www version of the exact domain of the live domain. Uncomment line if needed
@rxnlabs
rxnlabs / git-check-changed-files
Created February 14, 2015 20:09
Git - figure out if any files have changed on the production/live server. Great for figuring out which files to download to your local environment
#http://stevegrunwell.github.io/wordpress-git/#/20
git ls-files -dmo --exclude-standard