Skip to content

Instantly share code, notes, and snippets.

Juan Ignacio Vimberg jivimberg

Block or report user

Report or block jivimberg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
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
@jivimberg
jivimberg / takeWhileInclusive.kt
Last active Jun 3, 2018
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/
View takeWhileInclusive.kt
// 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
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) {
You can’t perform that action at this time.