Skip to content

Instantly share code, notes, and snippets.

@cemerson
cemerson / gist:3455408
Created August 24, 2012 20:44
Javascript: HTML Encode
function escapeHTMLEncode(str) {
var div = document.createElement(‘div’);
var text = document.createTextNode(str);
div.appendChild(text);
return div.innerHTML;
}
@cemerson
cemerson / gist:3455429
Created August 24, 2012 20:45
Javascript: New Function
/* ----------------------------------------------------------- /
MY_FUNCTION_NAME
Short description of function...
/ ----------------------------------------------------------- */
function MY_FUNCTION_NAME(){
report('TEST','--> MY_FUNCTION_NAME()..');
try{
}catch(e){ catchError('MY_FUNCTION_NAME()',e); }
}
@cemerson
cemerson / gist:3455465
Created August 24, 2012 20:49
Other: Lorum Ipsum
Suscipit adipiscing ex ut vel eum ex vulputate in nulla eu nisl augue illum eu feugait iusto in. Veniam minim, feugiat ad consequat diam, adipiscing facilisis at ex feugait laoreet at ut qui. Dignissim lorem et aliquam, quis ut tincidunt nonummy et. Ut feugait commodo erat et minim ullamcorper illum sit qui wisi ullamcorper, ad vel esse iusto ad lorem. Molestie facilisis iriure et nisl, aliquip iriure, delenit. Praesent praesent nostrud eu vel quis nostrud autem in et in. Ut, facilisi minim vel consequat luptatum at vel iusto et ex augue esse euismod luptatum ea feugiat sit exerci. Laoreet vel duis, autem feugiat quis ad, te feugait, illum dolore nisl feugait consequat elit qui aliquam in. Consequat dolor commodo, ullamcorper nostrud lorem ipsum. Dolore, erat ex, wisi. Facilisis in luptatum wisi quis consequat vulputate vel ut suscipit amet, vel erat facilisis duis eros. Nibh molestie vel.
Ullamcorper delenit ea augue. Duis dolore veniam veniam, odio volutpat delenit nulla quis. Blandit te qui nulla eros, ac
@cemerson
cemerson / gist:3455470
Created August 24, 2012 20:49
Other: PDF Expiration Script
var curDate = new Date();
var finalDate = new Date("6/25/2011");
if(finalDate.getTime() < curDate.getTime()){
app.alert("The customer license for this document has expired. Please contact Situational Leadership @ [email protected] regarding customer ID: 123023234 for assistance.");
this.closeDoc(true);
}else{
var ocgs = this.getOCGs();
for(var i=0;i<ocgs.length;i++){
if(ocgs[i].name == "Watermark")
break;
@cemerson
cemerson / gist:3493995
Created August 28, 2012 00:59
Javascript: Delayed Function Queue
/* Core Methods */
var TimedQueue = function(defaultDelay){
this.queue = [];
this.index = 0;
this.defaultDelay = defaultDelay || 3000;
};
TimedQueue.prototype = {
add: function(fn, delay){
this.queue.push({
@cemerson
cemerson / db.php
Created October 5, 2012 14:08
PHP: Test Database Connection
<?php
// Test a database connection via PHP
$db = @mysql_connect('#SERVER_NAME#', '#DB_USER#', '#DB_PASSWORD#');
if (!$db) echo "connection failed";
else echo "connection succeeded";
define('DB_NAME', 'wp_situationalcom_dev');
?>
@cemerson
cemerson / test.js
Created October 5, 2012 14:09
JavaScript: Detect iPhone/iPad Types
var pixelRatio = window.devicePixelRatio || 1;
var viewport = {
width: window.innerWidth,
height: window.innerHeight
};
var screen = {
width: window.screen.availWidth * pixelRatio,
height: window.screen.availHeight * pixelRatio
@cemerson
cemerson / test.js
Created October 5, 2012 14:10
JavaScript: Detect iPhone4 / iPhone 5
var iphone4 = (window.screen.height == (960 / 2));
var iphone5 = (window.screen.height == (1136 / 2));
@cemerson
cemerson / test.css
Created October 5, 2012 14:11
CSS: iPhone 5 Media Query
/* iPhone 5 only */
@media only screen and (min-width: 560px) and (max-device-width: 1136px) {
}
@cemerson
cemerson / Default.aspx.cs
Created October 5, 2012 18:01
C#: NEW FUNCTION (Void)
/* ---------------------------------------- /
/ MY_FUNCTION_NAME()
/ --------------------------------------- */
public void MY_FUNCTION_NAME(string param1){
try{
// function code here
}catch(Exception ex){
utils.SendDeveloperEmail("Server Error [MY_FUNCTION_NAME(param1:'" + param1 + "')]",ex);
}