Skip to content

Instantly share code, notes, and snippets.

@Macagare
Macagare / gist:4603792
Last active October 18, 2019 22:32
Coldfusion: strip tags from html
<!--- strip tags --->
<cfset stripedString = ReReplaceNoCase(source,"<[^>]*>","","ALL") />
@Macagare
Macagare / gist:4502095
Created January 10, 2013 13:40
JavaScript: Limit the number of characters in a textarea
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Code source: http://www.devcurry.com/2009/08/limit-number-of-characters-in-textarea.html THANKS -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Limit Number of Characters in a TextArea</title>
<script type='text/javascript'
src='http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
@Macagare
Macagare / .vimrc
Last active December 10, 2015 21:08
vim configuration (update ~/.vimrc)
"Status line
set statusline=%F%m%r%h%w\ %{&ff}\ %Y\ a/h:%03.3b/%02.2B\ %04l,%04v\ %p%%\ %L\ lines
set laststatus=2
"Tabstop
set tabstop=4
set shiftwidth=4
set expandtab
set backspace=indent,eol,start
@Macagare
Macagare / gist:4484890
Created January 8, 2013 15:55
JS: class documentation
/**
* @class Acme.TYPO3.Foo.ClassWithConstructor
*
* This class has a constructor!
*
* @namespace Acme.TYPO3.Foo
* @extends TYPO3.TYPO3.Core.SomeOtherClass
*
* @constructor
* @param {String} id The ID which to use
@Macagare
Macagare / gist:4484888
Created January 8, 2013 15:55
JS: method documentation
/**
* This is a method declaration; and the
* explanatory text is followed by a newline.
*
* @param {String} param1 Parameter name
* @param {String} param2 (Optional) Optional parameter
* @return {Boolean} Return value
*/
@Macagare
Macagare / gist:4345160
Created December 20, 2012 12:59
Javascript: check for html5 via jquery
function isHtml5(){
var test_canvas = document.createElement("canvas") //try and create sample canvas element
return (test_canvas.getContext)? true : false //check if object supports getContext() method, a method of the canvas element
}
@Macagare
Macagare / gist:4344082
Created December 20, 2012 09:20
Javascript: check Textarea max length
$("textarea[maxlength]").keydown( function(e) {
var key = e.which; // backspace = 8, delete = 46, arrows = 37,38,39,40
if ( ( key >= 37 && key <= 40 ) || key == 8 || key == 46 ) return;
return $(this).val().length < $(this).attr( "maxlength" );
});
@Macagare
Macagare / gist:4225778
Created December 6, 2012 16:26
Terminal: curl username password
curl -u username:password http://example.com
@Macagare
Macagare / gist:4201930
Created December 4, 2012 08:49
PHP: Social Media Links
<!-- bookmark on Delicious -->
<a rel="nofollow" href="http://delicious.com/post?url=<?php the_permalink(); ?>&amp;title=<?php echo urlencode(get_the_title($id)); ?>" title="Bookmark this post at Delicious">Bookmark at Delicious</a>
<!-- submit to Digg -->
<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=<?php the_permalink(); ?>" title="Submit this post to Digg">Digg this!</a>
<!-- tweet on Twitter -->
<a rel="nofollow" href="http://twitter.com/home?status=<?php echo urlencode("Currently reading: "); ?><?php the_permalink(); ?>" title="Share this article with your Twitter followers">Tweet this!</a>
<!-- submit to StumbleUpon -->
@Macagare
Macagare / gist:4201925
Created December 4, 2012 08:48
Javascript: Function - is_empty(obj)
function is_empty(obj) {
"use strict";
// Assume if it has a length property with a non-zero value
// that that property is correct.
if (obj.length && obj.length > 0){ return false; }
if (obj.length && obj.length === 0){return true; }
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) { return false; }
}