Skip to content

Instantly share code, notes, and snippets.

Gregory Karpinsky tivnet

Block or report user

Report or block tivnet

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
@tivnet
tivnet / ACE Editor: submit, beautify and minify.html
Last active Sep 19, 2019
ACE Editor: submit, beautify and minify
View ACE Editor: submit, beautify and minify.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ACE Editor: submit, beautify and minify</title>
<style type="text/css" media="screen">
#ace_js, #ace_css {
width: 95%;
height: 15em;
border: 1px solid silver;
@tivnet
tivnet / verup.sh
Created Apr 24, 2017
Plugin/Theme ZIP to Git keeping composer.json
View verup.sh
#!/bin/bash
if test -z ${1}; then
echo "Syntax: ${0} folder-name-same-as-zip-file";
exit 2;
fi
mv ${1} ${1}.S && \
unzip -q ${1}.zip && \
rm ${1}.zip && \
@tivnet
tivnet / a2site.sh
Created Mar 16, 2017
A simplified version of a2ensite/a2dissite. Works under Windows with no symlinking.
View a2site.sh
#!/bin/bash
# A simplified version of a2ensite/a2dissite. Works under Windows with no symlinking.
# Author: Gregory Karpinsky (@tivnet)
if [ ! -d sites-available ]
then
echo "Wrong folder!"
exit 2;
fi
@tivnet
tivnet / apigen-hooks.php
Created Nov 2, 2016
Generate list of hooks (for WPGlobus)
View apigen-hooks.php
<?php
/**
* File: apigen-hooks.php
*
* NOTE: this code is used internally in WPGlobus project.
* It's a W.I.P. - please use it, but do not forget to adapt for your project.
*
* @package WPGlobus\APIGen
* @author Gregory Karpinsky (@tivnet)
*/
@tivnet
tivnet / to-folders-by-date.sh
Created Jul 19, 2016
Split files into folders by EXIF original date
View to-folders-by-date.sh
#!/bin/bash
for f in `find . -name "*.jpg"`; do dd=`exif -t "Date and Time (Original)" --machine-readable $f | cut -f1 -d" " | sed s/:/-/g`; mkdir -p $dd && mv $f $dd/; done
@tivnet
tivnet / wc-api-manager-fix-2.php
Last active Jul 21, 2018
WooCommerce API Manager: Fix 2
View wc-api-manager-fix-2.php
<?php
// plugins/woocommerce-api-manager/includes/class-wc-am-update-api.php
// Add `$response->tested` to show "100% compatible" on the Updates page.
case 'pluginupdatecheck':
$response->id = $post_id;
$response->slug = ! empty( $this->slug ) ? $this->slug : $slug;
$response->plugin = $plugin_name;
$response->new_version = $api_data[ '_api_new_version' ];
$response->url = $api_data[ '_api_plugin_url' ];
@tivnet
tivnet / wc-api-manager-fix-1.php
Last active Oct 5, 2018
WooCommerce API Manager: Fix 1
View wc-api-manager-fix-1.php
<?php
// class WC_Api_Manager_Helpers
// Status can be lowercase.
public function is_user_subscription_active( $status ) {
// Wrong:
// return $status == 'Active' || $status == 'Pending Cancellation' ? true : false;
// Correct:
return ( strtolower( $status ) === 'active' || $status === 'Pending Cancellation' );
}
@tivnet
tivnet / php7-debug-backtrace-change.php
Created May 19, 2016
Demonstration of debug_backtrace change in PHP 7.
View php7-debug-backtrace-change.php
<?php
/**
* Demonstration of debug_backtrace change in PHP 7.
*
* `call_user_func` and `call_user_func_array` do not appear as separate calls in the trace.
*
* @author Gregory Karpinsky (@tivnet)
*/
main();
@tivnet
tivnet / etc-monit-monitrc.d-redis
Last active Jan 21, 2020
Monitoring Redis with Monit : /etc/monit/monitrc.d/redis
View etc-monit-monitrc.d-redis
check host redis.host with address 127.0.0.1
if failed port 6379 protocol redis then alert
check process redis-server with pidfile "/var/run/redis/redis-server.pid"
start program = "/etc/init.d/redis-server start"
stop program = "/etc/init.d/redis-server stop"
if failed host 127.0.0.1 port 6379 then restart
if 5 restarts within 5 cycles then timeout
View Xcel.html
<li id="customize-control-wpglobus_xcel-setting-blog-cats" class="customize-control customize-control-text" style="display: block;">
<label>
<span class="customize-control-title">Exclude Blog Categories</span>
<input type="text" class="wpglobus-customize-control" value="" data-customize-setting-link="wpglobus_xcel-setting-blog-cats" id="wpglobus_xcel-setting-blog-cats">
</label>
</li><li id="customize-control-xcel-setting-blog-cats" class="customize-control customize-control-text" style="display: none;">
<label style="display: none;">
<span class="customize-control-title">Exclude Blog Categories</span>
<span class="description customize-control-description">Enter the ID's of the post categories you'd like to EXCLUDE from the Blog, enter only the ID's with a minus sign (-) before them, separated by a comma (,)<br>Eg: "-13, -17, -19"<br>If you enter the ID's without the minus then it'll show ONLY posts in those categories.</span>
<inpu
You can’t perform that action at this time.