Skip to content

Instantly share code, notes, and snippets.

View mihdan's full-sized avatar
:octocat:
Code is poetry

Mikhail Kobzarev mihdan

:octocat:
Code is poetry
View GitHub Profile
@mihdan
mihdan / codeable.io.conf
Created September 28, 2015 09:36 — forked from tomazzaman/codeable.io.conf
Codeable.io Nginx config
server {
include /home/webmaster/www/codeable.io.conf;
server_name codeable.io;
listen 443 ssl spdy default_server;
root /home/webmaster/www/codeable.io;
index index.php index.html;
error_log /var/log/nginx/codeable.io.error.log warn;
@mihdan
mihdan / functions.php
Created October 15, 2015 13:09
MailChimp for WordPress + Scroll Triggered Boxes. Don't show boxes for subscribers.
<?php
// ..........................
// your functions.php content
// ..........................
// copy paste the following functions anywhere in your theme its functions.php file
function my_prefix_set_mailchimp_cookie($email, $merge_vars, $form_id, $result) {
if($result == true) {
@mihdan
mihdan / cors-nginx.conf
Created October 19, 2015 20:10 — forked from michiel/cors-nginx.conf
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@mihdan
mihdan / Slack theme for Wordpress
Created November 20, 2015 15:00 — forked from hlashbrooke/Slack theme for WordPress
Slack theme for the Wordpress channel. To use this theme, go to the 'Sidebar Theme' tab in your preferences pane and add this text to the custom theme field.
#21759B,#464646,#D54E21,#FFFFFF,#464646,#FFFFFF,#D54E21,#D54E21
@mihdan
mihdan / gist:a01ded16f0a526551b21
Created December 8, 2015 09:37 — forked from mikejolley/gist:3969579
WooCommerce - Create a coupon via PHP
$coupon_code = 'UNIQUECODE'; // Code
$amount = '10'; // Amount
$discount_type = 'fixed_cart'; // Type: fixed_cart, percent, fixed_product, percent_product
$coupon = array(
'post_title' => $coupon_code,
'post_content' => '',
'post_status' => 'publish',
'post_author' => 1,
'post_type' => 'shop_coupon'
@mihdan
mihdan / mstar-menu-limit.php
Created February 18, 2016 10:25 — forked from GhostToast/mstar-menu-limit.php
Increase the posts per page in WordPress menu panel
<?php
/*
Plugin Name: Mstar Menu Limit
Description: Increase the posts per page in menu panel
Plugin URI: http://ghosttoa.st
Author: Gustave F. Gerhardt
Author URI: http://ghosttoa.st
License: GPL2
Version: .9
*/
@mihdan
mihdan / gist:a471e25332f838a3aaf7
Last active October 26, 2016 12:30 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

VKontakte

@mihdan
mihdan / SyntaxHighlighter-to-Pastacode
Created February 25, 2016 22:25 — forked from tutweb/SyntaxHighlighter-to-Pastacode
Replace SyntaxHighlighter format to Pastacode
UPDATE wp_posts SET post_content = REPLACE ( post_content, '[html]
', '[pastacode lang="markup" message="" highlight="" provider="manual"]
<pre><code>');
UPDATE wp_posts SET post_content = REPLACE ( post_content, '
[/html]', '</code></pre>
[/pastacode]');
UPDATE wp_posts SET post_content = REPLACE ( post_content, '[css]
', '[pastacode lang="css" message="" highlight="" provider="manual"]
@mihdan
mihdan / wp-beta-setup.sh
Created March 28, 2016 11:26 — forked from morganestes/wp-beta-setup.sh
Set up a WordPress site for beta testing with wp-cli.
#!/usr/bin/env sh
# Install the Beta Tester plugin and set it to "Bleeding Edge" releases.
# Note: after installing plugin and setting the option, you may need to visit
# the site once before updating core version.
wp-beta() {
wp plugin install wordpress-beta-tester --activate
wp option set wp_beta_tester_stream unstable
wp core update
@mihdan
mihdan / Credit Card Generator
Created May 27, 2016 21:34 — forked from B-Con/Credit Card Generator
This JavaScript function generates random number strings that pass the Luhn checksum, the test that credit card numbers must conform to. It assumes there is an HTML radio input to indicate which company issued the card. This code is from my webpage here: http://bradconte.com/cc_generator.html.
// Copyright (c) 2015, Brad Conte (http://bradconte.com)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.