I hereby claim:
- I am sbglasius on github.
- I am sbglasius (https://keybase.io/sbglasius) on keybase.
- I have a public key whose fingerprint is 4430 F93E 75DB 3F72 5E29 6FB3 2E29 0639 BD6C 45F9
To claim this, I am signing this object:
def findRealUrl(url) { | |
HttpURLConnection conn = url.openConnection() | |
conn.followRedirects = false | |
conn.requestMethod = 'HEAD' | |
if(conn.responseCode in [301,302]) { | |
if (conn.headerFields.'Location') { | |
return findRealUrl(conn.headerFields.Location.first().toURL()) | |
} else { | |
throw new RuntimeException('Failed to follow redirect') | |
} |
I hereby claim:
To claim this, I am signing this object:
Working on Grails 3 I realized that I no longer can specify external configuration using the standard grails.config.locations
property in Config.groovy
file.
Reason is obvious! There is no Config.groovy
now in Grails 3. Instead we now use application.yml
to configure the properties. However, you can't specify the external configuration using this file too!
What the hack?
Now Grails 3 uses Spring's property source concept. To enable external config file to work we need to do something extra now.
/* Written by Damián Adams | |
* October 2016 | |
* https://mianlabs.com/2016/10/09/making-a-4chan-twitter-bot-with-groovy-in-8-easy-steps/ | |
*/ | |
import groovy.json.JsonSlurper | |
import java.net.URL | |
import java.text.SimpleDateFormat | |
@Grab(group='org.twitter4j', module='twitter4j-core', version='4.0.5') | |
import twitter4j.Status |
package tests | |
import com.fasterxml.jackson.annotation.JsonFilter | |
import com.fasterxml.jackson.core.JsonGenerator | |
import com.fasterxml.jackson.databind.JsonMappingException | |
import com.fasterxml.jackson.databind.ObjectMapper | |
import com.fasterxml.jackson.databind.SerializationFeature | |
import com.fasterxml.jackson.databind.SerializerProvider | |
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor | |
import com.fasterxml.jackson.databind.node.ObjectNode |
#!/usr/bin/env groovy | |
import java.nio.file.Files | |
import groovy.cli.picocli.CliBuilder | |
import groovy.cli.picocli.OptionAccessor | |
def cli = new CliBuilder(usage: "./${this.class.getSimpleName()}.groovy <directory>") | |
cli.with { | |
header = "'directory' is the source directory update unittests. If not given, the process stops" | |
} |
This script is hacket together to make merging multiple repos into one as easy as possible. It clones each sub-project and then uses git-filter-repo to move each repo into a sub directory. Finally it uses https://github.com/robinst/git-merge-repos for the final merge.
In other words, it takes this:
| project-1 (separate repo)
| - dir-1
| - file-1.txt
| - README.md
#!/usr/bin/env groovy | |
import groovy.cli.picocli.CliBuilder | |
import groovy.cli.picocli.OptionAccessor | |
import groovy.json.JsonSlurper | |
import java.nio.file.Files | |
import java.nio.file.Path | |
import java.nio.file.Paths | |
import java.util.regex.Pattern |