Skip to content

Instantly share code, notes, and snippets.

var obj = {test: "(function () {alert('asd'); return true})"};
var test = eval(obj.test);
var test2 = test();
var test3 = "test()";
eval(test3);
@tarzak
tarzak / gauge.js
Last active August 29, 2015 14:23 — forked from tomerd/gauge.js
function Gauge(placeholderName, configuration)
{
this.placeholderName = placeholderName;
var self = this; // for internal d3 functions
this.configure = function(configuration)
{
this.config = configuration;
/*
Input Data Structure:
[
{
_id: "id",
date: "1-May-12",
close: 68.13,
open: 34.12
},
var arr = [
{ccy:"EUR", balance:1000},
{ccy:"USD", balance:"2700"},
{ccy:"EUR", balance:"5600"},
{ccy:"USD", balance:"2500"}
]
var newArr = [];
arr.reduce(function(previousValue, currentValue, index, array) {
var arr = [5,3,2,1,4];
function bSort(arr) {
var i,j,temp;
for (i = 0; i < arr.length; i += 1) {
for (j = i + 1; j < arr.length; j += 1) {
if (arr[i] > arr[j]) {
temp = arr[i];
arr[i] = arr[j];
function compareTwoObjects (objOne, objTwo) {
var property
, checker = true
;
for (property in objTwo) {
if (!objOne[property] || objTwo[property] !== objOne[property] ) {
checker = false;
return checker;
}
function changeVal (obj, path, val) {
var arr = path.split('.');
var object = obj || {};
var tempObj = object;
for (var i = 0; i < arr.length - 1; i += 1) {
if(typeof tempObj[arr[i]] !== 'object') {
tempObj[arr[i]] = {};
}
tempObj = tempObj[arr[i]];
function createList(array) {
var list = createNext(0, array);
return list;
}
function createNext(i, array) {
var result;
if (i < array.length) {
@tarzak
tarzak / unitTest.js
Last active September 28, 2015 11:41
example of unit testing from inside?
//function to test
function aPlusB (a,b) {
return a+b
};
//test-function
function testAplusB (func) {
return func(2,1) === 3
};
[{a:1},{a:undefined},{a:3}].reduce( function(a,b) {
if (b.a) {
return a+=b.a
}
else {
return a
}
},0)