Skip to content

Instantly share code, notes, and snippets.

View jivimberg's full-sized avatar

Juan Ignacio Vimberg jivimberg

View GitHub Profile
@jivimberg
jivimberg / background.js
Last active August 29, 2015 14:05
OSN Notifications Extension for Chrome
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.
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.5.0/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
@jivimberg
jivimberg / sendForm.gs
Created January 3, 2017 07:18
Email Google Form daily full script
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 January 18, 2017 16:31
Google Apps Script to get notified about the number of unread emails in an inbox
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);
}
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 April 27, 2018 02:25
Jacoco on Gradle - How to verify coverage
apply plugin: "jacoco”
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.79
}
}
}
@jivimberg
jivimberg / build.gradle
Created April 27, 2018 03:02
Jacoco on Gradle - How to verify coverage with exclusions
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 April 27, 2018 05:47
Jacoco on Gradle - How to verify coverage with exclusions - WRONG
jacocoTestCoverageVerification {
violationRules {
rule {
excludes = [
'com/example/my/package/*',
'com/example/service/MyApplication.kt',
'com/google/protobuf/*'
]
limit {
minimum = 0.79
@jivimberg
jivimberg / takeWhileInclusive.kt
Last active December 18, 2020 10:36
Inclusive implementation of takeWhile for Kotlin. Inspired from this gist: https://gist.github.com/matklad/54776705250e3b375618f59a8247a237 . Read more about this implementation on my blog: https://jivimberg.io/blog/2018/06/02/implementing-takewhileinclusive-in-kotlin/
// kotlin.collections
inline fun <T> Array<out T>.takeWhileInclusive(
predicate: (T) -> Boolean
): List<T> {
var shouldContinue = true
return takeWhile {
val result = shouldContinue
shouldContinue = predicate(it)
result
class Person() {
private lateinit var _other: Person
private constructor(_other: Person) : this() {
this._other = _other
}
val other: Person
get() {
if (!::_other.isInitialized) {