Skip to content

Instantly share code, notes, and snippets.

@Macagare
Macagare / gist:3999514
Created November 2, 2012 08:37
Javascript: restrict textinput characters
<script type="text/javascript">
$(document).ready(function() {
$('.phoneInput').keypress(function(key) {
if(key.charCode < 48 || key.charCode > 57) return false;
});
$('.surnameInput').keypress(function(key) {
if((key.charCode < 97 || key.charCode > 122) && (key.charCode < 65 || key.charCode > 90) && (key.charCode != 45)) return false;
});
</script>
@Macagare
Macagare / gist:3999323
Created November 2, 2012 07:44
Coldfusion: cfml create log
<cflog file="myAppLog" application="no" text="User #Form.username# logged on.">
@Macagare
Macagare / gist:3999325
Created November 2, 2012 07:45
Coldfusion: cfloop list
<cfloop index = "ListElement" list = "John/Paul,George::Ringo" delimiters = ",:/">
<cfoutput>#ListElement#</cfoutput><br>
</cfloop>
@Macagare
Macagare / gist:3999333
Created November 2, 2012 07:47
Coldfusion: cfloop array
<cfloop index="x" array="#arr#">
<cfoutput>#x#<br /></cfoutput>
</cfloop>
@Macagare
Macagare / gist:3999344
Created November 2, 2012 07:49
HTML: HTML5 template
<!doctype html>
<head>
<!-- simplified character encoding -->
<meta charset="utf-8">
<title>TEMPLATE TITLE</title>
<!-- Main style sheet. Change version number in query string to force styles refresh -->
<!-- Link element no longer needs type attribute -->
@Macagare
Macagare / gist:3999356
Created November 2, 2012 07:53
Javascript: cufon embed fonts
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Playing with Cufón</title>
<!-- Stylesheets here, before all scripts. Helps avoid styling issues. -->
<link rel="stylesheet" type="text/css" href="style.css" />
<!--
If you want to use complex selectors with Cufón, load a selector engine (JavaScript framework) here.
We support jQuery, Sizzle, MooTools, Dojo, Prototype and other popular frameworks.
@Macagare
Macagare / gist:4001075
Created November 2, 2012 12:33
Actionscript: Calc if point is within shape
var userClickTarget : Point = new Point(tmpXPos, tmpYPos);
// read bounds extremes
var minAreaX : Number = -1;
var maxAreaX : Number = -1;
var minAreaY : Number = -1;
var maxAreaY : Number = -1;
// when an area specified, convert for flash interface to be able to debug display
var posLen : uint = targetPosition.xList.length;
@Macagare
Macagare / gist:4017991
Created November 5, 2012 16:04
Javascript: jquery handcursor mouseover
// http://jsfiddle.net/jquerybyexample/RgLPC/
$(".ui-datepicker-trigger").mouseover(function() {
$(this).css('cursor', 'pointer');
});
@Macagare
Macagare / gist:4024294
Created November 6, 2012 12:08
MySQL: Create db and user
$ mysql -uroot -p
mysql> create database my_new_database;
mysql> grant all on my_new_database.* to new_user@localhost identified by 'my secret password';
mysql> flush privileges;
mysql> quit
@Macagare
Macagare / gist:4044440
Created November 9, 2012 08:28
Javascript: getInternetExplorerVersion()
/**
* Returns the version of Internet Explorer or a -1
* (indicating the use of another browser).
*/
function getInternetExplorerVersion()
{
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;