Skip to content

Instantly share code, notes, and snippets.

@anandsunderraman
anandsunderraman / promisedRequest.js
Last active October 19, 2016 14:03
Node.js request with Q promises
//import the http library
var http = require('http'),
//npm install q before requiring it
Q = require('q');
//a js object with options
var googleNewsOptions = {
hostname: 'ajax.googleapis.com',
path: '/ajax/services/search/news?v=1.0&q=nodejs',
method: 'GET'
@anandsunderraman
anandsunderraman / regex
Created October 3, 2014 02:38
Regex to replace commas between double quotes
("[^",]+),([^",]+),([^"]*")
$1$2$3
@anandsunderraman
anandsunderraman / setPostParams.groovy
Created October 1, 2014 18:47
SoapUI set post parameters
//set sessionToken with jwt token to post request
testRunner.testCase.getTestStepByName("TestStep").testRequest.params.setPropertyValue('requestParameterName','requestParameterValue');
@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;
@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 / 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 / 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 / genTimeStamp.sql
Last active September 8, 2024 22:23
Oracle Random Timestamp Generation
select to_timestamp(sysdate) + (dbms_random.value(0,86400)/86400))
from dual;
@anandsunderraman
anandsunderraman / setChromeOptions.js
Last active July 19, 2024 12:13
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 / 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>