Skip to content

Instantly share code, notes, and snippets.

View alexcheng1982's full-sized avatar
🎯
Focusing

Fu Cheng alexcheng1982

🎯
Focusing
View GitHub Profile
@alexcheng1982
alexcheng1982 / Main.kt
Created January 31, 2018 21:15
Akka Streams Camel integration Main Kotlin file
import akka.NotUsed
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.stream.ClosedShape
import akka.stream.FlowShape
import akka.stream.Graph
import akka.stream.javadsl.GraphDSL
import akka.stream.javadsl.RunnableGraph
import akka.stream.javadsl.Source
import akka.stream.scaladsl.Flow
@alexcheng1982
alexcheng1982 / build.gradle
Created January 31, 2018 21:11
Akka Streams Camel integration build script
buildscript {
ext.kotlin_version = '1.2.21'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
@alexcheng1982
alexcheng1982 / port_forwarding.ps1
Created December 20, 2017 21:03
Windows port forwarding for EC2
<powershell>
$ipAddress = (invoke-restmethod -uri http://169.254.169.254/latest/meta-data/local-ipv4)
"Setting up port forwarding"
netsh interface portproxy add v4tov4 listenport=80 connectport=8080 connectaddress=$ipAddress
</powershell>
@alexcheng1982
alexcheng1982 / nginx_start.yml
Created December 20, 2017 21:02
Ansbile handler to start Nginx service
--
- name: start nginx
win_service:
name: nginx
start_mode: auto
state: started
@alexcheng1982
alexcheng1982 / nginx_setup.yml
Created December 20, 2017 21:01
Ansible task to setup Nginx on Windows
---
- name: install nginx
win_chocolatey:
name: nginx
state: present
- name: install nssm
win_chocolatey:
name: nssm
state: present
- name: copy nginx conf file
@alexcheng1982
alexcheng1982 / check-instances.js
Created December 19, 2017 20:02
AWS Lambda check instances
function findTag(tags, key) {
for (var i = tags.length - 1; i >= 0; i--) {
if (tags[i].Key === key) {
return tags[i].Value;
}
}
}
exports.handler = (event, context, callback) => {
var AWS = require('aws-sdk');
@alexcheng1982
alexcheng1982 / Dockerfile
Created December 17, 2017 21:15
Hubot Dockerfile
RUN groupadd --gid 1000 node \
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
# gpg keys listed at https://github.com/nodejs/node#release-team
RUN set -ex \
&& for key in \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
FD3A5288F042B6850C66B31F09FE44734EB7990E \
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
@alexcheng1982
alexcheng1982 / ops.js
Created December 17, 2017 21:14
Hubot handler
const yargs = require('yargs');
const spawn = require('child_process').spawn;
module.exports = (robot) => {
robot.respond(/deploy (.*)/i, (res) => {
let parser = yargs.command('deploy <build_num>', 'deploy a version', (yargs) => {
yargs
.positional('build_num', {
describe: 'build number',
})
@alexcheng1982
alexcheng1982 / external-scripts.json
Created December 17, 2017 21:13
Hubot external-scripts.json
[
"hubot-help"
]
@alexcheng1982
alexcheng1982 / hubot-dependencies.json
Created December 17, 2017 21:13
Hubot dependencies
"dependencies": {
"coffee-script": "^1.12.7",
"hubot": "^2.19.0",
"hubot-help": "^0.2.2",
"hubot-hipchat": "^2.12.0-6",
"hubot-scripts": "^2.17.2"
}