Skip to content

Instantly share code, notes, and snippets.

View mch0lic's full-sized avatar

Mindaugas Budreika mch0lic

View GitHub Profile
@benschwarz
benschwarz / index.html
Last active November 6, 2023 21:10
Using ARIA roles with <header>, <footer> and <aside>
<!doctype html>
<html>
<body>
<header role="banner">
<a href="/" rel="home">My company</a>
<nav role="navigation">
<a href="/about">About</a>
<a href="/contact">Contact</a>
</nav>
</header>
@jasny
jasny / mysql_splitdump.sh
Last active February 15, 2024 16:13
Split MySQL dump SQL file into one file per table or extract a single table
#!/bin/bash
####
# Split MySQL dump SQL file into one file per table
# based on http://blog.tty.nl/2011/12/28/splitting-a-database-dump
####
if [ $# -lt 1 ] ; then
echo "USAGE $0 DUMP_FILE [TABLE]"
exit
@mrinterweb
mrinterweb / deploy.rb
Created July 25, 2012 02:46
Wordpress site deployment using capistrano
set :application, 'www.mysite.com'
set :deploy_to, "/srv/www.mysite.com"
set :domain, "www.mysite.com"
set :user, "deploymentuser"
set :scm, :git
set :repository, "git@github.com:myusername/myproject.git"
set :branch, :master
set :deploy_via, :remote_cache
set :copy_exclude, ['.git']
ssh_options[:forward_agent] = true
@pento
pento / commercial-client.php
Created July 2, 2013 12:29
Sample Commercial Plugin update server and client
<?php
/*
* Plugin Name: Commercial Client
* Plugin URI: http://pento.net/
* Description: A sample client plugin for showing updates for non-WordPress.org plugins
* Author: pento
* Version: 0.1
* Author URI: http://pento.net/
* License: GPL2+
*/
@hissy
hissy / gist:7352933
Created November 7, 2013 11:07
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,
@bocharsky-bw
bocharsky-bw / .htaccess
Created June 19, 2014 10:10
The .htaccess example for Symfony Framework project that deployed on shared hosting.
#path/to/project/.htaccess
# Rewrite all requests to subdirectory, except exists file requests
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /web/$1 [QSA,L]
</IfModule>
@cferdinandi
cferdinandi / terminal-cheat-sheet.txt
Last active July 22, 2024 20:51
Terminal Cheat Sheet
# Terminal Cheat Sheet
pwd # print working directory
ls # list files in directory
cd # change directory
~ # home directory
.. # up one directory
- # previous working directory
help # get help
-h # get help
@ianmstew
ianmstew / Vagrantfile
Created August 20, 2014 12:43
vagrant-parallels
# -*- mode: ruby -*-
# vi: set ft=ruby :
require "rbconfig"
HOST_NAME = "prerender"
VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 1.5"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
@frozonfreak
frozonfreak / function.php
Last active November 20, 2018 15:54
WooCommerce apply coupon for regular price instead of sale price
add_filter('woocommerce_coupon_get_discount_amount', 'woocommerce_coupon_get_discount_amount', 10, 5 );
function woocommerce_coupon_get_discount_amount( $discount, $discounting_amount, $cart_item, $single, $coupon ) {
if ($coupon->type == 'percent_product' || $coupon->type == 'percent') {
global $woocommerce;
$cart_total = 0;
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
$variable_product1= new WC_Product_Variation( $cart_item["variation_id"] );
@growdev
growdev / gist:b68e35b5c6e0856bdbf1
Created March 19, 2015 19:01
Delete all WooCommerce Products with wp-cli
wp post list --field=ID --post_type=product | xargs wp post delete --force