Skip to content

Instantly share code, notes, and snippets.

@larscmagnusson
larscmagnusson / sort-list-string.js
Created October 19, 2022 06:07
Sort unsorted list
const unsortedString = `
a
c
b
`
const sortedString = [...unsortedString.split('\n')]
.map(x => x.trim())
.filter(x => x)
.sort()
.join('\n')
@larscmagnusson
larscmagnusson / diff.sh
Created September 20, 2019 21:07
Find what commit dir is
#!/bin/bash
# ANvänds = ./diff.sh swift-modularity/ Modularity/ "*.php" "."
DIR_1="$1"
DIR_2="$2"
GLOB="$3"
WHERE="$4"
cd $DIR_1
@larscmagnusson
larscmagnusson / wp-cli-export-import-examples.sh
Last active August 12, 2019 19:37
wp cli -- db export/import encrypted
#!/usr/bin/env bash
#export
wp db export - | openssl smime --encrypt --text --binary --aes256 --outform DER --out database.sql.enc PATH_TO_PUBLIC_KEY
#import
openssl smime --decrypt --in database.sql.enc --binary --inform DER --inkey PATH_TO_PRIVATE_KEY | wp db import -
@larscmagnusson
larscmagnusson / .htaccess
Created August 11, 2019 20:09
Wordpress images from livesite
<IfModule mod_rewrite.c>
# Get images from livesite if not on local
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.LOCALSITE.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*\.(gif|jpg|png))$ https://www.THELIVESITE.com/$1 [R=301,L]
# Wordpress permalinks
<?php
echo "test";
?>
@larscmagnusson
larscmagnusson / main.js
Created February 27, 2013 06:58
Test 2
var test = function () {
return "TEST!";
}
var test = function () {
return "TEST!";
}
// test