Skip to content

Instantly share code, notes, and snippets.

View trajche's full-sized avatar
🍕
Hungry

Trajche TJ Kralev trajche

🍕
Hungry
  • Helsinki, Finland
View GitHub Profile
@trajche
trajche / custom-wp-dl.sh
Last active August 4, 2022 20:44
Download and install WP in a Git directory
#!/bin/bash
if ! [[ -d ./wp-content ]]
then
echo "./wp-content doesn't exist in this directory. please make sure you are in a digitalnode wp instance."
exit
fi
if ! command -v wp &> /dev/null
then
@trajche
trajche / wp-dl-install.sh
Last active October 5, 2021 19:47
Download and install a WP instance (Mac, Valet, MySQL)
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 February 26, 2024 04:15
new mac set-up
#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 January 17, 2021 21:50
Valet Driver for WonderCMS
<?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 October 27, 2020 10:53 — forked from nileshtrivedi/home-server.md
Home Server setup: Raspberry PI on Internet via reverse SSH tunnel

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.

[{"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 April 22, 2020 23:58
Patch for allowing admins to create Dokan coupons.
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 December 11, 2019 10:41
One liner for WordPress download and unpacking in the current directory.
curl -O https://wordpress.org/latest.zip && unzip latest.zip && rm latest.zip && mv wordpress/* ./ && rm -r wordpress/
@trajche
trajche / headerparser.php
Last active November 5, 2019 19:56
link rel parser for headers in shopify / github
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 July 2, 2019 09:35 — forked from mikaelz/delete-all-woocommerce-products.php
Remove all WooCommerce products from database via SQL
<?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