Skip to content

Instantly share code, notes, and snippets.

View rxnlabs's full-sized avatar

De'Yonte W. rxnlabs

View GitHub Profile
@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.<[email protected]>
@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 / 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 / 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 / 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 / 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 / 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 / insert-ad-dr.php
Created September 28, 2015 18:50
insert ad after paragraph
public function slipstream_ad_content($content)
{
if(!is_single() || get_post_type() == 'lp' || get_post_type() == 'got')
return $content;
global $agora_core, $dr_theme, $afp_openx;
$openx_script = (is_object($afp_openx)) ? $afp_openx->openx_script(array('zoneid' => $dr_theme->openx_635x120_zoneid)) : '';
$paragraphs = str_replace('</p>', '', $content);
@rxnlabs
rxnlabs / wp-cli-reset-password
Created March 9, 2016 15:37
WordPress - WP CLI reset user's password using wp-cli
wp db query "UPDATE wp_users SET user_pass=MD5('new_password_here') WHERE user_login='username'"
@rxnlabs
rxnlabs / sass-breakpoint-susy-media-mixin.sass
Last active March 17, 2016 18:17
SASS - Media Query mixins with support for Breakpoint and Susy-media mixins. Uses SASS conditional logic to check if the Breakpoint media query mixin or the Susy-media mixin exists. Fallbacks to regular media query if neither mixin exists
$media-query-mixin-warning: "You should be using the Breakpoint SASS mixin library or the Susy Grid mixin to take advantage of cool features. Your media query will still compile though"
=phone-only
+phone("down")
@content
=tablet-only
+tablet("only")
@content