Skip to content

Instantly share code, notes, and snippets.

View ivankravchenko's full-sized avatar
🐌
moving fast

Ivan Kravchenko ivankravchenko

🐌
moving fast
View GitHub Profile
@ivankravchenko
ivankravchenko / se7ensky-breadcrumbs.php
Last active December 11, 2015 20:38
Simple breadcrumbs plugin, which is based on current URI location
<?php
function the_breadcrumbs($uri = null) {
$displayHome = false;
$displayThis = false;
$homepageId = 105;
if ($uri == null) {
$uri = $_SERVER['REQUEST_URI'];
$displayHome = true;
$displayThis = true;
<?php
function new_excerpt_more($more) {
global $post;
//return '<a class="read-more" href="'. get_permalink($post->ID) . '">' . $more . '</a>';
return '... <a class="read-more" href="'. get_permalink($post->ID) . '">&gt;</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
function improved_trim_excerpt($text) {
$ ->
$.fn.iphoneMenu = ->
$.each @, -> initiateIphoneMenu @
@ # chaining
$.fn.iphoneBreadcrumbs = (pageMenuSelector) ->
$.each @, -> initiateIphoneBreadcrumbs @, pageMenuSelector
@ # chaining
initiateIphoneBreadcrumbs = (el, pageMenuSelector) ->
@ivankravchenko
ivankravchenko / wp_query_date_range.php
Last active December 21, 2015 14:48 — forked from graemegeorge/WP_query and date range filter
Wordpress wp_query date range date_from date_to filter.
<?php
// https://gist.github.com/krava/6322195
// Wordpress wp_query date range date_from date_to filter.
add_filter('posts_where', 'wapp_filter_posts_where');
function wapp_filter_posts_where($where) {
global $wp_query;
if (isset($wp_query->query['date_from']) && isset($wp_query->query['date_to'])) {
$date_from = $wp_query->query['date_from'];
$date_to = $wp_query->query['date_to'];
@ivankravchenko
ivankravchenko / wp-jsonapi-sencha-filters.php
Created September 24, 2013 11:51
Wordpress JSON-API support for Sencha Ext.Store filters
<?php
// Wordpress JSON-API support for Sencha Ext.Store filters
// https://gist.github.com/krava/6683621
add_action('json_api-core-get_recent_posts', 'wapp_customize_get_recent_posts');
function wapp_customize_get_recent_posts() {
// filter: [{"property":"category","value":"1"},...] -> cat=:id, ...
global $wp_query;
if (isset($_GET['filter'])) {
$filter = json_decode(stripslashes($_GET['filter']));
@ivankravchenko
ivankravchenko / gist:7155475
Last active December 26, 2015 12:59
pizza ux ok
a = data.customer.addresses
shipTo = if a.home.street and a.work.street
d = new Date
if 1 <= d.getDay() <= 5 and 9 <= d.getHours() <= 18
a.work
else
a.home
else if a.home.street
a.home
else if a.work.street
@ivankravchenko
ivankravchenko / edge
Created November 29, 2013 16:57
handy hipache provision script installation: curl https://gist.github.com/krava/7708703/raw/3c4828c832ec63c66575339f0d1cd7647b0cc62c/edge > /sbin/edge && chmod u+x /sbin/edge
#!/bin/bash
COMMAND=$1
HOST=$2
case $COMMAND in
add)
shift;shift
if [[ ! $HOST ]]; then
echo No host specified.
@ivankravchenko
ivankravchenko / gist:11169416
Last active March 9, 2016 23:14
digitalocean create /swapfile
fallocate -l 1G /swapfile
chown root:root /swapfile
chmod 0600 /swapfile
mkswap /swapfile
swapon /swapfile
echo /swapfile none swap sw 0 0 >> /etc/fstab
echo vm.swappiness = 10 | tee -a /etc/sysctl.conf
echo vm.vfs_cache_pressure = 50 | tee -a /etc/sysctl.conf
sysctl -p
@ivankravchenko
ivankravchenko / gist:11169976
Last active August 29, 2015 14:00
install new flynn
# server sshd must not be at port 22
IP=$(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}')
docker run -v=/var/run/docker.sock:/var/run/docker.sock -p=1113:1113 --name flynn-host -d flynn/host -external $IP
# give host time to initialize
sleep 10
docker run -e=DISCOVERD=$IP:1111 flynn/bootstrap
@ivankravchenko
ivankravchenko / wp-switch-domain
Created May 29, 2014 16:07
Script for switching WordPress domain. It fixes serialization problems.
#!/usr/bin/php
<?php
$oldDomain = $argv[1];
$domain = $argv[2];
$inputSQL = file_get_contents('php://stdin');
$replacedDomainSQL = str_replace($oldDomain, $domain, $inputSQL);
$fixedSerializeSQL = preg_replace(