Skip to content

Instantly share code, notes, and snippets.

caratage

Block or report user

Report or block caratage

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
View keybase.md

Keybase proof

I hereby claim:

  • I am caratage on github.
  • I am caratage (https://keybase.io/caratage) on keybase.
  • I have a public key ASCFS7elX_L7uAoF9l42kY56fQSakUaueh0-QYRY9w8Lpwo

To claim this, I am signing this object:

@caratage
caratage / example.java
Last active May 7, 2018
Implementation of Java equals function
View example.java
public class Example {
private int value;
//getters and setters, constructor
@Override
public boolean equals(Object o) {
// same address
if (o == this) return true;
// other type
if (!(o instanceof Example)) {
return false;
View osx-iconservices-help.sh
#!/bin/sh
mkdir ${TMPDIR}/com.apple.IconServices
@caratage
caratage / osx-show-hidden-files.sh
Last active Apr 27, 2018
OSX - show hidden files
View osx-show-hidden-files.sh
#!/bin/bash
# defaults write com.apple.finder AppleShowAllFiles NO
defaults write com.apple.finder AppleShowAllFiles YES
killall Finder /System/Library/CoreServices/Finder.app
@caratage
caratage / gist:11402593
Created Apr 29, 2014
Check if image is in portrait or landscape orientation
View gist:11402593
var someImg = $("#someId");
if (someImg.width() > someImg.height()){
//it's a landscape
} else if (someImg.width() < someImg.height()){
//it's a portrait
} else {
//image width and height are equal, therefore it is square.
}
@caratage
caratage / index.php
Created Apr 21, 2013
Custom Taxonomy - Conditional Tag
View index.php
if (is_object_in_term( $post->ID, 'taxonomy-slug' )) {
// do something
}
@caratage
caratage / functions.php
Created Apr 21, 2013
Protected Posts - Custom Form, Message, Title
View functions.php
/**********************************************
* Custom Password Form
**********************************************/
add_filter( 'the_password_form', 'custom_password_form' );
function custom_password_form() {
global $post;
$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
$o = '<form class="protected-post-form form-inline" action="' . get_option('siteurl') . '/wp-login.php?action=postpass" method="post">
@caratage
caratage / functions.php
Created Dec 9, 2012
Sort admin columns by meta key query
View functions.php
/**********************************************
* Sort columns for TOUR DATE post type
**********************************************/
function set_date_post_types_admin_order($wp_query) {
if (is_admin()) {
// Get the post type from the query
$post_type = $wp_query->query['post_type'];
@caratage
caratage / Asset.php
Created Dec 4, 2012 — forked from SubZane/Asset.php
WordPress: get_attachment_id_from_src
View Asset.php
function get_attachment_id_from_src ($src) {
global $wpdb;
$reg = "/-[0-9]+x[0-9]+?.(jpg|jpeg|png|gif)$/i";
$src1 = preg_replace($reg,'',$src);
if($src1 != $src){
$ext = pathinfo($src, PATHINFO_EXTENSION);
$src = $src1 . '.' .$ext;
}
$query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$src'";
$id = $wpdb->get_var($query);
@caratage
caratage / query.php
Created Nov 28, 2012
Variants of query_posts
View query.php
// http://www.binarymoon.co.uk/2010/03/5-wordpress-queryposts-tips/
<?php
$query = 'posts_per_page=10';
$queryObject = new WP_Query($query);
// The Loop...
if ($queryObject->have_posts()) {
while ($queryObject->have_posts()) {
$queryObject->the_post();
the_title();
You can’t perform that action at this time.