Skip to content

Instantly share code, notes, and snippets.

View victorjonsson's full-sized avatar
🎯
Focusing

Victor Jonsson victorjonsson

🎯
Focusing
View GitHub Profile
var mval = require('mval'),
MANIFEST = mval.MANIFEST;
// Validate android manifest file
var errors = mval.validate('AndroidManifest.xml', MANIFEST.ANDROID);
if( errors.length > 0 ) {
throw new Error('AndroidManifest.xml is invalid \n'+errors.join('\n'));
}
// You can of course also validate ordinary objects
// Make the element editable by double clicking on it
$('#some-element').editable();
// There are some options you can configure when initiating
// the editable feature as well as a callback function that
// will be called when textarea gets blurred.
$('#some-element').editable({
touch : true, // Whether or not to support touch (default true)
lineBreaks : true, // Whether or not to convert \n to <br /> (default true)
toggleFontSize : true, // Whether or not it should be possible to change font size (defualt true)
<div id="editable-area">
<p>
<em class="start-info">Double click on the text to edit</em>
<em class="edit-info" style="display: none">
Start typing to change the text
<span class="info mac">(cmd + &uarr; or cmd + &darr; to change font size)</span>
<span class="info windows">(ctrl + &uarr; or ctrl + &darr; to change font size)</span>
</em>
</p>
<div class="editable">
<?php
/**
* Class that manages all post meta attached to posts by my plugin. This class can be used as an
* ordinary PHP object (stdClass)
*
* @requires PHP version >= 5.1, WordPress version >= 1.6
* @package MyPlugin
* @since 0.1
*/
<?php
/**
* Class that contains all the options for my plugin. This class can be used as an
* ordinary PHP object (stdClass)
*
* @requires PHP version >= 5.1, WordPress version >= 1.6
* @package MyPlugin
* @since 0.1
*/
@victorjonsson
victorjonsson / jquery.editable.js
Last active October 12, 2015 04:58
jQuery plugin that makes any HTML element editable
This plugin has moved to
https://github.com/victorjonsson/jquery-editable
@victorjonsson
victorjonsson / php-composer-collection.txt
Created October 19, 2012 09:02
Collection of nice PHP modules (composer)
- Wide set of classes for encryption
https://github.com/phpseclib/phpseclib
- Image manipulation
https://github.com/Gregwar/ImageBundle
- CLI utilities
https://github.com/jlogsdon/php-cli-tools
@victorjonsson
victorjonsson / tinymce.js
Created August 8, 2012 17:38
listen to keypress within tinyMCE
tinyMCE.editors[0].onKeyPress.add(function(ed, e) {
alert(e.keyCode);
});
@victorjonsson
victorjonsson / bash-hax.sh
Last active October 8, 2015 00:09
nice to have bash commands (svn...)
# Delete all missing files (!)
$ svn rm $( svn status | sed -e '/^!/!d' -e 's/^!//' )
# grep all lines not starting with ?
$ ... | grep -v '^?'
# List large directories
$ sudo du -h / | grep ^[0-9.]*G
@victorjonsson
victorjonsson / form-example.html
Created July 21, 2012 07:22
jQuery Form Validator, example
<form action="" onsubmit="return $(this).validate()">
<p>
Name (4 characters minimum):
<input name="user" data-validation="validate_min_length length4" />
</p>
<p>
Birthdate (yyyy-mm-dd):
<input name="birth" data-validation="validate_birthdate" />
</p>
<p>