Skip to content

Instantly share code, notes, and snippets.

function downloadWav(link, filename) {
link.href = 'data:audio/wav;base64,UklGRhwMAABXQVZFZm10IBAAAAABAAEAgD4AAIA+AAABAAgAZGF0Ya4LAACAgICAgICAgICAgICAgICAgICAgICAgICAf3hxeH+AfXZ1eHx6dnR5fYGFgoOKi42aloubq6GOjI2Op7ythXJ0eYF5aV1AOFFib32HmZSHhpCalIiYi4SRkZaLfnhxaWptb21qaWBea2BRYmZTVmFgWFNXVVVhaGdbYGhZbXh1gXZ1goeIlot1k6yxtKaOkaWhq7KonKCZoaCjoKWuqqmurK6ztrO7tbTAvru/vb68vbW6vLGqsLOfm5yal5KKhoyBeHt2dXBnbmljVlJWUEBBPDw9Mi4zKRwhIBYaGRQcHBURGB0XFxwhGxocJSstMjg6PTc6PUxVV1lWV2JqaXN0coCHhIyPjpOenqWppK6xu72yxMu9us7Pw83Wy9nY29ve6OPr6uvs6ezu6ejk6erm3uPj3dbT1sjBzdDFuMHAt7m1r7W6qaCupJOTkpWPgHqAd3JrbGlnY1peX1hTUk9PTFRKR0RFQkRBRUVEQkdBPjs9Pzo6NT04Njs+PTxAPzo/Ojk6PEA5PUJAQD04PkRCREZLUk1KT1BRUVdXU1VRV1tZV1xgXltcXF9hXl9eY2VmZmlna3J0b3F3eHyBfX+JgIWJiouTlZCTmpybnqSgnqyrqrO3srK2uL2/u7jAwMLFxsfEv8XLzcrIy83JzcrP0s3M0dTP0drY1dPR1dzc19za19XX2dnU1NjU0dXPzdHQy8rMysfGxMLBvLu3ta+sraeioJ2YlI+MioeFfX55cnJsaWVjXVlbVE5RTktHRUVAPDw3NC8uLyknKSIiJiUdHiEeGx4eHRwZHB8cHiAfHh8eHSEhISMoJyMnKisrLCszNy8yOTg9QEJFRUVITVFOTlJVWltaXmNfX2ZqZ21xb3R3eHqAhoeJkZ
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<cfscript>
iterations = 1000;
sampletext = RepeatString("Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", 100);
result = [];
// Method 1
i = 0;
startTime = getTickCount();
finalString = "";
while ( i < iterations ) {
@aliaspooryorik
aliaspooryorik / bleeding_variables.cfc
Last active March 3, 2017 14:26
Find bleeding variables
component extends="testbox.system.BaseSpec" {
function run(testResults, testBox) {
it ("should not bleed variables", function() {
prepareMock(variables.sut).$property("getVariablesScopeList", "this", getVariablesScopeList);
var before = sut.getVariablesScopeList();
sut.doSomething();
var after = sut.getVariablesScopeList();
expect(before).toBe(after, "variables have leaked!");
});
The html...
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<h3>Submit Some Hidden Form Data</h3>

Transformation Priority Premise

  • ({} → nil) no code at all → code that employs nil
  • (nil → constant)
  • (constant → constant+) a simple constant to a more complex constant
  • (constant → scalar) replacing a constant with a variable or an argument
  • (statement → statements) adding more unconditional statements.
  • (unconditional → if) splitting the execution path
  • (scalar → array)
  • (array → container)
<cfscript>
function foo() {
var i = 0;
local.j = 0;
local.cat = 1;
var bat = 2;
@aliaspooryorik
aliaspooryorik / flatten.cfm
Created July 11, 2017 11:40
Flatten complex data
<cfscript>
struct = {
"a": 1,
"b": 2,
"c": 3,
"d": {
"e": 4
}
};
@aliaspooryorik
aliaspooryorik / flatternArray.cfm
Last active July 12, 2017 12:58
Flatten an array
<cfscript>
a = [1,[2,[3,[4,5],6,7],8,9],10];
function recurse(data) {
var result = [];
data.each(function(item) {
if (isArray(item)) {
result.append(recurse(item), true);
} else {
result.append(item);
@aliaspooryorik
aliaspooryorik / query column as array.cfm
Created August 17, 2017 11:47
query column as array
var newarray = [];
newarray.addAll(q[colname]);
return newarray;