Skip to content

Instantly share code, notes, and snippets.

@Bl-nK
Bl-nK / MessagingController.groovy
Created July 3, 2018 18:36 — forked from xmlking/MessagingController.groovy
How to secure WebSocket connections (WebSocket over STOMP) ? Grails sample app : https://github.com/xmlking/grails-batch-rest
import grails.plugin.springsecurity.annotation.Secured
import org.springframework.messaging.handler.annotation.DestinationVariable
import org.springframework.messaging.handler.annotation.MessageMapping
import org.springframework.messaging.handler.annotation.SendTo
import org.springframework.messaging.simp.annotation.SendToUser
import org.springframework.messaging.simp.annotation.SubscribeMapping
import org.sumo.apiapp.stomp.StompExceptionHandler
import java.security.Principal
@Bl-nK
Bl-nK / git-deployment.md
Created August 23, 2017 21:28 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your lokal GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like my Deepl.io to act upon a Web-Hook that's triggered that service.

@Bl-nK
Bl-nK / sorting.groovy
Created December 5, 2016 20:50
Sort multiple columns in Groovy
def myList = [['dateCreated': new Date(), 'isHighlighted': false],['dateCreated': new Date()+1, 'isHighlighted': true],['dateCreated': new Date()+2, 'isHighlighted': true],['dateCreated': new Date()+3, 'isHighlighted': false]]
myList.sort{x,y->
y.isHighlighted <=> x.isHighlighted ?: y.dateCreated <=> x.dateCreated
}
@Bl-nK
Bl-nK / GebExample.groovy
Last active August 9, 2018 08:18
Scraping with Geb Example
@Grapes([
@Grab("org.codehaus.geb:geb-core:0.7.2"),
@Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.52.0"),
@Grab("org.seleniumhq.selenium:selenium-support:2.52.0")
])
import geb.Browser
def recentPosts
Browser.drive {
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
import java.security.InvalidKeyException
String hmac_sha256(String secretKey, String data) {
try {
Mac mac = Mac.getInstance("HmacSHA256")
SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes(), "HmacSHA256")
mac.init(secretKeySpec)
byte[] digest = mac.doFinal(data.getBytes())
@Bl-nK
Bl-nK / Example.groovy
Created January 24, 2016 01:15
Geb is easy!
Browser.drive{
go(url)
value1 = $('tr:nth-child(1) > td:nth-child(7) > a[href^="https://baseurl.com/derp/"]').text()
value2 = $('tr:nth-child(1) > td:nth-child(6)').text().tokenize()[0]
}
@Bl-nK
Bl-nK / BuildConfig.groovy
Last active August 29, 2015 14:15
Export Plugin Install
repositories {
mavenRepo "http://repo.grails.org/grails/core"
}
dependencies {
compile 'commons-beanutils:commons-beanutils:1.8.3'
}
plugins {
compile ":export:1.6"
@Bl-nK
Bl-nK / gist:3e198cd04354c3cc945a
Created January 4, 2015 00:34
Mint 17 Sources
deb http://packages.linuxmint.com qiana main upstream import #id:linuxmint_main
deb http://extra.linuxmint.com qiana main #id:linuxmint_extra
deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu/ trusty partner
@Bl-nK
Bl-nK / gist:995a6e766af1e2a1a99e
Created December 26, 2014 18:56
Curl with only HTTP status code over TOR
torsocks curl -sL -w "%{http_code}" $URL -o /dev/null 2>/dev/null
@Bl-nK
Bl-nK / geocoder.groovy
Last active August 29, 2015 14:07
Google Geocoder request in Groovy
import groovy.json.JsonSlurper
//Lat and Lon. You can also use any search that you would normally use in Google Maps
String arguments = "34.1030032 -118.4104684"
def base = 'https://maps.googleapis.com/maps/api/geocode/json?address='
def apiKey = '&key=YOUR_API_KEY' //Not required
def url = base + arguments.tokenize().join('+') + apiKey
def json = new JsonSlurper().parseText( new URL(url).text )