This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import actors.Actor | |
import actors.Actor._ | |
object RingTopologySimulation extends Application { | |
case class Message(count: Int) | |
class Node(id: Int, stops: Int) extends Actor { | |
var next: Node = null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import actors.Actor | |
import actors.Actor._ | |
object StarTopologySimulation extends Application { | |
case class Message(sender: Node) | |
class Node(id: Int) extends Actor { | |
def act() { | |
val startTime = System.nanoTime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns net.abhinavsarkar | |
(:use [clojure.contrib.import-static])) | |
(import-static java.lang.Integer parseInt) | |
(def no-of-nodes | |
(do | |
(println "Number of nodes? ") | |
(parseInt (read-line)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns net.abhinavsarkar.unicode-partition | |
(:import [java.awt.font TextAttribute GlyphVector] | |
[java.awt Font] | |
[javax.swing JTextArea])) | |
(let [^java.util.Map text-attrs { | |
TextAttribute/FAMILY "Arial Unicode MS" | |
TextAttribute/SIZE 25 | |
TextAttribute/LIGATURES TextAttribute/LIGATURES_ON} | |
font (Font/getFont text-attrs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn create-auth-input-dialog | |
"Creates a JDialog to take the input of username and password from the user. | |
Returns the dialog. | |
Arguments are: | |
parent: the parent frame | |
dialog-title: the title of the dialog | |
dialog-message: the message shown in the dialog | |
dialog-width : the width of the dialog |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.abhinavsarkar.util; | |
import java.util.concurrent.CancellationException; | |
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.Future; | |
import java.util.concurrent.TimeUnit; | |
import java.util.concurrent.TimeoutException; | |
import java.util.concurrent.atomic.AtomicBoolean; | |
import java.util.concurrent.atomic.AtomicReference; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.math.{sin, cos, abs, round, ceil, Pi} | |
import scala.collection.mutable.Buffer | |
import scala.util.Random.nextPrintableChar | |
case class Point(x: Int, y: Int) | |
class Star(val spikes: Int, val kind: Int, val diameter: Int) { | |
lazy val vertices: Seq[Point] = { | |
val radius = diameter/2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import List | |
main :: IO () | |
main = do | |
noOfTestCases <- readLn | |
readTestCases noOfTestCases | |
readTestCases :: Integer -> IO () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Copyright (c) Abhinav Sarkar. All rights reserved. | |
; The use and distribution terms for this software are covered by the | |
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) | |
; which can be found in the file epl-v10.html at the root of this distribution. | |
; By using this software in any fashion, you are agreeing to be bound by | |
; the terms of this license. | |
; You must not remove this notice, or any other, from this software. | |
(ns socharts.socharts | |
(:import [java.util.zip GZIPInputStream] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn ascii-bar-chart | |
" | |
Prints the horizontal ASCII bar chart for the data given. | |
Handles both positive and negative values. | |
Use it to visualize data in the REPL. | |
Arguments: | |
data: a seq of key value pairs. the chart is printed in the order of this seq. | |
keys should be strings (or have a proper toString method). | |
values should be numbers. |