Skip to content

Instantly share code, notes, and snippets.

View BKeanu1989's full-sized avatar

Kevin Fechner BKeanu1989

View GitHub Profile
@BKeanu1989
BKeanu1989 / bill_data.sql
Last active January 11, 2017 02:42
wordpress/woocommerce: bill data for artists. example december 2016 && exclude service email
CREATE TEMPORARY TABLE ALL_ORDERS_IN_GIVEN_TIMEFRAME (
SELECT ALL_ORDERS_IN_GIVEN_TIMEFRAME_PLAIN.order_item_id, ALL_ORDERS_IN_GIVEN_TIMEFRAME_PLAIN.product_name, ALL_ORDERS_IN_GIVEN_TIMEFRAME_PLAIN.post_date, meta_value AS email FROM (SELECT ITEMS.order_item_id, ITEMS.order_item_name AS product_name, ITEMS.order_id, MAIN_POSTS.post_date FROM wp_mokkamerch_posts AS MAIN_POSTS
JOIN wp_PREFIX_woocommerce_order_items AS ITEMS ON MAIN_POSTS.ID = ITEMS.order_id
WHERE DATE(MAIN_POSTS.post_date) BETWEEN "2016-12-01" AND "2017-01-01" AND (MAIN_POSTS.post_status = "wc-completed" OR MAIN_POSTS.post_status = "wc-production") AND ITEMS.order_item_type = "line_item") AS ALL_ORDERS_IN_GIVEN_TIMEFRAME_PLAIN
JOIN wp_PREFIX_postmeta AS MAIN_POSTMETA ON ALL_ORDERS_IN_GIVEN_TIMEFRAME_PLAIN.order_id = MAIN_POSTMETA.post_id AND MAIN_POSTMETA.meta_key = "_billing_email" AND MAIN_POSTMETA.meta_value <> 'EXCLUDE@SERVICE-EMAIL.com'
);
CREATE TEMPORARY TABLE ITEMMETA_SUMMARY (
@BKeanu1989
BKeanu1989 / live-to-local-wp.sql
Last active November 29, 2018 13:17
From live to local Wordpress
-- variables: PREFIX; URL; HTDOCS_DIR
-- TODO/TRY UPDATE PREFIXposts SET guid = replace(guid, 'URL', 'http://localhost:8888/HTDOCS_DIR');
UPDATE PREFIXoptions SET option_value = replace(option_value, 'URL', 'http://localhost:8888/HTDOCS_DIR') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE PREFIXposts SET post_content = replace(post_content, 'URL', 'http://localhost:8888/HTDOCS_DIR');
UPDATE PREFIXpostmeta SET meta_value = replace(meta_value, 'URL','http://localhost:8888/HTDOCS_DIR');
@BKeanu1989
BKeanu1989 / bill_data.php
Created January 11, 2017 13:06
bill_data_php - whitespace kills php script-queries
<?php $ALL_ORDERS_IN_GIVEN_TIMEFRAME = $wpdb->query('CREATE TEMPORARY TABLE ALL_ORDERS_IN_GIVEN_TIMEFRAME (SELECT ALL_ORDERS_IN_GIVEN_TIMEFRAME_PLAIN.order_item_id, ALL_ORDERS_IN_GIVEN_TIMEFRAME_PLAIN.product_name, ALL_ORDERS_IN_GIVEN_TIMEFRAME_PLAIN.post_date, meta_value AS email FROM (SELECT ITEMS.order_item_id, ITEMS.order_item_name AS product_name, ITEMS.order_id, MAIN_POSTS.post_date FROM wp_PREFIX_posts AS MAIN_POSTS JOIN wp_PREFIX_woocommerce_order_items AS ITEMS ON MAIN_POSTS.ID = ITEMS.order_id WHERE DATE(MAIN_POSTS.post_date) BETWEEN "2016-12-01" AND "2017-01-01" AND (MAIN_POSTS.post_status = "wc-completed" OR MAIN_POSTS.post_status = "wc-production") AND ITEMS.order_item_type = "line_item") AS ALL_ORDERS_IN_GIVEN_TIMEFRAME_PLAIN JOIN wp_PREFIX_postmeta AS MAIN_POSTMETA ON ALL_ORDERS_IN_GIVEN_TIMEFRAME_PLAIN.order_id = MAIN_POSTMETA.post_id AND MAIN_POSTMETA.meta_key = "_billing_email" AND MAIN_POSTMETA.meta_value <> "service@mokka-merch.com");');
$ITEMMETA_SUMMARY = $wpdb->query('CREATE TE
ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
/Applications/MAMP/Library/bin/mysql
/usr/local/mysql/bin/mysql -u {username} -p {databasename} < file_name.sql
@BKeanu1989
BKeanu1989 / add gitignore after commit.txt
Created January 26, 2017 16:49
add gitignore after commit
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
@BKeanu1989
BKeanu1989 / listCookies()
Last active February 9, 2017 14:01
listCookies.js
function listCookies() {
var theCookies = document.cookie.split(';');
var aString = '';
for (var i = 1 ; i <= theCookies.length; i++) {
aString += i + ' ' + theCookies[i-1] + "\n";
}
return aString;
}
listCookies();
@BKeanu1989
BKeanu1989 / waitForElementToAppear.js
Created February 18, 2017 18:48
Wait for element to appear, setTimeout
function waitForElementToAppear(selector, time) {
if(document.querySelector(selector)!=null) {
alert("The element is displayed, you can put your code instead of this alert.");
return;
}
else {
setTimeout(function() {
waitForElementToAppear(selector, time);
}, time);
}
# sudo nano /etc/nginx/sites-enabled/default
# HTTP — redirect all traffic to HTTPS
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
return 301 https://$host$request_uri;
}
# HTTPS — proxy all requests to the Node app
db.createUser(
{
user: "XXX",
pwd: "XXX",
roles: [ { role: "root", db: "admin" } ]
}
)
mongoimport -u 'ACTUALUSERNAME' -p 'PASSWORD' --authenticationDatabase admin -d DATABASE -c COLLECTION --type csv --file FILEPATH.csv --headerline
pm2 start ecosystem.config.js --env production_mongodb
scp /path/to/file username@a:/path/to/destination
tar -czvf foo-bar.tar.gz `find foo-bar*`
find ./order-export-* -maxdepth 0 -type f -delete