Skip to content

Instantly share code, notes, and snippets.

View twmbx's full-sized avatar
🇿🇲

Twaambo Haamucenje twmbx

🇿🇲
View GitHub Profile
@twmbx
twmbx / flexvideo.js
Created December 16, 2013 12:33
Adding Zurb Foundation Flex Video classes to html iframes on dynamic sites using Javascript. Useful on wordpress sites where contributors may not always follow best practice. Requires jQuery or Zepto, hacked from fitvids.js
(function( $ ){
$.fn.flexvids = function() {
"use strict";
return this.each(function(){
var selectors = [
"iframe[src*='player.vimeo.com']",
"iframe[src*='youtube.com']",
"iframe[src*='youtube-nocookie.com']",
"iframe[src*='kickstarter.com'][src*='video.html']",
@twmbx
twmbx / database.sql
Created May 31, 2017 10:30
Example schema for directus 6.4rc testing
-- 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 / PdoAdapter.php
Last active July 20, 2017 14:05
Phinx: PDO Adapter ( Cockroach DB Fixes)
<?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 / CockroachAdapter.php
Last active July 20, 2017 14:10
Phinx: Cockroach (Postgres) Adapter ( Cockroach DB Fixes )
<?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 / routes.php
Created January 4, 2018 10:23 — forked from fhferreira/routes.php
Logout of Auth Basic on Laravel
<?php
Route::get('logout-basic', function() {
return Redirect::to(preg_replace("/:\/\//", "://log-me-out:fake-pwd@", url('/')));
});
@twmbx
twmbx / App.svelte
Created May 15, 2019 13:58
Svelte Twitter Tweet Box
<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 / index.php
Created September 30, 2016 11:15 — forked from drizzentic/index.php
Sample USSD Application
<!-- 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:
@twmbx
twmbx / ffmpeg.sh
Created April 19, 2020 20:33
FFMPEG complex Video Trim
# 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 / useful-wp-stuff.md
Last active May 13, 2020 10:55
Useful WordPress Stuff
@twmbx
twmbx / vanilla-ajax-poll.js
Last active February 6, 2023 14:57
Polling in JS with an async ajax call that returns a promise ( modified from: https://davidwalsh.name/javascript-polling )
// 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!