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 / 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 / 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 / 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)";
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 / 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>
@farinspace
farinspace / functions.php
Last active February 27, 2016 03:32
Noon Plugin "nooz_shortcode" filter usage example.
<?php
function my_custom_template( $output, $data ) {
// loop $data['items'], use post ID, to get additional meta data if needed
// ...
// filter by type to output different templates
if ( 'coverage' == $data['type'] ) {
ob_start();
// $data variable is available inside PHP file
@farinspace
farinspace / SassMeister-input.scss
Created October 31, 2014 00:32
Generated by SassMeister.com.
// ----
// Sass (v3.4.6)
// Compass (v1.0.1)
// ----
@mixin size($size) {
$height: nth($size, 1);
$width: $height;
@if length($size) > 1 {
$height: nth($size, 2);
@farinspace
farinspace / isPositionFixed
Created September 29, 2014 22:46
Javascript function to check if an element and/or its parents position is set to fixed
isPositionFixed = function (selector, traverseAncestors) {
var el = $(selector);
if (el.length) {
if (!traverseAncestors) {
return 'fixed' === el.css('position') ? true : false ;
}
var isFixed = false;
var els = el.add(el.parents());
els.each(function() {
if ('fixed' === $(this).css('position')) {
@farinspace
farinspace / color_picker
Created September 27, 2014 15:32
Using a color picker with WPAlchemy
jQuery(function($){
var picker_config = {
onSubmit: function(hsb, hex, rgb, el) {
$(el).val(hex);
$(el).ColorPickerHide();
},
onBeforeShow: function () {
$(this).ColorPickerSetColor(this.value);
},
onChange: function (hsb, hex, rgb) {