Skip to content

Instantly share code, notes, and snippets.

View farinspace's full-sized avatar
🙃
working ...

Dimas Begunoff farinspace

🙃
working ...
View GitHub Profile
@farinspace
farinspace / my_custom_template.php
Created February 20, 2016 20:48
Noon Plugin "nooz_shortcode" filter, PHP template example.
<?php if ( $data['items'] ) { ?>
<div>
<ul>
<?php foreach( $data['items'] as $item ) { ?>
<li>
<time datetime="<?php echo $item['post_date']; ?>"><?php echo $item['post_date_formatted']; ?></time>
<h2>
<a href="<?php echo $item['link']; ?>"><?php echo $item['title']; ?></a>
</h2>
<p><?php echo $item['source']; ?></p>
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
farinspace / functions.php
Created June 23, 2016 00:58
Adding additional content to the post excerpt
<?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="http://example.com">http://example.com</a>.';
}
return $excerpt;
}
@farinspace
farinspace / bitcoin-sync-status
Created July 19, 2017 06:54
cli bitcoin sync status
BC_CURRENT=`bitcoin-cli getblockcount 2>&1`; BC_HEIGHT=`wget -O - http://blockchain.info/q/getblockcount 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)";
@farinspace
farinspace / bbpress-hooks.php
Created November 17, 2011 07:53
Generate a list of hooks and filters for bbpress 2.0.1
<?php
// place and run in ./plugins/bbpress/bbp-themes
$dirs = array( './bbp-twentyten', './bbp-twentyten/bbpress' );
$actions = array();
$filters = array();
@farinspace
farinspace / monero.md
Last active April 27, 2018 04:16
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
farinspace / javascript-trim.js
Created April 27, 2018 17:58
Javascript trim( string )
if (!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
};
}
@farinspace
farinspace / apache2.conf
Created June 10, 2018 22:14
Remove time from Apache directory listings
<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>"
</IfModule>
@farinspace
farinspace / main.cf
Last active July 16, 2018 18:33
MacOS X postfix relyhost mail setup
...
# append to /etc/postfix/main.cf
relayhost=smtp.sendgrid.net:587
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options=
smtp_use_tls=yes
smtp_tls_security_level=encrypt
tls_random_source=dev:/dev/urandom
@farinspace
farinspace / nginx.conf
Created July 17, 2018 16:08
Prevent long caching in subdirectory for a WPEngine install
# 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;
}