Skip to content

Instantly share code, notes, and snippets.

@anandsunderraman
anandsunderraman / gist:5852834
Created June 24, 2013 19:34
Regular Expression to Format Currency In Javascript
function formatCurrency(amount)
{
//truncate the amount to 0 decimals
//for every digit that is followed by 3 digits and a word boundary
//add a comma
amount = amount.toFixed(0).replace(/(\d)(?=(\d{3})+\b)/g, "$1,");
return amount;
}
@anandsunderraman
anandsunderraman / requestTest.js
Last active December 18, 2015 22:09
Gist to POST a request using node.js request module
var request = require('request');
function postRequest(post_data,responseObject)
{
var url = 'http://www.example.com';
var proxy_opt = 'http://domain:port';
var post_options = {
uri:url,
<?php
//testing php curl
$authURL = 'https://someapi.com/rest/Authentication';
$userName = 'userName';
$apiKey = 'passwords';
$proxyHost = 'host';
$proxyPort = 1111;
@anandsunderraman
anandsunderraman / html.snippet.xml
Last active August 29, 2015 14:05
Sublime Text 2 HTML Snippet
<snippet>
<content><![CDATA[
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src=""></script>
<link rel="stylesheet" href="">
</head>
@anandsunderraman
anandsunderraman / setChromeOptions.js
Last active May 2, 2024 05:54
Selenium Web Driver Set Chrome Options
//import the selenium web driver
var webdriver = require('selenium-webdriver');
var chromeCapabilities = webdriver.Capabilities.chrome();
//setting chrome options to start the browser fully maximized
var chromeOptions = {
'args': ['--test-type', '--start-maximized']
};
chromeCapabilities.set('chromeOptions', chromeOptions);
var driver = new webdriver.Builder().withCapabilities(chromeCapabilities).build();
@anandsunderraman
anandsunderraman / genTimeStamp.sql
Last active August 29, 2015 14:06
Oracle Random Timestamp Generation
select to_timestamp(sysdate) + (dbms_random.value(0,86400)/86400))
from dual;
@anandsunderraman
anandsunderraman / web.xml
Last active August 29, 2015 14:06
JSF Web.xml configuration
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>RichFacesExperiment</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
@anandsunderraman
anandsunderraman / iterateTestSteps.groovy
Last active August 29, 2015 14:07
iterate thru test steps and add header to each of them
import groovy.json.JsonSlurper;
import com.eviware.soapui.support.types.StringToStringMap;
//get the response from the test step that makes the call to get the authentication token
def authResponse = testRunner.testCase.getTestStepByName("GetToken").getPropertyValue("response");
//parse the json response
def authResponseJSON = new JsonSlurper().parseText(authResponse);
//access the access_token property in the respose
@anandsunderraman
anandsunderraman / parse_json.groovy
Last active August 29, 2015 14:07
soap ui groovy parse json
//import library to parse JSON
import groovy.json.JsonSlurper;
//get the JSON response from the test step that makes the call to some test step to get a JSON repsonse
def response = testRunner.testCase.getTestStepByName("TestStepName").getPropertyValue("response");
//parse the json response
def responseJSON = new JsonSlurper().parseText(response);
//access the propertyname
@anandsunderraman
anandsunderraman / config.inc.php
Created September 30, 2014 13:51
phpmyadmin add remote mysql server
<?php
$i++;
//add remote server hostname or ip
$cfg['Servers'][$i]['host'] = 'hostname or ip';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['compress'] = FALSE;