Skip to content

Instantly share code, notes, and snippets.

View vahidhedayati's full-sized avatar

Vahid Hedayati vahidhedayati

View GitHub Profile
@vahidhedayati
vahidhedayati / gist:e5c839a534ce5fbd7b157bc617c44036
Last active May 29, 2017 14:03
Grails application logging errors to slack

Grails slack plugin appears to do most of the work here

Visit: https://slack.com/ and create a new slack channel Goto Configure apps/integration and create a webhook Configure webhook url in the plugin

If you are using pre grails 2.3, get hold of the grails 2 project from : https://github.com/mathifonseca/grails-slack/tree/grails-2.x

Copy the content of the plugin https://github.com/mathifonseca/grails-slack/tree/grails-2.x/src/groovy/grails/plugin/slack & https://github.com/mathifonseca/grails-slack/tree/master/grails-app/services/grails/plugin/slack to your local application For grails 2.0.1:

@vahidhedayati
vahidhedayati / TimeDuration removing milliseconds.md
Created October 21, 2016 10:01
TimeDuration removing milliseconds.md

When you have TimeCategory do calculation and return duration difference you will get it took 1.001 seconds for example.. To get rid of the milliseconds I used this hack, take from Tim Yates here:

http://stackoverflow.com/questions/16716802/how-to-format-time-durations-in-groovy

A slight tweak to set millseconds to 0 then parse out .000 from output...

  private String getDuration(Date startDate,Date endDate) {
 if (startDate && endDate) {
@vahidhedayati
vahidhedayati / gist:1df1597662065931b2083adfbdda0a54
Created October 17, 2016 22:42
compileStatic - config this way
@CompileStatic
class QueuekitLists {
////
/**
* Retrieve configuration value of reportPriorties
* this should be a list containing key value e.g: ReportName:Priority.HIGH
*
* Assign report priority back if not set to DEFAULT LOW
*/
@vahidhedayati
vahidhedayati / gist:71d92f8153ade5d732b3
Last active August 29, 2015 14:25
Apache-Shiro-LDAP-Dynamic-Permissions for grails

This is a guide on how to create dynamic security control for a grails application, in effect to control the actual security of your controller and actions for them via your own customised domainClasses and its own auto generated controllers views for the new domain classes. In this example the application refers to two additional domain objects: Environment and Application class. It also includes these as part of the authentication process. So if url being:

/doSomething/somethingAction?appId=XX&envId=XX

where controller is doSomething and action is somethingAction in that controller. It does a further check against those specifics on that somethingAction of appId and envId also matching security checks.

So if all you wish to do is basic dynamic controller and its action control then simply remove any reference do environment/application.

The below code would work in conjunction with a customised shiro configuration found:

@vahidhedayati
vahidhedayati / Grails3 plugin instructions.md
Last active July 31, 2016 14:52
Grails3 plugin instructions.md

http://grails.github.io/grails-doc/3.0.x/guide/upgrading.html

Follow above instructions in order to get the content of your grails plugin from older grails into grails 3.

A few notes on plugin names and folder names, I put down a few things here: https://groups.google.com/forum/#!topic/grails-dev-discuss/cG_6mvAO3f8

In there I mentioed mvn install - which does not appear to work under normal circumstances, in order to get a plugin to work locally follow grails install instructions or do it as inline plugin ..

@vahidhedayati
vahidhedayati / ggts-exclamation-howto
Created January 20, 2015 20:03
Grails GGTS how to overcome red exclamation mark or and red cross
Right I think its about time I put down some notes on this for an easy way of fixing plugin/war files with files missing that you may download off of git or other public places.
1. Plugins.
1.1 : Plugin missing files
If you pull in a plugin and attempt to open it in ggts sometimes it shows an incorrect folder structure and so on, a manual fix to this is to remove the project from ggts. then
1.1.1 : automatic fix:
run : grails integrate-with --eclipse