Skip to content

Instantly share code, notes, and snippets.

View royki's full-sized avatar
😃
I may be slow to respond.

ROY royki

😃
I may be slow to respond.
View GitHub Profile
@royki
royki / checkJenkins.sh
Created April 18, 2017 12:41 — forked from julianchurchill/checkJenkins.sh
A bash script to query a Jenkins server. Use like this: 'checkJenkins.sh <jobname>' and it will query the server with the given job name every 30s. Use like this: 'checkJenkins.sh <jobname> tmux' and it will query the server once and output tmux coloured messages appropriate to display in a tmux status bar. E.g. add this to your .tmux.conf 'set …
#!/bin/bash
CONSOLE_RED="\033[2;31m"
CONSOLE_GREEN="\033[2;32m"
CONSOLE_CLEAR="\033[0m"
JENKINS_SERVER=http://my_jenkins_server
JOB=$1
JOB_QUERY=/job/${JOB}

Overview

Here you will find instructions for importing the datasets for M001: MongoDB Basics into a locally running MongoDB deployment.

Datasets

All datasets are provided in Amazon S3 in a single zip file (243 MB zipped; 1.5 GB unzipped). The files were created with the mongodump command. They may be imported into your MongoDB deployment using mongorestore. Note that these datasets include the indexes necessary to support example queries and labs used in M001. The datasets included are as follows.

@royki
royki / Scala.For.The.Impatient.md
Created June 25, 2019 15:03 — forked from hhimanshu/ Scala.For.The.Impatient.md
Scala for the Impatient Exercises

This gist will contain all the exercises from the book

object Solution {
def solution(N: Int): Int = {
if (N < 1) sys.error(s"Invalid input: $N")
@scala.annotation.tailrec
def foo(i: Int, total: Int): (Int, Int) = {
if ((i * i) >= N) (total, i)
else if (N % i == 0) foo(i + 1, total + 2)
else foo(i + 1, total)
}
object Solution {
def solution(S: String): Int = {
val max = S.length / 2
@scala.annotation.tailrec
def symmetryPoint(i: Int): Int = {
val left = S(i)
val right = S(S.length - 1 - i)
object Solution {
def solution(A: Array[Int]): Int = {
val N = A.size
if (N < 1 || N > 1000000) sys.error(s"Invalid array size: $N")
A.foldLeft(0) { (current, i) =>
i ^ current
}
}
@royki
royki / CodilityTreeHeight.scala
Created July 31, 2019 20:57 — forked from feliperazeek/CodilityTreeHeight.scala
Codility TreeHeight Scala
object Solution {
def solution(T: Tree): Int = {
def height(t: Tree, i: Int): Int = {
val left = (Option(t.l).map(height(_, i + 1)) getOrElse i)
val right = (Option(t.r).map(height(_, i + 1)) getOrElse i)
scala.math.max(i, scala.math.max(left, right))
}
@royki
royki / CodilityMissingInteger.scala
Created July 31, 2019 20:57 — forked from feliperazeek/CodilityMissingInteger.scala
Codility Missing Integer in Scala
object Solution {
def solution(A: Array[Int]): Int = {
val bitz = new java.util.BitSet(A.size)
val n = A.foldLeft(0) { (total, i) =>
if (i > 0 && i <= A.size && !bitz.get(i)) {
bitz.set(i)
total + 1
} else total
import scala.math.{min, abs}
object Solution {
def solution(A: Array[Int]): Int = {
if (A.size < 2 || A.size > 100000) sys.error(s"Invalid input - array size: ${A.size}")
val total = A.map(_.toLong).sum
(A.foldLeft[(Int, Long, Long)](-1, -1, 0l) { (t, i) =>
if (i < -1000 || i > 1000) sys.error(s"Invalid array element: $i")
object Solution {
def solution(A: Array[Int]): Int = {
(A.foldLeft[(Int, Option[Double], Int)]((0, None, -1)) { (t, item) =>
val (index, min, results) = t
val checkPair = index <= A.size - 2
val checkTrio = index <= A.size - 3