Skip to content

Instantly share code, notes, and snippets.

View abachuk's full-sized avatar
✍️
dev manager by day, writing code at night

Alex Bachuk abachuk

✍️
dev manager by day, writing code at night
View GitHub Profile
// The actual grunt server settings
connect: {
options: {
port: 9000,
hostname: 'localhost',
livereload: 35729
},
proxies: [{
context: '/api', // the context of the data service
host: 'mydomain.com/apis/', // wherever the data service is running
@abachuk
abachuk / index.php
Created June 7, 2015 18:45
WordPress plugin extending CMB2 metaboxes
<?php
/*
Plugin Name: NDM metaboxes
Description: portfolio metaboxes for NDM
Version: 0.11
Author: Alex Bachuk
Author URI: http://alexbachuk.com
License: GPL2
*/
?>
<?php class slider_widget extends WP_Widget {
function slider_widget() {
$widget_options = array(
'classname' => 'slider',
'description' => 'add promo slider'
);
parent::WP_Widget(false, 'Promotional Slider', $widget_options);
@abachuk
abachuk / gist:2373381
Created April 13, 2012 03:23
WP example 1
<?php
/**
* Template Name: Business Rankings
* @package WordPress
*/
get_header();
?>
<aside class="right-sidebar">
<ul class="widgets">
@abachuk
abachuk / Custom Post type meta box for WordPress
Created July 28, 2012 22:58
Custom Post type meta box for WordPress (extension to CPT)
/******* RELATED PAGES METABOX *********/
add_action( 'cmb_render_select_post', 'rrh_cmb_render_select_post', 10, 2 );
function rrh_cmb_render_select_post( $field, $meta ) {
global $posts;
$posts = get_posts( array( 'post_type' => 'page', 'posts_per_page' => -1 ));
echo '<select name="', $field['id'], '" id="', $field['id'], '">';
foreach ($posts as $option) {
echo '<option value="', $option->ID, '"', $meta == $option->ID ? ' selected="selected"' : '', '>', $option->post_title, '</option>';
}
echo '</select>';
@abachuk
abachuk / jqm-hacks
Created July 31, 2012 15:04
jQuery Mobile hacks and fixes
/********** iOS rotation zoom fix **********/
var viewport = $('meta[name="viewport"]');
var nua = navigator.userAgent;
if ((nua.match(/iPad/i)) || (nua.match(/iPhone/i)) || (nua.match(/iPod/i))) {
viewport.attr('content', 'width=device-width, minimum-scale=1.0, maximum-scale=1.0');
$('body')[0].addEventListener("gesturestart", gestureStart, false);
}
function gestureStart() {
@abachuk
abachuk / gist:4703394
Last active December 12, 2015 02:58
meta box code example
$meta_boxes[] = array(
'id' => 'home_page_metabox2',
'title' => 'Preview',
'pages' => array( 'page', ), // Post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'show_on' => array( 'key' => 'page-template', 'value' => 'page_home.php' ),
'fields' => array(
array(
@abachuk
abachuk / gist:5485177
Last active December 16, 2015 19:29
WordPress + Backbone
//NAMESPCING APP
var App = {
Models : {},
Collections: {},
Views: {},
Router: {}
};
//DECLARING MODEL
App.Models.Post = Backbone.Model.extend({});
@abachuk
abachuk / ajax polling
Created May 1, 2013 19:43
Ajax Polling
(function(exports, document, $) {
var window = exports;
var RecentGiftsController = function(mediator) {
var mediator = mediator;
var pollingProcess = null;
var url = '/ajax/get-recent-gifts';
var buffer = [];
@abachuk
abachuk / gist:5658751
Created May 27, 2013 19:41
getting blog posts with ajax request in JSON format
blog: function(){
$.ajax({
url: 'http://alexbachuk.com/api/get_recent_posts/',
type: 'GET',
dataType: 'json',
success: function(data){
console.log(data);
},
error: function(data){
console.log(data);