Skip to content

Instantly share code, notes, and snippets.

View Mamaduka's full-sized avatar

George Mamadashvili Mamaduka

View GitHub Profile
<?php
$file = '/path/to/image.png';
$editor = wp_get_image_editor( $file );
// true for hard crop
$editor->resize( 300, 300, true );
// use crop for more advanced cropping, positioning etc.
@Mamaduka
Mamaduka / setup.sh
Last active August 29, 2015 14:07 — forked from bradp/setup.sh
echo "Creating an SSH key for you..."
ssh-keygen -t rsa
echo "Please add this public key to Github \n"
echo "https://github.com/account/ssh \n"
read -p "Press [Enter] key after this..."
echo "Installing xcode-stuff"
xcode-select --install
# shortform git commands
alias g='git'
# add a tag
git tag -a 1.2 -m "Version 1.2 Stable"
# push tags
git push --tags
# download all files from a gist without git
<?php
/**
* Exclude comments for specific posts.
* 250 and 270 are post IDs
*/
function mamaduka_where_clauses( $clauses ) {
global $wpdb;
$clauses['where'] .= " AND ( $wpdb->comments.comment_post_ID NOT IN ( 250, 270 ) )";
<?php
/**
* Plugin Name: WooCommerce Email Customer Address
* Plugin URI: https://gist.github.com/BFTrick/7891074
* Description: Email the site admin when a customer changes their address
* Author: Patrick Rauland
* Author URI: http://patrickrauland.com/
* Version: 1.1
*
* This program is free software: you can redistribute it and/or modify
@Mamaduka
Mamaduka / 0_reuse_code.js
Created July 15, 2014 12:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
li.share-mwp a::before {
content: url('mwp.png');
}
<?php
/**
* Disable Browse Happy
*/
function because_im_happy() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
<?php
/**
* Adjust image quality to 100
*/
function mamaduka_adjust_quality( $image )) {
$image->set_quality(100);
return $image
}
add_filter( 'image_editor_save_pre', 'mamaduka_adjust_quality' );
@Mamaduka
Mamaduka / README.md
Created February 11, 2014 19:13
Setting up Cron on OVH

Because OVH doesn't support URL for Cron, we need to create and add custom PHP file:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://www.lovelysecret.be/wp-cron.php?f8c7891ad19adc
0dde19beb11eb67b2b&action=wysi
ja_cron&process=all');
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);