Skip to content

Instantly share code, notes, and snippets.

View sgml's full-sized avatar

psweatte sgml

View GitHub Profile
@sgml
sgml / Printer.js
Created January 17, 2019 21:26
Printer
function printer(){for (var obj in this) {console.log("this." + obj + ": " + this[obj])}}
printer();
@sgml
sgml / Heartbeat.js
Created January 17, 2019 21:26
Heartbeat
var heartbeat = window.setTimeout(function(){window.location = window.location}, 10000)
@sgml
sgml / AutoStubs.js
Created January 17, 2019 21:25
Auto Stubs
function foo(value){ return /.*=.*=>.{/.exec(value) ? /.*=>.{/.exec(value).toString() : false}
function bar(value){ return value }
function baz(value){ return String("SearchViewModel." + value).trim().replace(/[\s=>{}]/g,"")}
var arrows = document.querySelector("pre").innerText.split("\n").map(foo).filter(bar)
var stubs = arrows.map(baz)
window.stubs = stubs;
@sgml
sgml / AutoMocks.js
Created January 17, 2019 21:25
Auto Mocks
var foo = 'window.name'.replace('.', '":{"').replace(/^/,'{"').replace(/$/,'":""}}')
@sgml
sgml / Modal Remover.js
Created January 17, 2019 21:24
Modal Remover
document.querySelector(".Popover, .fullBanner").setAttribute("style", "display:none")
function mapper(value) {
value.disabled = true;
}
Array.from(document.styleSheets).map(mapper);
var data = [{"keyword": "foo"}, {"keyword": "bar"}, {"keyword": "baz"}];
var matchObject = {keyword:'baz', index: 0};
var matchArray = data.filter(function(value, index) {return value.keyword === matchObject.keyword });
var index = 0;
var result = [];
@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
#
@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 / 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)
{
...
}