Skip to content

Instantly share code, notes, and snippets.

View hanrw's full-sized avatar
🎯
Focusing

itshan hanrw

🎯
Focusing
View GitHub Profile
import java.io.File
import akka.actor._
import akka.routing.{Routee, RemoveRoutee, ActorRefRoutee, AddRoutee}
import akka.stream.actor.ActorPublisher
import org.akkamon.core.ActorStack
import org.akkamon.core.instruments.CounterTrait
import play.api.libs.json.Json
import scala.annotation.tailrec
import scala.concurrent.duration._
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.http.MediaType
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
import org.springframework.test.context.web.WebAppConfiguration
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders
import org.springframework.test.web.servlet.setup.MockMvcBuilders
@hanrw
hanrw / PlayerController.groovy
Last active November 17, 2016 02:58
Spring mvc test sample
import org.springframework.http.MediaType
import org.springframework.web.bind.annotation.*
@RestController
public class PlayerController {
@RequestMapping(value = "/authenticate", method = RequestMethod.POST, consumes = MediaType.APPLICATION_XML_VALUE, produces = MediaType.APPLICATION_XML_VALUE)
public @ResponseBody PlayerAuthenticationResponse authenticate(@RequestBody final PlayerAuthentication request) {
return new PlayerAuthenticationResponse()
}
version: '2'
services:
mysql:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: demop@ssword
volumes:
- /home/finnplay/docker/var/lib/mysql:/var/lib/mysql
labels:
o.rancher.scheduler.global: 'true'
@hanrw
hanrw / gist:cec8342d6cb5efc8bafbbb3bab1a2341
Created July 3, 2017 09:54
registry-docker-compose.yml
version: '2'
services:
registry:
image: registry:2
environment:
REGISTRY_AUTH: htpasswd
REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt
REGISTRY_HTTP_TLS_KEY: /certs/domain.key
@hanrw
hanrw / Jenkins-docker
Created September 26, 2017 12:02
Jenkins build docker.
version: '2'
services:
activemq:
image: rmohr/activemq:5.10.0
volumes:
- /home/hanrenwei/Docker/activemq/conf/activemq.xml:/opt/activemq/conf/activemq.xml
- /home/hanrenwei/Docker/activemq/conf/groups.properties:/opt/activemq/conf/groups.properties
- /home/hanrenwei/Docker/activemq/conf/jetty-realm.properties:/opt/activemq/conf/jetty-realm.properties
- /home/hanrenwei/Docker/activemq/conf/users.properties:/opt/activemq/conf/users.properties
- /home/hanrenwei/Docker/activemq/data:/var/activemq/data
1. Setup a project
2. Add groovy SDK support:
https://www.bonusbits.com/wiki/HowTo:Add_Groovy_SDK_to_IntelliJ_IDEA
3. Download http://(yourjenkinsurl)/job/(yourpipelinejob)/pipeline-syntax/gdsl
- this will give you the .gdsl file - download this to the src folder of your project.
4. Finally follow this step - right click on the src folder -> Mark directory as -> Sources Root
# How to install `ipkg` on a Synology DS214
After a couple of days of trying to get `ipkg` woking on my DS214 I found [this article](https://github.com/trepmag/ds213j-optware-bootstrap) by [trepmag](https://github.com/trepmag). It is written for the DS213j, but it’s been working for me and [others](https://github.com/alberthild) for the DS214 too.
I have done some minor changed to clarify some things, but if you are a Linux guy (unlike me) my changes might be of no use to you.
## Guide
@hanrw
hanrw / hg stats.txt
Created December 28, 2017 09:35 — forked from aras-p/hg and git snippets and stats.md
hg churn and log cheat sheet
Graph of total commits by month, over last year:
hg churn -f "%Y-%m" -s -c -d "-365"
List of my commits over last year:
hg log -k aras -d "2013-01-01 to 2013-12-31" --template "{short(node)} {user(author)} {firstline(desc)}\n" >mycommits.txt
My lines changed count over last year (takes ages):
@hanrw
hanrw / KStream.java
Created March 30, 2018 11:35
KStream
@Bean
public KStream<String, Event> kStreamJson(StreamsBuilder builder) {
KStream<String, Event> stream =
builder.stream(topic, Consumed.with(Serdes.String(), new JsonSerde<>(Event.class)));
stream
.map(((key, value) -> KeyValue.pair(LocalDate.now().toString(), 1L)))
.filter(
(key, msg) -> {
System.out.println("Got a message! key = {}, value = {}" + key + " " + msg);