Skip to content

Instantly share code, notes, and snippets.

View grainier's full-sized avatar
🏠
Working from home

Grainier Perera grainier

🏠
Working from home
View GitHub Profile
@grainier
grainier / compose.yaml
Created August 31, 2025 14:36
Docker Compose for headless rTorrent + File Browser + ruTorrent
# Docker Compose for headless rTorrent + File Browser + ruTorrent
#
# Instructions:
# 1. Create required directories in the same folder as this file:
# mkdir -p downloads session filebrowser config/rtorrent
# 2. (Optional) Place your custom rtorrent.rc at:
# config/rtorrent/rtorrent.rc
# to include any additional settings; daemon mode is enabled via the command below,
# but you can also add `system.daemon.set = true` in that file.
# 3. Bring up the stack (after shutting down any existing one):
@grainier
grainier / UpperBoundIssue.java
Created September 27, 2023 08:01
Apache Helix UpperBoundIssue with `OnlineOfflineStateModel`
package org.apache.helix.examples;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
@grainier
grainier / HelixClusteringIssue.java
Last active June 19, 2022 04:50
Sample Code To Reproduce An Issue In Helix
package org.apache.helix.examples;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
import org.apache.helix.ConfigAccessor;
import org.apache.helix.HelixAdmin;
import org.apache.helix.HelixDefinedState;
import org.apache.helix.HelixManager;
import org.apache.helix.HelixManagerFactory;
@grainier
grainier / ClusterSetup.java
Last active June 18, 2022 04:58
Helix Util Functions
public class ClusterSetup {
InitializingBean init() {
return () -> {
// Create admin.
LOG.info("Creating cluster admin...");
HelixAdmin admin = new ZKHelixAdmin.Builder()
.setZkAddress(appConfig.getZkClientUrl()).build();
ConfigAccessor configAccessor = new ConfigAccessor.Builder()
.setZkAddress(appConfig.getZkClientUrl()).build();
@grainier
grainier / main.bal
Last active May 25, 2021 04:01
Ballerina Query Expression Sample
import ballerina/io;
type Author record {|
readonly int id;
string name;
|};
type Category record {|
readonly int id;
string name;
import ballerina/io;
type Person record {|
string firstName;
string lastName;
string deptAccess;
|};
type Department record {|
string name;
@grainier
grainier / stream_pipeline.bal
Last active April 18, 2020 03:41
POC for a Stream Pipeline
import ballerina/io;
// -------- Types ---------
public type _Iterator abstract object {
public function next() returns record {|(any|error) value;|}|error?;
};
public type _StreamFunction abstract object {
public _StreamFunction? prevFunc;
public function process() returns _Frame|error?;
@grainier
grainier / sample.bal
Created November 21, 2019 05:50
ThrottleWindow and Sample impl for WSO2 MGW
// Copyright (c) 2019 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
@grainier
grainier / forever_sample.bal
Created February 27, 2019 05:41
Sample usage of length window and count aggregator
forever {
from inputStream window length(2)
select inputStream.name, inputStream.age, inputStream.status, count() as count
group by inputStream.school
=> (Teacher [] emp) {
foreach var e in emp {
outputStream.publish(e);
}
}
}
@grainier
grainier / aggregator.bal
Created February 27, 2019 05:31
Aggregator abstract object
public type Aggregator abstract object {
public function copy() returns Aggregator;
public function process(anydata value, EventType eventType) returns anydata;
};