Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Deepak Mishra d3ep4k

🏠
Working from home
View GitHub Profile
@d3ep4k
d3ep4k / paytm-orders-export.js
Last active Mar 12, 2020
JS code to organise paytm orders to be exported as csv
View paytm-orders-export.js
// records = []
columns = []
document.querySelectorAll("._2PmH5").forEach( record => {
columns=[]
record.childNodes.forEach( column =>
columns.push(column.textContent.trim())
);
str = JSON.stringify(columns);
// debugger;
// console.log(str)
View movie.jsp
<jsp:directive.include file="../fragments/mason-init.jspf"/>
<m:resource>
<m:request method="GET">
<sql:query var="result" dataSource="${datasource}">
SELECT * FROM movie
</sql:query>
<c:set target="${output}" property="output" value="${result}"/>
</m:request>
@d3ep4k
d3ep4k / external.xml
Last active Jun 23, 2019
External API request example using XRequest feature in metamug console
View external.xml
<?xml version="1.0" encoding="UTF-8" ?>
<Resource xmlns="http://xml.metamug.net/resource/1.0" v="1.0">
<Request method="GET">
<XRequest id="xrequest" method="GET"
url="https://postman-echo.com/get?foo1=bar1&amp;foo2=bar2"
/>
</Request>
</Resource>
@d3ep4k
d3ep4k / hello.xml
Last active Jun 23, 2019
When condition example with param example
View hello.xml
<?xml version="1.0" encoding="UTF-8" ?>
<Resource xmlns="http://xml.metamug.net/resource/1.0" v="1.0">
<Request method="GET">
<Desc> Say hello to different species </Desc>
<Param name="type" type="text" minlength="1" />
<!-- http://localhost:7000/backend/v1.0/hello?type=animal -->
<Sql id="helloAnimals" when="$type eq animal"> SELECT 'Hello animals' as "message" </Sql>
<!-- http://localhost:7000/backend/v1.0/hello?type=plant -->
<Sql id="helloPlants" when="$type eq plant"> SELECT 'Hello plants' as "message" </Sql>
</Request>
View script.groovy
GroovyScriptEngine engine = new GroovyScriptEngine(".");
Map<String, String> request = new HashMap();
request.put("param1", "Hello");
Map<String, String> response = new HashMap();
response.put("param1", "World");
Binding binding = new Binding();
binding.setVariable("request", request);
binding.setVariable("response", response);
engine.run("src/main/java/"+className, binding);
View Output.java
class MtgOutput{
private Map<String, Object> map;
public Output(Map<String, Object> map){
this.map = map;
}
protected abstract String processJSONObject(JSONObject obj);
protected abstract String processJSONArray(JSONArray obj);
protected abstract String processString(String obj);
View Probability.java
import java.util.concurrent.ThreadLocalRandom;
public class Probability {
public static void main(String[] args){
if(args.length != 2){
System.out.println("java Probability <Samples> <Probability percentage>");
System.exit(0);
}
@d3ep4k
d3ep4k / router-password.md
Last active Nov 25, 2018
Router default username and password.
View router-password.md

Skyworth

Username: admin

Password: br0adband

Technicolor TC7210.dNZ

Username:

@d3ep4k
d3ep4k / java-pass-by-value.groovy
Created Nov 5, 2018
Java is pass by value. You cannot change the reference
View java-pass-by-value.groovy
map = new HashMap();
map.put("name","intellect");
void modify(map){
map.get("name")
map.put("name","trade");
map = new HashMap();
map.put("name","scf");
}
View run-opengrok.md