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
async void Main() | |
{ | |
var cnn = new SqlConnection("Data Source=ERPDBUAT;Initial Catalog=Enterprise_Misc; Integrated Security=true"); | |
cnn.Open(); | |
var cmd = new SqlCommand("SELECT * FROM ShopService.DivisionRules WHERE DivCode = 'MHL001'", cnn); | |
await cmd.ExecuteReaderAsync().ContinueWith(async rdr => { | |
await rdr.Result.ReadAsync().ContinueWith(ok => { | |
rdr.Result.GetBoolean(rdr.Result.GetOrdinal("IsMobileEnabled")).Dump(); | |
rdr.Result.GetBoolean(rdr.Result.GetOrdinal("IsWebEnabled")).Dump(); |
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.collection.mutable.ListBuffer | |
object HelloWorld { | |
def Start() { | |
println("OnStart") | |
} | |
def Complete() { | |
println("OnComplete") |
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 akka.actor.Actor | |
import akka.actor.ActorSystem | |
import akka.actor.Props | |
case class RequestMessage(req: String) | |
case class ResponseMessage(resp: String) | |
class ClientActor extends Actor { | |
def receive = { | |
case ResponseMessage(resp: String) => println(resp) |
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
// http://stackoverflow.com/questions/8104846/chart-of-ienumerable-linq-equivalents-in-scala | |
xs.Aggregate(accumFunc) -> xs.reduceLeft(accumFunc) | |
xs.Aggregate(seed, accumFunc) -> xs.foldLeft(seed)(accumFunc) | |
xs.Aggregate(seed, accumFunc, trans) -> trans(xs.foldLeft(seed)(accumFunc)) | |
xs.All(pred) -> xs.forall(pred) | |
xs.Any() -> xs.nonEmpty | |
xs.Any(pred) -> xs.exists(pred) | |
xs.AsEnumerable() -> xs.asTraversable // roughly | |
xs.Average() -> xs.sum / xs.length |
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
object Main { | |
implicit class Converter(val s: String) { | |
def MaybeInt: Option[Int] = { | |
try { | |
Some(s.toInt) | |
} | |
catch { |
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.io.Source | |
// value object - automatically implements equals and gethashcode | |
case class Line(lineNo: Int, partNo: String, title: String, description: String) | |
object Test { | |
// converts string array into Line value object | |
def toLine(args: Array[String]): Line = { | |
Line(args(0).toInt, args(1), args(2), args(3)) |
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
open Printf | |
type envelope = { | |
name: string; | |
amount: int; | |
} | |
type account = { | |
name: string; | |
balance: int; |
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 main | |
import ( | |
"fmt" | |
) | |
type contact struct { | |
name string | |
phone string | |
email string |
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 main | |
import ( | |
"bytes" | |
"compress/gzip" | |
"encoding/base64" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" |
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
void Main() | |
{ | |
var numbers = new int[]{11, 3, 9, 15, 7, 6, 2, 1, 5, 23, 18, 4}; | |
Quicksort(numbers, 0, numbers.Length-1); | |
foreach(var n in numbers){ | |
Console.WriteLine(n); | |
} | |
} | |
public void Quicksort(int[] elements, int left, int right) |