Skip to content

Instantly share code, notes, and snippets.

View sgml's full-sized avatar

psweatte sgml

View GitHub Profile
@sgml
sgml / gist:8854545
Created February 6, 2014 23:19
JavaScript Unicode Object
/* Wrong */
function Unicode()
{
var table = [];
for(var i=0; i < 99999; i++)
{
table.push(String.fromCharCode(i) )
}
return table;
}
@sgml
sgml / gist:8854555
Created February 6, 2014 23:20
jQuery Templating
jQuery Templating:
<pre>
$("#foo").prepend
(
$("&lt;div&gt;",
{
//data attribute for AJAX URL
"data-href": myurl(),
//function call for markup
@sgml
sgml / gist:8854562
Created February 6, 2014 23:21
IE8 Gradient Syntax
Fail:
#ffa
Pass:
##ffffffaa
@sgml
sgml / gist:8854575
Created February 6, 2014 23:22
Simple Slideshow
Fail:
[code]
<!doctype html>
<head>
<style>
pre { position:absolute; clip: rect(0, 100%, 100%, 0); }
pre:focus { clip: rect(0, auto, auto, 0); }
</style>
</head>
<pre tabindex="1">hi</pre>
@sgml
sgml / gist:8854589
Created February 6, 2014 23:22
JSON to Query String in IE
Fail:
var payload = $.param({"strategy": node}, true);
Pass:
var w3_param = $.param({"strategy": node}, true);
var ie_param = String("strategy=").concat(
encodeURIComponent(
JSON.stringify(node).replace(/\\"/g,"\u0022")
).replace(/%22/,"").replace(/%22$/,"")
);
@sgml
sgml / gist:8854598
Created February 6, 2014 23:23
jQuery Constructor Shorthand
Fail:
$.ready(foo)
Pass:
$(foo)
@sgml
sgml / gist:8854622
Created February 6, 2014 23:24
Global RegExp replace
Mistake:
var selector = ("'$greetings' '$friend'").replace(/\$([^']+)/g, dict[RegExp.$1])
Correction:
var selector = ("'$greetings' '$friend'").replace(/\$([^']+)/g, expand)
function expand(match, offset, fullstring)
{
...
}
@sgml
sgml / gist:8869892
Created February 7, 2014 19:22
Dependency Injection
@media handheld { @import handheld.css }
@media test { @import test.css }
var baseURL = !!page_config.url.cdn ? page_config.url.cdn + "/cdn/mysite/" : ""
var ie = "onpropertychange" in document;
var browsermap = { "true": ie_param, "false": w3_param };
var w3_param = [".addEventListener","\u0022DOMAttrModified\u0022",",false"];
var ie_param = [".attachEvent","\u0022onpropertychange\u0022",""];
var result = "document.getElementById(\u0022foo\u0022)".concat(browsermap[ie][0], "(", browsermap[ie][1], ",bar", browsermap[ie][2], ")");
@sgml
sgml / build.properties
Created December 28, 2018 17:32 — forked from douglascayers/build.properties
Force.com Migration Tool
#
# Specify System Administrator credentials
# that will login to Salesforce to retrieve the metadata.
#
# You will also need the security token.
#
# The server url is which instance to connect to:
# For sandboxes, use https://test.salesforce.com
# For production or developer orgs, use https://login.salesforce.com
#
function mapper(value) {
value.disabled = true;
}
Array.from(document.styleSheets).map(mapper);