Skip to content

Instantly share code, notes, and snippets.

View fromdev's full-sized avatar

Sachin Joshi fromdev

View GitHub Profile
@fromdev
fromdev / iMacroScript
Last active August 20, 2021 16:52
How to Appear Always Online On Gtalk & Google Hangout - Code For Article on http://bit.ly/OnlineGtalk
VERSION BUILD=8881205 RECORDER=FX
TAB T=1
URL GOTO=https://mail.google.com/mail/u/0/#inbox
TAG POS=1 TYPE=A ATTR=TXT:Important
WAIT SECONDS=30
TAG POS=1 TYPE=A ATTR=TXT:SentMail
WAIT SECONDS=30
@fromdev
fromdev / SampleAsyncCallInSequence.java
Created August 15, 2019 02:48
SampleAsyncCallInSequence - Supplier Lambda Example Code
MyClass myobject = new MyClass();
CompletableFuture<Data> dataCompletableFuture1 = CompletableFuture.supplyAsync(() -> myobject.getData1()); // first Async call
CompletableFuture<Data> dataCompletableFuture2 = CompletableFuture.supplyAsync(() -> myobject.getData2()); // second Async call
CompletableFuture<Data> dataCompletableFuture3 = CompletableFuture.supplyAsync(() -> myobject.getData3()); // third Async call
//Now the code to combine in sequence
dataCompletableFuture1
.thenCombine(dataCompletableFuture2, Aggregator::combine)
.thenCombine(dataCompletableFuture3, Aggregator::combine);
@fromdev
fromdev / Aggregator.java
Created August 15, 2019 02:47
Aggregator - Supplier Lambda Example Code
public class Aggregator {
public combine(Data data1, Data data2) {
//some magic for aggregating data
}
}
@fromdev
fromdev / SampleCallInSequence.java
Created August 15, 2019 02:46
SampleCallInSequence - Supplier Lambda Example Code
MyClass myobject = new MyClass();
Data dataObject1 = myobject.getData1();
Data dataObject2 = myobject.getData2();
Data dataObject3 = myobject.getData3();
Aggregator aggregator = new Aggregator();
Data someDataCombined = aggregator.combine(dataObject1, dataObject2); // combines data of 2 objects
Data someDataCombined2 = aggregator.combine(someDataCombined, dataObject3); // combines data of 2 objects
@fromdev
fromdev / SampleAsyncCall.java
Created August 15, 2019 02:44
SampleAsyncCall - Supplier Lambda Example Code
MyClass myobject = new MyClass();
CompletableFuture<Data> dataCompletableFuture = CompletableFuture.supplyAsync(() -> myobject.getData()); // this is async call with supplier Lambda
Data dataObject = dataCompletableFuture.get(); // this is a blocking call
@fromdev
fromdev / SampleCall.java
Created August 15, 2019 02:43
SampleCall - Supplier Lambda Example Code
MyClass myobject = new MyClass();
Data dataObject = myobject.getData();
@fromdev
fromdev / MyClass.java
Created August 15, 2019 02:40
MyClass - Supplier Lambda Example Code
public class MyClass {
public Data getData() {
// some remote processing code
};
}
@fromdev
fromdev / validateVin
Created July 20, 2018 09:01
Validate Vehicle Identification Number (VIN) Using JavaScript Regular Expressions
function validateVin(vin) {
var re = new RegExp("^[A-HJ-NPR-Z\\d]{8}[\\dX][A-HJ-NPR-Z\\d]{2}\\d{6}$");
return vin.match(re);
}
@fromdev
fromdev / TestBrowserUtil.java
Created January 10, 2018 18:11
Sample class how to use BrowserUtil.java
package browser.util;
import javax.servlet.http.HttpServletRequest;
import browser.util.BrowserUtil.BrowserType;
public class TestBrowserUtil {
public static void sample(HttpServletRequest request) {
@fromdev
fromdev / BrowserUtil.java
Created January 10, 2018 18:09
How To Identify Different Browsers In Java Server Side - Utility Classes
package browser.util;
public class BrowserUtil {
public static enum BrowserType {
INTERNET_EXPLORER, MOZILA_FIREFOX, SAFARI, NETSCAPE, GOOGLE_CHROME, FLOCK, UNKNOWN
}
/**
* Each browser sends a the user-agent field with different content
*