Skip to content

Instantly share code, notes, and snippets.

View ilmoralito's full-sized avatar

Mario Martinez ilmoralito

View GitHub Profile
@ilmoralito
ilmoralito / get all keys in a map
Last active June 18, 2024 14:06
Groovy get all keys in a map
def map = [language:"groovy", framework:"grails"]
def keys = map.keySet() as List
assert ["language", "framework"] == keys
@ilmoralito
ilmoralito / profileCommand
Last active October 12, 2017 15:08
Update current logged user password, using grails spring securit core plugin, i got help in this mail list http://grails.1312388.n4.nabble.com/update-current-user-password-in-spring-security-core-plugin-td4655284.html
package com.testing
import grails.plugin.springsecurity.annotation.Secured
class UserController {
def springSecurityService
@Secured(['ROLE_ADMIN'])
def profile(profileCommand cmd) {
if (request.method == "POST") {
if (cmd.hasErrors()) {
@ilmoralito
ilmoralito / job
Created March 21, 2014 17:55
Sending email from quartz using some view
//in quartz job
package com.testing
class SampleJob {
def mailService
static triggers = {
simple repeatInterval: 10000l // execute job once in 100000 seconds, just to try something
}
@ilmoralito
ilmoralito / showAndHide
Last active August 29, 2015 14:07
Show and hide content with jquery
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.measures { display: none; }
</style>
</head>
<body>
@ilmoralito
ilmoralito / app
Created October 10, 2014 14:52
passingDataToIds
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body {
font-family: sans-serif;
width: 960px;
font-size: 12px;
@ilmoralito
ilmoralito / sample
Created November 14, 2014 18:35
sample
...
if (data) {
var opt = $("<option>", { value:data.id, text:data.fullName, selected:true });
$("#client\\.id").append(opt);
}
...
@ilmoralito
ilmoralito / addClient
Created November 14, 2014 19:03
sample
if (!client.save(flush:true)) {
client.errors.allErrors.each { error ->
log.error "[$error.field: $error.defaultMessage]"
}
return false
}
@ilmoralito
ilmoralito / off
Created December 10, 2014 17:53
anular evento click
$("#trigger").on("click", function(e) {
var count = $('.phonesClient').length;
$(".phonesClient:last").clone().insertBefore($(this)).find('input');
if (count > 3){
$(this).off('click')
}
})
@ilmoralito
ilmoralito / file.js
Last active September 19, 2017 23:07
extracting non-repeated keys from a data list
// Given a set of data where the keys of the objects can vary
const data = [
{ name: 'Amanda', email: 'amanda@example.com', genre: 'Female' },
{ name: 'Daniel', email: 'daniel@example.com', genre: 'Male', telephones: ['8989 7667', '8765 4321'] },
{ name: 'Arnulfo', email: 'arnulfo@example.com', genre: 'Male', },
{ name: 'Ricardo', email: 'ricardo@example.com', genre: 'Male', city: 'Leon' },
{ name: 'Mario', genre: 'Male', single: true },
];
// Having this or similar html
<input type="password" name="password" id="password">
<button id="toggleButton">Show password</button
// And wanting to display the password when mousedown and hide the password when mouseup or mouseleave
// In a similar way as is done in the firefox async login form
// If you are in firefox you can go to this url: about:accounts?action=signin&entrypoint=menupanel
const password = document.querySelector('#password');