Skip to content

Instantly share code, notes, and snippets.

View sizovs's full-sized avatar
🌴
Mentoring software developers @ principal.dev

Eduards Sizovs sizovs

🌴
Mentoring software developers @ principal.dev
View GitHub Profile
new File('.').eachFileRecurse(groovy.io.FileType.FILES) {
if (it.name.endsWith(".java")) {
def hits = it.text =~ /\/\/\s*DROP\s*\[\s*(.*)\s*\]\n/
hits.each { match, key ->
def dropConditionForAGivenKey = dropConditions[(key)]
if (!dropConditionForAGivenKey) {
println("<!> Cannot find drop conditions for key '$key'")
return
}
try {
Map dropConditions = [
new_do_stuff_toggled : { cfg("new_do_stuff.enabled") == "true" },
marketing_campaign_finished : { timeCame "09/04/2014" }
]
def timeCame(String date) {
def today = new Date()
def expirationDate = new Date().parse('dd/MM/yyyy', date)
today.after expirationDate
}
pattern = ~/.*---(.*)$/
def droppables = []
manager.build.logFile.eachLine { line ->
matcher = pattern.matcher(line)
if(matcher.matches()) {
droppables << matcher.group(1)
}
}
pattern = ~/.*<!>(.*)$/
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.HttpResponseException
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.2')
version = args[0]
if (!version) {
throw new IllegalArgumentException("No version specified")
}
archive = "askfm-node-$version-docker.zip"
host = 'http://172.16.0.2:8081'
package fm.ask.components.counter;
import static org.joda.time.Duration.standardDays;
import org.joda.time.Duration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.rubylight.conf.IConfProperty;
package fm.ask.components.counter;
import static org.joda.time.Duration.standardDays;
import org.joda.time.Duration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.rubylight.conf.ConfFacade;
@Retention(RetentionPolicy.RUNTIME)
@Target([ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.ANNOTATION_TYPE, ElementType.PARAMETER])
@BindingAnnotation
@AutoBind
@interface MySQL {
String databaseName()
}
String[] tokenize(String tokenizable) {
if (tokenizable == null || tokenizable.isEmpty()) {
return null;
}
tokenize ...
}
def "returns null if there is nothing to tokenize"() {
expect:
tokenizer.tokenize(tokenizable) == result
where:
tokenizable || result
null || null
"" || null
}
String[] printingTokenizer(String tokenizable) {
String[] tokens = tokenizer(tokenizable);
if (tokens != null) {tokens.each(System::out::println) }
return tokens;
}