Skip to content

Instantly share code, notes, and snippets.

View feliperazeek's full-sized avatar
💭
Be there and give a shit

Felipe Oliveira feliperazeek

💭
Be there and give a shit
View GitHub Profile
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
object Solution {
def solution(A: Array[Int]): Int = {
val (results, _) = A.sorted.foldLeft((0, 0)) { (t, item) =>
val (current, last) = t
val next = last + 1
item match {
case x if x < 0 => (current, last)
case `last` => (item, item)
object Solution {
def solution(A: Array[Int]): Int = {
val positive = new java.util.BitSet()
val negative = new java.util.BitSet()
A.foldLeft(0) { (current, i) =>
val duplicate = if (i < 0) (negative get i * -1)
else (positive get i)
duplicate match {
import java.util.BitSet
object Solution {
def solution(A: Array[Int]): Int = {
val bitz = new BitSet(A.size + 1)
val good = A.foldLeft(true)((current, i) =>
if (current) {
(i, bitz.get(i)) match {
case (x, _) if x > A.size =>
@feliperazeek
feliperazeek / hive-site.xml
Created July 3, 2014 17:24
Hortonworks suggested settings Tez/Hive
<property>
<name>hive.vectorized.groupby.flush.percent</name>
<value>0.1</value>
</property>
<property>
<name>hive.vectorized.groupby.maxentries</name>
<value>10240</value>
</property>
<property>
<name>tez.session.am.dag.submit.timeout.secs</name>
@feliperazeek
feliperazeek / gist:3537872
Created August 30, 2012 19:07 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

CTags

Ctrl-t Ctrl-r rebuild tags
Ctrl-t Ctrl-y search for definitions

General

⌘T go to file
@feliperazeek
feliperazeek / .ctags
Created August 29, 2012 19:20
Scala CTags
--langdef=Scala
--langmap=Scala:.scala
--regex-scala=/def\s*([^(=[({ ]*)/\1/d,definition/
--regex-scala=/class\s*([^[( {]*)/\1/c,class/
--regex-scala=/trait\s*([^[( {]*)/\1/t,trait/
--regex-scala=/object\s*([^ {]*)/\1/o,object/
--regex-scala=/val\s*([^= ]*)/\1/v,val/
--regex-Scala=/^[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/c,classes/
--regex-Scala=/^[ \t]*object[ \t]*([a-zA-Z0-9_]+)/\1/o,objects/
--regex-Scala=/^[ \t]*trait[ \t]*([a-zA-Z0-9_]+)/\1/t,traits/
trait JDBCer {
this: AkkaAgentMySQLStateServiceComponent =>
val retryTimes = config int "db.extensions.retries" or 5
/**
* Get a random slave connection name for Jeeves
*/
def slaveDB(): Option[String] = {
// Randomize List
package com.klout.api.services
import akka.agent.Agent
import akka.dispatch._
import org.joda.time._
import com.klout.playful2.sugar._
import com.klout.playful2.zookeeper._
import com.klout.playful2.actors._
import java.util.{ Map => javaMap }
import java.{ lang => java }