Skip to content

Instantly share code, notes, and snippets.

View xymor's full-sized avatar

Raphael Miranda xymor

View GitHub Profile
@xymor
xymor / build.gradle
Created January 24, 2019 19:39
kotlin gradle idea
import java.text.SimpleDateFormat
buildscript {
ext.kotlin_version = '1.3.11'
ext.spek_version = '1.0.9'
ext.junit_runner_version = '1.0.0-M3'
repositories {
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
@xymor
xymor / monitoring-mongo.sh
Created January 21, 2019 18:02
Monitor your OpLog using AWS Cloudwatch
#!/bin/bash
JSON=`mongo --quiet -u root -p pass --authenticationDatabase admin --eval "JSON.stringify(db.getReplicationInfo())" database.com.br:27017/local`
TIMEDIFF=`echo $JSON | jq '.timeDiffHours'`
echo $TIMEDIFF
aws cloudwatch put-metric-data --region sa-east-1 --metric-name MongoTimeDiffHours --namespace Midas --value "`echo $TIMEDIFF`" --timestamp `date -u "+%Y-%m-%dT%H:%M:%SZ"`
@xymor
xymor / hazelcast-aws.groovy
Created December 18, 2018 19:35
connect to aws hazelcast cluster
@Grab('com.hazelcast:hazelcast:3.7.4')
@Grab('com.hazelcast:hazelcast-aws:2.1.0')
import com.hazelcast.config.*
import com.hazelcast.core.Hazelcast
import com.hazelcast.spi.discovery.impl.*
import com.hazelcast.aws.*
import com.hazelcast.core.ILock
@xymor
xymor / gvt-mtu.js
Last active September 8, 2018 02:47 — forked from anonymous/gvt-mtu.js
script para mudar mtu do roteador GVT
//acessar 192.168.25.1/save_rg_conf.cgi
var objts = {};
$.xmo.getValuesTree("Device/IP/Interfaces/Interface[@uid='1']/MaxMTUSize");
$.xmo.getValuesTree("Device/IP/Interfaces/Interface[@uid='1']/LowerLayers");
$.xmo.getValuesTree("Device/IP/Interfaces/Interface[@uid='2']/MaxMTUSize");
$.xmo.getValuesTree("Device/IP/Interfaces/Interface[@uid='2']/LowerLayers");
@xymor
xymor / definition
Last active June 7, 2018 06:38
script to automatically attach and detach an EC2::Instance from elbs
Our architecture uses an Ec2:Instance to define a master,
such instance doesn't have the automatic management of elb attachment
provided by the AWS::AutoScaling::AutoScalingGroup to slaves so
this script roughly replicates it by attaching an instance
upon boot and releasing it during shutdown.
@xymor
xymor / gist:4549291
Last active May 25, 2018 19:54
Encrypt/decrypt with Blowfish/ECB/NoPadding
import javax.crypto.spec.SecretKeySpec
import javax.crypto.Cipher
import org.apache.commons.codec.binary.Base64
def encrypt(encrypt,en_key) {
if(encrypt.size() % 8 != 0){ //not a multiple of 8
byte[] padded = new byte[encrypt.length + 8 - (encrypt.length % 8)];
//copy the old array into it
@xymor
xymor / RemoveDuplicates.java
Created April 23, 2018 14:43
hackerrank RemoveDuplicates from linkedlist
/*
Node is defined as
class Node {
int data;
Node next;
}
*/
Node RemoveDuplicates(Node head) {
Node current = head;
@xymor
xymor / query.kt
Created April 19, 2018 21:16
How to run a mongo aggregation pipeline using plain json mongo query insteal of spring data dsl
fun reportServices(stores: List<Store>, start: LocalDate, end: LocalDate, pageable: Pageable): Pair<List<java.util.HashMap<*, *>>, Int> {
val pipeline = """
[
{#match: {
'processed.accountingCodePrimary': {#ne: null},
'processed.specialization': {#ne: 'NONE'},
'processed.authorizer.#id': {#eq: 'WK'},
'processed.transactionCodeConsult': {#ne: 'YES'}
}},
@xymor
xymor / TheTimeinWords.kt
Created April 19, 2018 14:55
The Time in Words from Hackerrank in kotlin
val dictionary = mapOf<Int,String>(
1 to "one",
2 to "two",
3 to "three",
4 to "four",
5 to "five",
6 to "six",
7 to "seven",
8 to "eight",
9 to "nine",
@xymor
xymor / install.sh
Created March 31, 2018 18:48
Installing a fresh ubuntu development workstation
#Installs sdkman
curl -s "https://get.sdkman.io" | bash
#Installs python
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
#Installs ruby
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable --ruby