Skip to content

Instantly share code, notes, and snippets.

Avatar

Twaambo Haamucenje twmbx

View GitHub Profile
@twmbx
twmbx / wc-delete-all-products.sql
Created Apr 21, 2021
WooCommerce Delete All Products, Product Attachments and custom Product Attributes
View wc-delete-all-products.sql
-- Products
DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
ON taxes.term_id=terms.term_id
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product');
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');
DELETE FROM wp_posts WHERE post_type = 'product';
@twmbx
twmbx / ffmpeg.sh
Created Apr 19, 2020
FFMPEG complex Video Trim
View ffmpeg.sh
# cut out parts of a video by splitting it into parts delineated by seconds
# then combining them to create a single video
# example splits into 4 and then combines.
ffmpeg -i input-video.ext -filter_complex "
[0:v]split=4[vc1][vc2][vc3][vc4],
[vc1]trim=00:911,setpts=PTS-STARTPTS[v1],
[vc2]trim=974:2971,setpts=PTS-STARTPTS[v2],
[vc3]trim=2997:5129,setpts=PTS-STARTPTS[v3],
@twmbx
twmbx / App.svelte
Created May 15, 2019
Svelte Twitter Tweet Box
View App.svelte
<script>
let message = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit';
let messageCounter;
let buttonState;
let counterState;
$: message;
$: messageCounter = calcCounter(message);
$: buttonState = getButtonState(messageCounter);
$: counterState = getCounterState(messageCounter);
@twmbx
twmbx / routes.php
Created Jan 4, 2018 — forked from fhferreira/routes.php
Logout of Auth Basic on Laravel
View routes.php
<?php
Route::get('logout-basic', function() {
return Redirect::to(preg_replace("/:\/\//", "://log-me-out:fake-pwd@", url('/')));
});
@twmbx
twmbx / vanilla-ajax-poll.js
Last active Feb 13, 2021
Polling in JS with an async ajax call that returns a promise ( modified from: https://davidwalsh.name/javascript-polling )
View vanilla-ajax-poll.js
// The polling function
function poll(fn, timeout, interval) {
var endTime = Number(new Date()) + (timeout || 2000);
interval = interval || 100;
var checkCondition = function(resolve, reject) {
var ajax = fn();
// dive into the ajax promise
ajax.then( function(response){
// If the condition is met, we're done!
@twmbx
twmbx / CockroachAdapter.php
Last active Jul 20, 2017
Phinx: Cockroach (Postgres) Adapter ( Cockroach DB Fixes )
View CockroachAdapter.php
<?php
/**
* Phinx
*
* (The MIT license)
* Copyright (c) 2015 Rob Morgan
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated * documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
@twmbx
twmbx / PdoAdapter.php
Last active Jul 20, 2017
Phinx: PDO Adapter ( Cockroach DB Fixes)
View PdoAdapter.php
<?php
/**
* Phinx
*
* (The MIT license)
* Copyright (c) 2015 Rob Morgan
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated * documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
@twmbx
twmbx / database.sql
Created May 31, 2017
Example schema for directus 6.4rc testing
View database.sql
-- MySQL dump 10.15 Distrib 10.0.29-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: localhost
-- ------------------------------------------------------
-- Server version 10.0.29-MariaDB-0ubuntu0.16.04.1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
@twmbx
twmbx / index.php
Created Sep 30, 2016 — forked from drizzentic/index.php
Sample USSD Application
View index.php
<!-- MIT License
Copyright (c) 2016 Derrick Rono
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: