Skip to content

Instantly share code, notes, and snippets.

View rajeevprasanna's full-sized avatar

Rajeev Kumar kallempudi rajeevprasanna

View GitHub Profile
@rajeevprasanna
rajeevprasanna / MissingNumber.scala
Created October 28, 2017 07:08
Repeat and Missing Number ArrayBookmark Suggest Edit
/**
* Created by rajeevprasanna on 10/28/17.
* Question reference : http://www.geeksforgeeks.org/find-a-repeating-and-a-missing-number/
*/
object MissingNumber extends App {
val l = List( 873, 854, 355, 178, 157, 730, 97, 264, 376, 129, 721, 361, 298, 734, 797, 905, 570, 811, 289, 415, 120, 295, 100, 575, 895, 554, 810, 537, 47, 388, 770, 702, 643, 510, 197, 649, 500, 751, 596, 755, 871, 217, 456, 26, 567, 200, 571, 578, 93, 365, 114, 484, 657, 875, 620, 223, 110, 498, 35, 597, 740, 73, 565, 331, 845, 861, 725, 160, 343, 808, 61, 453, 743, 428, 242, 299, 358, 278, 434, 535, 460, 637, 209, 229, 586, 327, 172, 102, 585, 249, 256, 795, 658, 13, 161, 706, 450, 219, 594, 146, 470, 798, 720, 443, 850, 830, 62, 558, 192, 712, 448, 576, 214, 250, 45, 767, 257, 713, 336, 817, 87, 269, 305, 538, 849, 497, 346, 483, 841, 882, 411, 869, 339, 822, 121, 781, 136, 455, 568, 540, 247, 198, 679, 398, 206, 610, 324, 372, 403, 858, 70, 676, 27, 150, 42, 236, 439, 354, 891, 884, 1, 412, 99, 123, 878, 901, 334, 639, 67
<!DOCTYPE html>
<html lang="en">
<head>
<title>File downloader</title>
</head>
<body>
<div id="progress-msg">File is downloading. Please wait...</div>
<script>
function saveAs(blob, fileName) {
<?xml version="1.0" encoding="UTF-8"?>
<!--Created:ce44715c-8c4e-446b-879c-ea9ebe0f09c8-->
<OfficeApp
xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0"
xsi:type="MailApp">
<!-- Begin Basic Settings: Add-in metadata, used for all versions of Office unless override provided. -->
item.body.setSelectedDataAsync(
`<div class="<div class="customerClass"><span style="color:white;display:none" class="CustomerClass">hidden Text</span></div>`,
{coercionType: Office.CoercionType.Html},
function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed) {
console.error('failed!!!');
} else {
console.log('success');
}
});
<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp
xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0"
xsi:type="MailApp">
<!-- Begin Basic Settings: Add-in metadata, used for all versions of Office unless override provided. -->
import java.io.{FileInputStream, InputStream}
import java.nio.ByteBuffer
import java.security.MessageDigest
import java.util.concurrent.TimeUnit
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.HttpMethods.GET
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
import akka.stream.ActorMaterializer
@rajeevprasanna
rajeevprasanna / Main2.scala
Created June 30, 2017 11:00 — forked from zsolt-donca/Main2.scala
Playing around with Cats' State monad
package testing
import cats._
import cats.data._
import cats.implicits._
object Main2 extends App {
case class Stats(warning: Int, error: Int)
package futureeitherapplicativestack
import cats._
import cats.data._
import cats.implicits._
import scala.concurrent.{Await, Future}
import scala.concurrent.duration.Duration
import scala.concurrent.ExecutionContext.Implicits.global
import cats.MonadError
import cats.instances.either._
import cats.instances.future._
import cats.instances.try_._
import cats.syntax.applicativeError._
import cats.syntax.flatMap._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
@rajeevprasanna
rajeevprasanna / statefactorial.scala
Created June 29, 2017 10:36 — forked from calvinlfer/statefactorial.scala
Factorial using the State monad
import cats.data.State
import cats.data.State._
def factorialWithState(x: Int): Int = {
def stateFactorial: State[Int, Int] =
get.flatMap(x =>
if (x <= 1)
State.pure(1)
else {
set[Int](x - 1).flatMap(_ => stateFactorial.map(z => x * z))