Skip to content

Instantly share code, notes, and snippets.

Abhijit Sarkar asarkar

Block or report user

Report or block asarkar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Graph.scala
package org.asarkar.data
sealed trait Edge[T] {
def tail: T
def head: T
}
sealed trait WeightedEdge[T] extends Edge[T] {
def weight: Double
View csd-wrapper.sh
#!/bin/bash
# description: Cisco Anyconnect CSD wrapper for OpenConnect
# author: https://github.com/asarkar/
# gist: https://gist.github.com/asarkar/fb4452a4abdf9e4a9752a7d55d2cdc93
# connect: sudo openconnect --background \
# --user=<username> \
# --authgroup=1 \
# --csd-user=<localhost username> \
# --csd-wrapper=<script location on localhost> \
# --os=mac-intel \
@asarkar
asarkar / csd-wrapper.sh
Last active Jul 8, 2019 — forked from l0ki000/csd-wrapper.sh
Cisco Anyconnect CSD wrapper for OpenConnect macOS client
View csd-wrapper.sh
#!/bin/bash
# Enter your vpn host here
CSD_HOSTNAME=
if [[ -z ${CSD_HOSTNAME} ]]
then
echo "Define CSD_HOSTNAME with vpn-host in script text. Exiting."
exit 1
fi
@asarkar
asarkar / akka-threading.scala
Last active Jan 15, 2017
Snippet showing execution on a separate dispatcher
View akka-threading.scala
blocking-io-dispatcher {
type = Dispatcher
executor = "thread-pool-executor"
thread-pool-executor {
fixed-pool-size = 16
}
throughput = 1
}
---
@asarkar
asarkar / Find.scala
Last active Dec 11, 2016
Can this be done using Applicative?
View Find.scala
val l = (1 to 20)
val isEven = (i: Int) => i % 2 == 0
val isLtTen = (i: Int) => i < 10
val isGtTen = (i: Int) => i > 10
val p1 = List(isEven, isLtTen)
val p2 = List(isEven, isGtTen)
val r1 = l.find(i => p1.forall(_ (i)))
val r2 = l.find(i => p2.forall(_ (i)))
View DemoApplication.java
@SpringCloudApplication
@EnableFeignClients
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@FeignClient(name = "httpbin", url = "httpbin.org")
public interface HttpBinClient {
@RequestMapping(path = "/post", method = POST, produces = APPLICATION_JSON_VALUE)
View Backpressure.java
ConnectableFlowable<Integer> pub = Flowable.range(1, 10000)
.publish();
pub.debounce(1, SECONDS)
.subscribeOn(computation())
.subscribe(new DefaultSubscriber<Integer>() {
@Override
public void onStart() {
request(1);
}
View FrequencyCalculator.java
public class FrequencyCalculator extends RecursiveTask<Map<Character, Integer>> {
private static final long serialVersionUID = -5328480156308631556L;
private static final int NUM_PROCESSORS = Runtime.getRuntime()
.availableProcessors();
private final String word;
public FrequencyCalculator(String word) {
this.word = word;
@asarkar
asarkar / pattern.scala
Created Jun 10, 2015
Scala Pattern Matching Demo
View pattern.scala
sealed abstract class BinaryTree
case class BinTreeLeaf(value: Int) extends BinaryTree
case class BinTreeNode(left: BinaryTree, right: BinaryTree) extends BinaryTree
def leafSum(tree: BinaryTree): Int = tree match {
case node: BinTreeNode => leafSum(node.left) + leafSum(node.right)
case leaf: BinTreeLeaf => leaf.value
}
"Method leafSum" should "traverse a binary tree in order" in {
@asarkar
asarkar / Mixin.scala
Created Jun 10, 2015
Scala Mixin Demo
View Mixin.scala
trait Logged { def log(msg: String) {} }
trait Chattery extends Logged { def chatter = log("I chatter. Do you mind?") }
trait ConsoleLogger extends Logged { override def log(msg: String) = println(msg) }
scala> val ch = new Chattery() with ConsoleLogger
ch: Chattery with ConsoleLogger = $anon$1@1ef7fe8e
scala> ch.chatter
You can’t perform that action at this time.