Skip to content

Instantly share code, notes, and snippets.

@diversen
diversen / backup-wordpress-single-file.sh
Created Mar 11, 2021
Single file wordpress backup script using rsync and mysqldump
View backup-wordpress-single-file.sh
#!/usr/bin/env php
<?php
/**
* Wordpress backup without any configuration
*
* USAGE:
*
* ./wordpress-backup.php path/to/basepath/of/wordpress/
*
View search_csv.php
<?php
// Search CSV
$csv = './Debitorer.csv';
$result = [];
$i = 0;
if (($handle = fopen($csv, "r")) !== false) {
while (($data = fgetcsv($handle, 1000, ";")) !== false) {
$i++;
View non-bloated-cookie-consent.html
View Tonal test
const Tonal = require("tonal");
const Scale = Tonal.Scale
const Note = Tonal.Note
const scales = Scale.names()
console.log(scales)
const testScale = 'C major'
const major = Scale.notes(testScale)
const intervals = Scale.intervals(testScale)
@diversen
diversen / php-recaptcha.php
Last active Jul 14, 2020
php verify google recaptcha version 2
View php-recaptcha.php
<?php
/**
* Will make it work if server does not have
* allow_url_fopen
*/
function fileGetContentsCurl($url)
{
$ch = curl_init();
View wavesurfer.js
var samplePromise = require('get-audio-sample-promise');
var rand = require('random-float');
var waveSurfer = require('wavesurfer.js')
// let [foo, bar] = await Promise.all([getFoo(), getBar()]);
// let audiobuf = await samplePromise(ctx, 'raven.mp3');
function randomDoubleFromInterval(min, max){
return Math.random()*(max-min);
@diversen
diversen / battery.sh
Created Sep 24, 2017
shell script which show percentage of battery left
View battery.sh
#!/bin/sh
upower -i $(upower -e | grep 'BAT') | grep -E "state|to\ full|percentage"
@diversen
diversen / serv.sh
Created Sep 23, 2017
Tiny bash wrapper around built-in PHP-server in order to serv current dir. Usage: Place in a global bin dir and run serv.sh
View serv.sh
#!/bin/sh
if [ -z "$1" ]
then
PORT=8080
fi
if [ "$1" ]
then
PORT=$1
View querySelector.php
<?php
// composer require symfony/css-selector
// Easy to use CSS selectors on XML and HTML docs.
use Symfony\Component\CssSelector\CssSelectorConverter;
include_once "vendor/autoload.php";
// $xml = simplexml_load_file('test.xml');
@diversen
diversen / modify-bootstrap-button.php
Created Jun 29, 2017
Quick modify of bootstrap buttons using php
View modify-bootstrap-button.php
<?php
header('Content-type: text/css');
function buttonColor($class = '.myBtn' , $c = '#ffffff', $bg = '#0099cc', $cHover = '#C0C0C0', $bgHover = '#C0C0C0') {
$str = <<<EOF
$class {
background: $bg;
color: $c;