Instantly share code, notes, and snippets.

working ...

Dimas Begunoff farinspace

View GitHub Profile
farinspace / trim_non_alphanum.php
Created Aug 6, 2018
Trim non alpha-numeric characters from the beginning and end of a string
View trim_non_alphanum.php
function trim_non_alphanum( $str ) {
$str = preg_replace( '/^[^[:alnum:]]+/u', '', $str ); // beginning
return preg_replace( '/[^[:alnum:]]+$/u', '', $str ); // end
farinspace / nginx.conf
Created Jul 17, 2018
Prevent long caching in subdirectory for a WPEngine install
View nginx.conf
# Request is cached for at maximum of 10 minutes, then origin revalidation starts
# Clients that send "If-Modified-Since" headers will recieve 304 response unless the file actually changes on origin
# Use: `add_header Last-Modified ""` to remove Last-Modified server headers
location ~* ^/wp-content/themes/theme/subdir/ {
add_header Cache-Control "public, max-age=600, must-revalidate";
etag off;
farinspace /
Last active Jul 16, 2018
MacOS X postfix relyhost mail setup
# append to /etc/postfix/
farinspace / apache2.conf
Created Jun 10, 2018
Remove time from Apache directory listings
View apache2.conf
<IfModule mod_autoindex.c>
IndexHeadInsert "<script>window.onload=function(){document.querySelectorAll('tr td:nth-child(3)').forEach(function(td){if(td&&td.innerText.indexOf('-')>=0)td.innerHTML=td.innerText.match(/\d{4}-\d{2}-\d{2}/)[0]})}</script>"
farinspace /
Last active Apr 29, 2018
x11vnc setup solution, Ubuntu 18.04 LTS

Make and Make install

See x11vnc stack smashing detected solution

Recommended version: x11vnc: 0.9.14 lastmod: 2013-11-21


Set desktop to auto login and prevent screen locking .. else you will need to deal with Xauth

farinspace / javascript-trim.js
Created Apr 27, 2018
Javascript trim( string )
View javascript-trim.js
if (!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
farinspace /
Last active Apr 27, 2018
Generating and encrypting wallet data to file

Encrypt a file

openssl enc -aes-256-cbc -a -in wallet-info.txt -out wallet-info.txt.enc

Decrypt a file

openssl enc -aes-256-cbc -d -a -in wallet-info.txt.enc -out wallet-info.txt

Generate a random password and write it to a file

farinspace / bitcoin-sync-status
Created Jul 19, 2017
cli bitcoin sync status
View bitcoin-sync-status
BC_CURRENT=`bitcoin-cli getblockcount 2>&1`; BC_HEIGHT=`wget -O - 2>/dev/null`; perl -E "say sprintf(’Block %s of %s (%.4f%%), %s blocks remaining.', $BC_CURRENT, $BC_HEIGHT, ($BC_CURRENT/$BC_HEIGHT)*100, $BC_HEIGHT-$BC_CURRENT)";
View eloqua-validation-example.js
field5.add(Validate.Custom, {
against: function(value) {
return !value.match(/(\S:\/\/\S|\D\.\D|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\d\.\D)/);
failureMessage: "Value must not contain any URL's"
farinspace / functions.php
Created Jun 23, 2016
Adding additional content to the post excerpt
View functions.php
add_filter( 'get_the_excerpt', 'my_get_the_excerpt' );
function my_get_the_excerpt( $excerpt ) {
if ( 'nooz_coverage' == get_post_type() ) {
$excerpt .= ' &mdash; View more coverage at <a href=""></a>.';
return $excerpt;