Skip to content

Instantly share code, notes, and snippets.

@organizm
organizm / wp_shortcode.php
Last active May 30, 2016 09:36
Класс создает шорткод, и подгружает скрипты только там где выводится шорткод. #wordpress
<?php
class foobar_shortcode {
static $add_script;
static function init () {
add_shortcode('foobar', array(__CLASS__, 'foobar_func'));
add_action('init', array(__CLASS__, 'register_script'));
add_action('wp_footer', array(__CLASS__, 'print_script'));
}
static function foobar_func( $atts ) {
self::$add_script = true;
@organizm
organizm / gist:d245fc815e921be59153
Last active June 1, 2016 07:46
JQuery decimal count animated #jquery
jQuery(function($) {
$('.timer').countTo({
from: 0,
to: 4.89,
speed: 4000,
refreshInterval: 1,
onComplete: function(value) {
console.debug(this);
}
});
@organizm
organizm / Magento_clean_up.php
Last active June 13, 2017 11:16
Magento clean up #magento
<?php
switch($_GET['clean']) {
case 'log':
clean_log_tables();
break;
case 'var':
clean_var_directory();
break;
}
@organizm
organizm / Vagrantfile
Last active September 6, 2016 22:38
Vagrant file for lxc conteiner with Ubuntu 12 (precise64) #vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@organizm
organizm / Media_class.php
Last active June 15, 2016 14:06
Media class for Wordpress. Can generate video HTML with preview image. #wordpress
<?php
/**
* Клас для обработки видео ссылок и генерации HTML видео.
* User: Alex
* Date: 24.09.2014
* Time: 17:32
*/
class wpc_media
{
@organizm
organizm / pupkey
Created May 30, 2016 09:40
NO_PUBKEY Error. Set pupkey #linux
gpg --keyserver pgpkeys.mit.edu --recv-key 010908312D230C5F
gpg -a --export 010908312D230C5F | sudo apt-key add -
@organizm
organizm / msttcorefonts
Created June 1, 2016 07:49
Установка msttcorefonts (шрифтов Microsoft) на Ubuntu #linux
sudo apt install msttcorefonts
sudo fc-cache -fv
@organizm
organizm / wc-sort-by-default.php
Created June 27, 2016 14:40
WooCommerce - Change default catalog sort order #woocommerce #wordpress
<?php
/**
* This code should be added to functions.php of your theme
**/
add_filter('woocommerce_default_catalog_orderby', 'imperialfashion_custom_default_catalog_orderby');
function imperialfashion_custom_default_catalog_orderby() {
return 'date'; // Can also use title and price
}
@organizm
organizm / find_rm.sh
Last active July 5, 2016 10:20
Удалить из папки ооочень большое колическтво файлов, когда ln ls не может даже отобразить. #linux
postdrop: warning: mail_queue_enter: create file maildrop/327454.25698: No space left on device
find dir_name/ -type f -name "*" -exec rm -f {} \; - #wery slow for many files
find session/ -type f -delete; #will perform better because it doesn't have to spawn an external process for each and every matched file.
@organizm
organizm / start_chrome_desctop.sh
Last active January 9, 2022 11:33
How to install end start chrome remote desctop #ubuntu
Mostly from https://aur.archlinux.org/packages/chrome-remote-desktop/?comments=all but with some of my changes.
1. I manually created the chrome-remote-desktop group, and added myself to it.
2. I manually created the ~/.chrome-remote-desktop-session file with "exec startxfce4" in it.
3. I manually created the ~/.config/chrome-remote-desktop directory.
4. mkdir /etc/chromium-browser/native-messaging-hosts
4. ln -s /etc/opt/chrome/native-messaging-hosts/* /etc/chromium-browser/native-messaging-hosts/
You should now have a 'Enable Remote Connection' button on the CRD extension page.