Skip to content

Instantly share code, notes, and snippets.

Igor Fomichev fomigo

Block or report user

Report or block fomigo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fomigo
fomigo / .gitconfig
Created Oct 31, 2019 — forked from johnpolacek/.gitconfig
My current .gitconfig aliases
View .gitconfig
[alias]
co = checkout
cob = checkout -b
coo = !git fetch && git checkout
br = branch
brd = branch -d
brD = branch -D
merged = branch --merged
st = status
aa = add -A .
View crop-and-fit.php
<?php
function resizeImage($source, $dest, $new_width, $new_height, $quality)
{
// Taken from http://salman-w.blogspot.com/2009/04/crop-to-fit-image-using-aspphp.html
$image = new Phalcon\Image\Adapter\GD($source);
$source_height = $image->getHeight();
$source_width = $image->getWidth();
$source_aspect_ratio = $source_width / $source_height;
$desired_aspect_ratio = $new_width / $new_height;
if ($source_aspect_ratio > $desired_aspect_ratio) {
@fomigo
fomigo / README.md
Created Oct 13, 2019 — forked from Ocramius/README.md
`__invoke` vs `function` vs `Closure`
View README.md
@fomigo
fomigo / Antonyms.md
Created Aug 20, 2019 — forked from maxtruxa/Antonyms.md
A list of common terms used in programming and their respective antonyms.
View Antonyms.md

Antonym List

Note: The table headings (positive/negative) are not necessarily meaningful.

Positive Negative
acquire release
add remove (e.g. an item), subtract (arithmetic)
advance retreat
allocate deallocate (correct), free (common)
allow deny
@fomigo
fomigo / jquery-wp
Last active Apr 25, 2016
jQuery in WordPress
View jquery-wp
(function( $ ) {
'use strict';
$(function() {
alert( 'JavaScript Loaded!' );
});
})( jQuery );
View wpdb-queries-with-meta-data.php
<?php
$results = $wpdb->get_results(
"
SELECT key2.meta_value as cat_id, $wpdb->posts.ID as action_id -- , $wpdb->posts.post_title as title
FROM $wpdb->posts
INNER JOIN $wpdb->postmeta key1
ON $wpdb->posts.ID = key1.post_id
INNER JOIN $wpdb->postmeta key2
ON $wpdb->posts.ID = key2.post_id
WHERE key1.meta_key = 'active'
@fomigo
fomigo / wp-query-ref.php
Last active Aug 29, 2015 — forked from luetkemj/wp-query-ref.php
WP: Query $args
View wp-query-ref.php
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@fomigo
fomigo / meta-fields-from-all-posts.php
Created Jun 19, 2015
how-to-get-a-meta-values-from-all-posts-in-a-special-category
View meta-fields-from-all-posts.php
<?php
// http://wordpress.stackexchange.com/questions/64338/how-to-get-a-meta-value-from-all-post
// https://wordpress.org/support/topic/how-to-get-a-meta-values-from-all-posts-in-a-special-category
function get_meta_values( $key = '', $type = 'post', $status = 'publish' ) {
if( empty( $key ) ) return;
global $wpdb;
$r = $wpdb->get_results( $wpdb->prepare( "
SELECT p.ID, pm.meta_value FROM {$wpdb->postmeta} pm
@fomigo
fomigo / select-from-get.js
Created Jun 15, 2015
select form input elements from GET params
View select-from-get.js
$(function () {
//grab the entire query string
var query = document.location.search.replace('?', '');
//extract each field/value pair
query = query.split('&');
//run through each pair
for (var i = 0; i < query.length; i++) {
//split up the field/value pair into an array
var field = query[i].split("=");
//target the field and assign its value
@fomigo
fomigo / list_hooked_functions.php
Last active Aug 29, 2015
WP_list_hooked_functions
View list_hooked_functions.php
function list_hooked_functions($tag=false){
global $wp_filter;
if ($tag) {
$hook[$tag]=$wp_filter[$tag];
if (!is_array($hook[$tag])) {
trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
return;
}
}
else {
You can’t perform that action at this time.