Skip to content

Instantly share code, notes, and snippets.

@kknd22
kknd22 / gist:c664b901029f120e830d
Last active August 29, 2015 14:03
build-cust-artifact-dependency.gradle
/**
* http://stackoverflow.com/questions/17875576/gradle-projects-depending-on-artifacts-created-by-sibling-projects
*/
apply plugin: 'java'
repositories {
mavenCentral()
}
@kknd22
kknd22 / groovy-reg-foo-bar.groovy
Last active August 29, 2015 14:13
groovy regular expression replacement foo-bar example
// matcher
def m = "foo-bar" =~ /(.+)(-)(.+)/
println m[0]
println m[0][1]
println m[0][2]
println m[0][3]
assert m[0] == ["foo-bar", "foo", "-", "bar"]
set dm_t_branch="dir"
set dm_ear=%dm_t_branch%\xxx.ear
set dm_war=%dm_t_branch%\yyy.war
jar -tf %dm_ear% | grep "lib/" | grep -v "^dm-"| sed -e "s:lib/::g" > gradle-ear-libs-jars.txt
jar -tf %dm_war% | grep "WEB-INF/lib/" | sed -e "s:WEB-INF/lib/::g" > gradle-libs-jars.txt
cat gradle-ear-libs-jars.txt > zjunk.txt
cat gradle-libs-jars.txt >> zjunk.txt
grep -v "^dm-" zjunk.txt | sort > 2-gradle-total-ear-war-jars.txt
@kknd22
kknd22 / intellij gradle multi module dependencies
Created March 3, 2015 03:31
Intellij IDEA to recognize Gradle module interdependencies
http://stackoverflow.com/questions/23164157/getting-intellij-idea-13-to-recognize-gradle-module-interdependencies
@kknd22
kknd22 / gist:c891c52e43cd65ba5be3
Created March 22, 2015 21:23
kafka - view message in the topic
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic apache_log --from-beginning
@kknd22
kknd22 / 0_reuse_code.js
Created April 18, 2016 13:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@kknd22
kknd22 / scala-symbols.txt
Created December 21, 2016 19:52
scala symbol operator
// Keywords
<- // Used on for-comprehensions, to separate pattern from generator
=> // Used for function types, function literals and import renaming
// Reserved
( ) // Delimit expressions and parameters
[ ] // Delimit type parameters
{ } // Delimit blocks
. // Method call and path separator
// /* */ // Comments
@kknd22
kknd22 / scala self explaination
Last active December 22, 2016 15:41
scala self
http://www.scala-lang.org/old/node/8194.html
http://stackoverflow.com/questions/4017357/difference-between-this-and-self-in-self-type-annotations
3 forms:
trait A {self: B =>..}
trait A {self =>..}
trait A {this: B =>..}
trait A {self: B =>..} is the most useful one. used primary for mixins.
'A' implements a small groups of very specific operations for very generic type. 'B' could be potentially implements another a small group.
@kknd22
kknd22 / scala+T-T
Last active January 5, 2017 20:52
scala +T -T convariance contravariance
http://blogs.atlassian.com/2013/01/covariance-and-contravariance-in-scala/
trait Function1[-T1, +R] {
def apply(t : T1) : R
...
}
This is single arg function in scala - T1 is basically input, R is output.
Any single arg function extends from this. And think through this rationally:
-T1 -> input needs to be less restrictive
@kknd22
kknd22 / MyAwsCrudS3.scala
Created November 3, 2017 13:56
scala code crud for aws s3 - fakes3
package junk
import com.amazonaws.{AmazonClientException, AmazonServiceException, ClientConfiguration}
import com.amazonaws.auth.{AWSStaticCredentialsProvider, BasicAWSCredentials}
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration
import com.amazonaws.services.s3.{AmazonS3Client, AmazonS3ClientBuilder, S3ClientOptions}
import com.amazonaws.services.s3.model.Bucket
import scala.collection.JavaConversions._
import com.amazonaws.services.s3.model.PutObjectRequest