Skip to content

Instantly share code, notes, and snippets.

View abhardwaj4's full-sized avatar

Abhishek Bhardwaj abhardwaj4

View GitHub Profile
@abhardwaj4
abhardwaj4 / rediscluster.java
Created May 7, 2018 16:00
Redis Cluster connect
Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
//Jedis Cluster will attempt to discover cluster nodes automatically
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7379));
JedisCluster jc = new JedisCluster(jedisClusterNodes);
jc.set("foo", "bar");
String value = jc.get("foo");
@abhardwaj4
abhardwaj4 / fileWriteRead.js
Created March 2, 2017 06:38
FileWriteRead
var start = new Date();
var fs = require('fs');
var arr = [];
// Large Loop
for (var i = 0; i < 10000000; ++i) {
arr.push({x : i});
}
fs.writeFile('largefile.txt', JSON.stringify(arr), function(err){
@abhardwaj4
abhardwaj4 / swap.js
Created November 4, 2016 18:52
Swapping two variables in javascript
function swapUsingThirdVariable(a, b) {
var c = a;
a = b;
b = c;
}
function swapNumbersWithoutThirdVariable(a, b) {
a = a + b;
b = a - b;
a = a - b;
@abhardwaj4
abhardwaj4 / .content.xml
Created September 19, 2016 18:36
Override CUI.rte.plugins.KeyPlugin
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:ClientLibraryFolder"
categories="rte.coralui2"/>