Skip to content

Instantly share code, notes, and snippets.

James Dinsdale molovo

Block or report user

Report or block molovo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@molovo
molovo / Wysiwyg.php
Created Dec 10, 2018
Wysiwyg block for Magento 2 widgets
View Wysiwyg.php
<?php
namespace <vendor>\<module>\Block\Adminhtml\Widget;
use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget\Form\Element;
use Magento\Cms\Model\Wysiwyg\Config;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Data\Form\Element\Factory;
View keybase.md

Keybase proof

I hereby claim:

  • I am molovo on github.
  • I am molovo (https://keybase.io/molovo) on keybase.
  • I have a public key ASCR10KV__E4jv8vHvRJCRz_fnerGVmSWryJF4rDjE0mWQo

To claim this, I am signing this object:

@molovo
molovo / title_changing_stuff.js
Last active Feb 28, 2016
Quick bit of JS to change page title when the user navigates away from the tab
View title_changing_stuff.js
( function () {
// This function does the dirty work of finding the event type and setting the appropriate title
var updatePageTitle = function ( evt ) {
var v = "This text should match your <title> element", // The title when tab is visible
h = "I Miss You! ❤", // The title when tab is hidden
evtMap = {
focus: v,
focusin: v,
pageshow: v,
@molovo
molovo / Default (OSX).sublime-keymap
Created Mar 18, 2014
My SublimeText2 User Settings File
View Default (OSX).sublime-keymap
[
// swap the keybindings for paste and paste_and_indent
{
"keys": [ "super+v" ],
"command": "paste_and_indent"
}, {
"keys": [ "super+shift+v" ],
"command": "paste"
},
@molovo
molovo / gist:6907965
Last active Sep 27, 2018
A short snippet for exporting posts from Anchor CMS into separate .markdown files for use with Jekyll. Just add the created files straight into your _posts folder in jekyll. The following code goes into /anchor/routes/site.php, then just visit <site URL>/export to create the files
View gist:6907965
Route::get('export', function() {
$posts = Post::where('status', '=', 'published')->get();
foreach ($posts as $post) {
$content = <<<EOD
---
layout: post
title: "$post->title"
date: $post->created
categories: blog
@molovo
molovo / anchor.sublime-snippet
Created Oct 9, 2013
A small sublime snippet set for anchor CMS. Save the file in /Users/<username>/Library/Application Support/Sublime Text 2/Packages/User. Tweet @molovo for further requests :)
View anchor.sublime-snippet
<snippet>
<content><![CDATA[
<?php if(has_posts()): ?>
<ul>
<?php while(posts()): ?>
<li>
<article>
<h1>
<a href="<?php echo article_url(); ?>" title="<?php echo article_title(); ?>">
<?php echo article_title(); ?>
@molovo
molovo / gist:5514490
Created May 3, 2013
A simple AJAX download counter. Count is stored in a json file, and updated via PHP.
View gist:5514490
// jQuery to update counter when button is clicked
$('#download').click(function(event) {
event.preventDefault();
var redirectUrl = $(this).attr('href');
$.ajax({
url: "downloads.php",
success: function(response) {
if (response = 'success') {
// The counter file has been updated in the background, but we should update the results on screen to tell the user
var count = $('#count').html();
@molovo
molovo / gist:5330415
Created Apr 7, 2013
Some yummy jQuery date validation. Was designed to allow a standard text input to accept date values, which could then be recognised by a datepicker widget which is only able to recognise inputted values in dd/mm/yyyy format. Could also be used to simply allow the user to use their preferred format, but still have consistency within the database…
View gist:5330415
$('input.class').blur(function() {
// First grab the date entered
var enteredDate = $(this).val();
// If enteredDate is only a number, add slashes at the correct points
if ( enteredDate == parseFloat(enteredDate) ) {
enteredDate = enteredDate.replace(/(\S{2})/g,"$1/");
enteredDate = enteredDate.replace(/\/$/,""); // removes the final slash
//alert (enteredDate);
}
You can’t perform that action at this time.