Skip to content

Instantly share code, notes, and snippets.

Avatar

Juan Ignacio Vimberg jivimberg

View GitHub Profile
@jivimberg
jivimberg / background.js
Last active Aug 29, 2015
OSN Notifications Extension for Chrome
View background.js
var osnURL = "https://osn-fusioncrm.oracle.com/osn/social/api/v1";
var defaultNotificationDuration = 5000;
var loggedUserId;
var previousTabId=-1, previousData=[];
function showNotification(userID, titleTxt, bodyTxt) {
if (window.webkitNotifications) {
console.log("Notifications are supported!");
var notification = window.webkitNotifications.createNotification(
osnURL+"/pictures/"+userID+"/profile", // The image.
View setup_java5_mac.bash
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.5.0/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
@jivimberg
jivimberg / sendForm.gs
Created Jan 3, 2017
Email Google Form daily full script
View sendForm.gs
function sendFormEmail() {
var toEmailAddress = "someone@gmail.com";
var htmlMessage = HtmlService.createHtmlOutputFromFile("Name-of-your-HTML-file.html").getContent();
var subject = "Subject";
var message = "Some message";
MailApp.sendEmail(toEmailAddress, subject, message, {
htmlBody: htmlMessage
});
}
@jivimberg
jivimberg / unreadCount.gs
Created Jan 18, 2017
Google Apps Script to get notified about the number of unread emails in an inbox
View unreadCount.gs
function unreadCount() {
var unreadCount = GmailApp.getInboxUnreadCount();
var masterEmail = "<your-email@something.com>";
var subject = "Your unread count";
var message = "You have " + unreadCount + " emails"
MailApp.sendEmail(masterEmail, subject, message);
}
View ChannelApproach.kt
fun fetchMergeRequestsChannel(gitLabService: GitLabService, lastProductionSha: String): ReceiveChannel<MergeRequest> {
return produce {
var page = 1
while (true) {
gitLabService.delayedFetchMergeRequests(page++).forEach { send(it) }
}
}.takeWhile { it.commitSha != lastProductionSha }
}
fun main(args: Array<String>) {
@jivimberg
jivimberg / build.gradle
Last active Apr 27, 2018
Jacoco on Gradle - How to verify coverage
View build.gradle
apply plugin: "jacoco”
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.79
}
}
}
@jivimberg
jivimberg / build.gradle
Created Apr 27, 2018
Jacoco on Gradle - How to verify coverage with exclusions
View build.gradle
jacocoTestCoverageVerification {
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
'com/example/my/package/*',
'com/example/service/MyApplication.kt',
'com/google/protobuf/*'
])
})
}
@jivimberg
jivimberg / build.gradle
Created Apr 27, 2018
Jacoco on Gradle - How to verify coverage with exclusions - WRONG
View build.gradle
jacocoTestCoverageVerification {
violationRules {
rule {
excludes = [
'com/example/my/package/*',
'com/example/service/MyApplication.kt',
'com/google/protobuf/*'
]
limit {
minimum = 0.79
View Person.kt
class Person() {
private lateinit var _other: Person
private constructor(_other: Person) : this() {
this._other = _other
}
val other: Person
get() {
if (!::_other.isInitialized) {
@jivimberg
jivimberg / CoroutinesUtils.kt
Last active Jul 7, 2020
SQS Consumer using Kotlin coroutines and pool of workers.
View CoroutinesUtils.kt
package com.jivimberg.sqs.published
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.isActive
import kotlinx.coroutines.yield
import java.lang.Thread.currentThread
suspend fun CoroutineScope.repeatUntilCancelled(block: suspend () -> Unit) {
while (isActive) {
You can’t perform that action at this time.