Skip to content

Instantly share code, notes, and snippets.

@prajwal-stha
prajwal-stha / migrate.sh
Created October 17, 2016 01:31 — forked from tobi-pb/migrate.sh
Upgrade MAMP to Mysql 5.6
#!/bin/sh
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.24-osx10.9-x86_64.tar.gz
tar xfvz mysql-5.6*
echo "stopping mamp"
sudo /Applications/MAMP/bin/stop.sh
sudo killall httpd mysqld
echo "creating backup"
@prajwal-stha
prajwal-stha / README.md
Created October 17, 2016 14:00 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@prajwal-stha
prajwal-stha / mamp.md
Created October 17, 2016 14:21 — forked from jfloff/mamp.md
How to get MAMP to work with SSL ... Yes really.

First of all you need to be able to run MAMP in port 80. This is a "heat check" if you don't have any process jamming http ports. You can check it like this:

sudo lsof | grep LISTEN

If you do happen to have any process with something like this *:http (LISTEN), you are in trouble. Before with adventure check if it isn't MAMP itself (yeah, you should close that beforehand)

ps <pid of that process>

If you don't see MAMP, you are in good hands, I have just the thing for you:

@prajwal-stha
prajwal-stha / .htaccess
Created October 29, 2016 01:13
Prevent PHP execution on a directory-by-directory basis in WordPress file. Add this file in each directory to prevent PHP execution.
// Lock down PHP execution in that particular directory.
<Files *.php>deny from all</Files>
@prajwal-stha
prajwal-stha / README.md
Created November 3, 2016 07:34 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@prajwal-stha
prajwal-stha / Mark parent navigation active when on custom post type single page Mark (highlight) custom post type parent as active item in Wordpress Navigation. When you visit a custom post type's single page, the parent menu item (the post type archive) isn't marked as active. This code solves it by comparing the slug of the current post type with the navigation items, and adds a class accordingly.
<?php
add_action('nav_menu_css_class', 'add_current_nav_class', 10, 2 );
function add_current_nav_class($classes, $item) {
// Getting the current post details
global $post;
// Getting the post type of the current post
<?php
abstract class WPAS_Model {
static $primary_key = 'id';
private static function _table() {
global $wpdb;
$tablename = strtolower( get_called_class() );
$tablename = str_replace( 'wpas_model_', 'wpas_', $tablename );
return $wpdb->prefix . $tablename;
}
private static function _fetch_sql( $value ) {
@prajwal-stha
prajwal-stha / magento-cleanup.php
Created December 31, 2016 16:38
Set the correct permissions for complete magento installations.
<?php
## Function to set file permissions to 0644 and folder permissions to 0755
function AllDirChmod( $dir = "./", $dirModes = 0755, $fileModes = 0644 ){
$d = new RecursiveDirectoryIterator( $dir );
foreach( new RecursiveIteratorIterator( $d, 1 ) as $path ){
if( $path->isDir() ) chmod( $path, $dirModes );
else if( is_file( $path ) ) chmod( $path, $fileModes );
}
@prajwal-stha
prajwal-stha / magento-check.php
Created December 31, 2016 16:39
Snippet to test server meets magento specifications or not.
<?
extension_check(array(
'curl',
'dom',
'gd',
'hash',
'iconv',
'mcrypt',
'pcre',
'pdo',
@prajwal-stha
prajwal-stha / git.md
Created January 15, 2017 09:52
The remote end hung up unexpectedly while git push: With this kind of error, raise the postBuffer size by:

git config --global http.postBuffer 524288000