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
[{
"name": "felipe",
"age": 33
}, {
"name": "ty",
"age": 3
}]
@feliperazeek
feliperazeek / SimpleTriggerPlugin.java
Created February 23, 2016 01:14
Azkaban Simple Trigger Plugin
package azkaban.security;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
spring_profiles: postgresql
database:
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://uaa.ccbvglwadavl.us-west-2.rds.amazonaws.com:5432:/uaa
username: uaa
password: uaauaauaa
jwt:
token:
spring_profiles: postgresql
database:
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://${DB_PORT_5432_TCP_ADDR}:${DB_PORT_5432_TCP_PORT}/${DB_ENV_DB:postgres}
username: ${DB_ENV_USER:postgres}
password: ${DB_ENV_PASS:}
jwt:
token:
@feliperazeek
feliperazeek / csv-to-redis.py
Created November 29, 2015 14:59
Python script that converts CSV to list of Redis set commands to be mass inserted
#!/usr/bin/python
import sys
import getopt
import fileinput
import csv
import json
import bcrypt
def main(argv):
@feliperazeek
feliperazeek / CodilityStrSymmetryPoint.scala
Created October 9, 2015 05:35
Codility StrSymmetryPoint
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)
@feliperazeek
feliperazeek / CodilityTreeHeight.scala
Created October 7, 2015 06:54
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))
}
@feliperazeek
feliperazeek / CodilityOddOccurrencesInArray.scala
Last active July 31, 2019 20:57
Codility OddOccurrencesInArray
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
}
}
@feliperazeek
feliperazeek / CodilityCountFactors.scala
Created September 28, 2015 05:31
Codility CountFactors
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)
}
@feliperazeek
feliperazeek / CodilityMissingInteger.scala
Created September 17, 2015 06:30
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