Skip to content

Instantly share code, notes, and snippets.

View bondarolik's full-sized avatar
🖥️
Coding now

V. Bruk bondarolik

🖥️
Coding now
View GitHub Profile
@bondarolik
bondarolik / sendform.js
Created August 30, 2012 00:10
Простая jquery функция для ajax запросов
function sendFeedback() {
$.post('url_to_post.php',
$('#feedbackForm').serialize(), function(data) {
var datamsg = data.split('!');
$('#message-area').hide();
if (datamsg[0] != 'Ошибка') {
// messages
$('#message-area').removeClass('error');
$('#message-area').addClass('success').show('slow');
} else {
@bondarolik
bondarolik / sendform.php
Created August 30, 2012 00:14
Simple function to send php form
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
$user_name = trim($_POST['name']);
$user_email = trim($_POST['email']);
$user_message = trim($_POST['message']);
$action = trim($_POST['action']);
if (strlen($user_name) == 0) { echo "Error! Представьтесь, пожалуйста."; exit(); }
if (strlen($user_email) == 0) { echo "Error! Введите ваш емайл."; exit(); }
if (strlen($user_message) == 0) { echo "Error! Сообщение не может быть пустым."; exit(); }
@bondarolik
bondarolik / autoheight.js
Created August 30, 2012 00:17
Set height of div based on the highest div in columns
$(document).ready(function() {
var sidebarHeight = $("#sidebar").height();
var contentHeight = $("#workarea").height();
if (contentHeight > sidebarHeight) {
$("#sidebar").height(contentHeight).slideDown("slow");
}
});
@bondarolik
bondarolik / functions.php
Created August 30, 2012 03:14
Custom breadcrumbs function for WordPress
function breadcrumbs() {
#### Пример:
#### <a href="#">Главная</a> » <a href="#">Название Категории</a> » Название записи
# Predefined variables
#global $wp, $post;
$link_EOS = '<a href="';
$link_CON = '">';
$link_EOF = '</a>';
$sep = " » "; # important to put it between two spaces
@bondarolik
bondarolik / functions.php
Created August 30, 2012 03:16
Add rel="fancybox" to wp_attachments
add_filter( 'wp_get_attachment_link', 'add_fancybox_rel');
function add_fancybox_rel ($content) {
// add checks if you want to add prettyPhoto on certain places (archives etc).
return str_replace('<a', '<a rel="fancybox"', $content);
}
@bondarolik
bondarolik / functions.php
Created August 30, 2012 03:17
Better SEO wp_title()
# Rewrite <title> tag for better SEO
function seo_title() {
global $post, $page, $paged;
$sep = " | "; # Separator
$newtitle = get_bloginfo('name'); # Default
# Single page ########################################
if (is_single() || is_page()) {
$newtitle = single_post_title("", false); # default title
}
@bondarolik
bondarolik / header.php
Created August 30, 2012 03:22
Custom keywords including tags and category list within (hardcoded in header.php)
<meta name='keywords' content='<?php echo $keywords; ?>' />
<meta name='description' content='<?php echo $description; ?>' />
@bondarolik
bondarolik / Rails_Mysql2_lib
Created January 9, 2013 19:35
Rails. Fixing mysql2 lib not found problem.
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
class DiscogsController < ApplicationController
before_filter :authenticate_user!
before_filter :check_admin
before_filter do
@discogs = Discogs::Wrapper.new("APP_NAME", access_token: session[:access_token])
end
def index
@items_with_discogs = Item.all # Items should have discogs_release_id
@bondarolik
bondarolik / mercadopago_payment_status
Created June 27, 2016 17:38
How to verify Mercadopago payment status and update it remotly
def check_payment_status
# Prepare for search collection
search_hash = { external_reference: params[:id] }
####################################### INIT MERCADOPAGO API
client_id = 'xxxxx'
client_secret = 'xxxxxxx'
mp_client = MercadoPago::Client.new(client_id, client_secret)
hash = mp_client.search(search_hash)