Skip to content

Instantly share code, notes, and snippets.

View maheshruparel's full-sized avatar

Mahesh Ruparel maheshruparel

View GitHub Profile
1) Install MAMP normally
2) Download the latest binary of tomcat from http://tomcat.apache.org/ and extract it into the MAMP folder
(you should now have a /Applications/MAMP/apache-tomcat-version folder)
3) Create a link to the apache-tomcat folder:
ln -s /Applications/apache-tomcat-7.0.37/ tomcat
4) Make sure all the binaries are executable:
cd /Applications/tomcat/bin
(s=>{p=[];for(i=2;i<s;i++){for(j=f=0;p[j]*p[j]<=i;j++)f|=!(i%p[j]);f||p.push(i)}return p})(10000)
@maheshruparel
maheshruparel / gist:b1cf3e31e1543d16a8d8bc796a3e7f95
Created August 13, 2019 18:01 — forked from bradleysa/gist:7d1448253097784daf94
WooCommerce: Add Continue Shopping Button on Cart Page
<?php
/**
* Add Continue Shopping Button on Cart Page
* Add to theme functions.php file or Code Snippets plugin
*/
add_action( 'woocommerce_before_cart_table', 'woo_add_continue_shopping_button_to_cart' );
function woo_add_continue_shopping_button_to_cart() {
@maheshruparel
maheshruparel / 0.md
Created July 14, 2019 06:32 — forked from max-mapper/0.md
JS hoisting by example

JavaScript function hoisting by example

Below are many examples of function hoisting behavior in JavaScript. Ones marked as works successfuly print 'hi!' without errors.

To play around with these examples (recommended) clone them with git and execute them with e.g. node a.js

Notes on hoisting

(I may be using incorrect terms below, please forgive me)

<!--
source: http://wordpress.stackexchange.com/a/53516/7577
-->
<a id="buy" href="#">Buy this!</a>
<script>
$('#buy').click(function(e) {
e.preventDefault();
addToCart(19);
return false;
});
via http://wordpress.stackexchange.com/questions/2623/include-custom-taxonomy-term-in-search/5404#5404
function atom_search_where($where){
global $wpdb;
if ( is_search() )
$where .= "OR (t.name LIKE '%".get_search_query() . "%' AND {$wpdb->posts} . post_status = 'publish')";
return $where;
}
<?php
if ( !function_exists( 'wp_new_user_notification' ) ) {
function wp_new_user_notification( $studentID, $plaintext_pass = '' ) {
$student = new WP_User($studentID);
$student_data = get_userdata( $studentID );
$firstname = $student_data->first_name;
$student_login = stripslashes( $student_data->user_login );
// URLs
$site_url = site_url();
@maheshruparel
maheshruparel / get_barcode_from_image.js
Created October 9, 2012 10:48 — forked from tbtlr/get_barcode_from_image.js
Barcode recognition with JavaScript - Demo: http://bit.ly/djvUoy
/*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(){
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',