Skip to content

Instantly share code, notes, and snippets.

Avatar

Trajche TJ Kralev trajche

  • Helsinki, Finland
View GitHub Profile
@trajche
trajche / wp-dl-install.sh
Last active Oct 5, 2021
Download and install a WP instance (Mac, Valet, MySQL)
View wp-dl-install.sh
mysql -u root -e "create database wp_sitename";
wp core download
wp config create --dbname=wp_sitename --dbuser=root --dbpass=
wp core install --url=https://woocommerce.test --title=WooCommerce --admin_user=admin --admin_password=admin --admin_email=trajche@kralev.eu
wp plugin uninstall akismet
wp plugin uninstall hello
wp plugin install woocommerce
@trajche
trajche / mac
Last active Oct 26, 2021
new mac set-up
View mac
#Homebrew, Ohmy.sh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
#Defaults
brew install --cask google-chrome
brew install --cask tunnelblick
#Communication Tools
brew install --cask slack
@trajche
trajche / WonderCMSValetDriver.php
Created Jan 17, 2021
Valet Driver for WonderCMS
View WonderCMSValetDriver.php
<?php
class WonderCMSValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
@trajche
trajche / home-server.md
Created Oct 27, 2020 — forked from nileshtrivedi/home-server.md
Home Server setup: Raspberry PI on Internet via reverse SSH tunnel
View home-server.md

Raspberry Pi on Internet via reverse SSH tunnel

HackerNews discussed this with many alternative solutions: https://news.ycombinator.com/item?id=24893615

I already have my own domain name: mydomain.com. I wanted to be able to run some webapps on my Raspberry Pi 4B running perpetually at home in headless mode (just needs 5W power and wireless internet). I wanted to be able to access these apps from public Internet. Dynamic DNS wasn't an option because my ISP blocks all incoming traffic. ngrok would work but the free plan is too restrictive.

I bought a cheap 2GB RAM, 20GB disk VM + a 25GB volume on Hetzner for about 4 EUR/month. Hetzner gave me a static IP for it. I haven't purchased a floating IP yet.

View test.skema
[{"name":"hello","color":"Red","position":{"x":186,"y":214},"increment":false,"timestamp":false,"softdelete":false,"column":[{"name":"id","type":"increments","length":"","defaultvalue":"","enumvalue":"","ai":false,"pk":false,"nu":false,"ui":false,"in":false,"un":false,"fillable":false,"guarded":false,"visible":false,"hidden":false,"colid":"c23","order":0},{"name":"name","type":"increments","length":"","defaultvalue":"","enumvalue":"","ai":false,"pk":false,"nu":false,"ui":false,"in":false,"un":false,"fillable":false,"guarded":false,"visible":false,"hidden":false,"colid":"c31","order":1}],"relation":[{"extramethods":"","foreignkeys":"","name":"relation","relatedmodel":"users","relationtype":"hasOne","usenamespace":""}],"seeding":[]},{"name":"users","color":"Blue","position":{"x":841,"y":361},"increment":false,"timestamp":false,"softdelete":false,"column":[{"name":"12321","type":"increments","length":"","defaultvalue":"","enumvalue":"","ai":false,"pk":false,"nu":false,"ui":false,"in":false,"un":false,"fillable":
@trajche
trajche / allow-admin-coupons-fix.patch
Created Apr 22, 2020
Patch for allowing admins to create Dokan coupons.
View allow-admin-coupons-fix.patch
From 962ea6ad8940dc9339423e1fbc7e01a40db75c99 Mon Sep 17 00:00:00 2001
From: TJ <trajche@kralev.eu>
Date: Thu, 23 Apr 2020 02:52:55 +0300
Subject: [PATCH] applying fix from
https://github.com/weDevsOfficial/dokan/pull/685
---
includes/Admin/Settings.php | 11 ++
includes/Commission.php | 6 +-
includes/Order/Hooks.php | 86 +++++++++++++-
@trajche
trajche / wp-one-liner
Created Dec 11, 2019
One liner for WordPress download and unpacking in the current directory.
View wp-one-liner
curl -O https://wordpress.org/latest.zip && unzip latest.zip && rm latest.zip && mv wordpress/* ./ && rm -r wordpress/
@trajche
trajche / headerparser.php
Last active Nov 5, 2019
link rel parser for headers in shopify / github
View headerparser.php
function returnHeaderArray($linkHeader) {
$cleanArray = [];
if (strpos($linkHeader, ',') !== false) {
//Split into two or more elements by comma
$linkHeaderArr = explode(',', $linkHeader);
} else {
//Create array with one element
$linkHeaderArr[] = $linkHeader;
@trajche
trajche / delete-all-products.php
Last active Jul 2, 2019 — forked from mikaelz/delete-all-woocommerce-products.php
Remove all WooCommerce products from database via SQL
View delete-all-products.php
<?php
require dirname(__FILE__).'/wp-blog-header.php';
//Removing attributes (does not work for some reason, should read up on https://www.webhat.in/article/woocommerce-tutorial/how-product-attribute-are-stored-in-database/)
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')");
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'");
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id NOT IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)");
//Removing products and product variations
@trajche
trajche / multiple-select-woocommerce.php
Created Mar 7, 2018
WooCommerce Product multiple select options
View multiple-select-woocommerce.php
function woocommerce_wp_select_multiple( $field ) {
global $thepostid, $post, $woocommerce;
$thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
$field['class'] = isset( $field['class'] ) ? $field['class'] : 'select short';
$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
$field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
$field['value'] = isset( $field['value'] ) ? $field['value'] : ( get_post_meta( $thepostid, $field['id'], true ) ? get_post_meta( $thepostid, $field['id'], true ) : array() );