Skip to content

Instantly share code, notes, and snippets.

@arthurtsang
arthurtsang / DynamicServiceActivatorBeanDefinitionParser.java
Last active March 18, 2020 09:23
Bean definition parser for custom spring namespace
public class DynamicServiceActivatorBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
protected Class getBeanClass(Element element) {
return DefaultDynamicServiceActivator.class;
}
@Override
protected void doParse(Element element, BeanDefinitionBuilder bean) {
List<Element> methodElements = DomUtils.getChildElementsByTagName(element, "method");
ManagedMap<String, BeanDefinition> methodMetadataMap = null;
@arthurtsang
arthurtsang / Dockerfile
Last active September 25, 2019 06:48
Dockerfile for Git Server
FROM nextflow:19.07.0
# copy nextflow pipeline to /bfx/nextflow
ADD . /bfx/nextflow
# install git (and configure it), nginx, fcgiwrap and apache2-utils
RUN apt-get update && \
apt-get install -y git && \
git config --global user.email "admin@company.com" && \
git config --global user.name "company admin" && \
@arthurtsang
arthurtsang / nginx config
Created September 25, 2019 06:43
nginx config for git server
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/git;
# Add index.php to the list if you are using PHP
@arthurtsang
arthurtsang / run.sh
Last active September 25, 2019 06:37
run.sh to start nginx and fcgiwrap
#!/usr/bin/env bash
set -exuo pipefail
export PATH=$PATH:/bfx/bin/nextflow/19.07.0
spawn-fcgi -u www-data -s /var/run/fcgiwrap.socket /usr/sbin/fcgiwrap
nginx -g "daemon on;"
nextflow "$@"
@arthurtsang
arthurtsang / gmail-html.utils.ts
Last active August 30, 2019 18:14
Extracting HTML from GMail
/**
* search for email with gmailSearchQuery (e.g. "to: someone@gmail.com subject: spam")
* and get the raw content of the mail
*/
async searchEmail(gmailSearchQuery: string): Promise<any[]> {
const auth = await this.authorize();
const gmail = google.gmail({ version: 'v1', auth });
return new Promise((resolve, reject) => {
gmail.users.messages.list(
{
@arthurtsang
arthurtsang / app.po.ts
Last active August 30, 2019 17:08
Simple utility class for protractor
import { browser, ElementFinder, ExpectedConditions, ProtractorBrowser, by } from 'protractor';
export const defaultTimeout = 10000;
export class AppPo {
browserWindow: ProtractorBrowser;
constructor(browserWindow: ProtractorBrowser = browser) {
this.browserWindow = browserWindow;
}
@arthurtsang
arthurtsang / gmail-auth.utils.ts
Created August 30, 2019 16:59
authorize and get token from gmail api using protractor
import gmailCred from '../resources/gmail.credentials.json';
import { gmail_v1, google } from 'googleapis';
import * as fs from 'fs';
import { OAuth2Client } from 'google-auth-library';
import { browser, by, ElementFinder } from 'protractor';
// If modifying these scopes, delete token.json.
const SCOPES = ['https://www.googleapis.com/auth/gmail.readonly'];
// The file token.json stores the user's access and refresh tokens, and is
// created automatically when the authorization flow completes for the first
@arthurtsang
arthurtsang / DynamicServiceActivator.java
Created March 29, 2013 01:21
Create a Spring Integration Channel programatically and register that as a Spring bean
private SubscribableChannel createInputChannel(String inputChannelName) {
PublishSubscribeChannel channel = new PublishSubscribeChannel();
channel.setBeanName(inputChannelName);
channel.setBeanFactory(applicationContext);
//channel.setApplySequence(true);
((ConfigurableApplicationContext)applicationContext).getBeanFactory().registerSingleton(inputChannelName, channel);
return channel;
}
@arthurtsang
arthurtsang / conv_deconv_variational_autoencoder.py
Created February 14, 2017 06:29 — forked from Newmu/conv_deconv_variational_autoencoder.py
Prototype code of conv/deconv variational autoencoder, probably not runable, lots of inter-dependencies with local codebase =/
import theano
import theano.tensor as T
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
from theano.tensor.signal.downsample import max_pool_2d
from theano.tensor.extra_ops import repeat
from theano.sandbox.cuda.dnn import dnn_conv
from time import time
import numpy as np
from matplotlib import pyplot as plt
@arthurtsang
arthurtsang / introrx.md
Created January 31, 2017 19:20 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing