Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Kasun Thennakoon tmkasun

🏠
Working from home
View GitHub Profile
@tmkasun
tmkasun / Gauge.jsx
Created Feb 18, 2021
How to use canvas-gauges with React using Reeact hooks
View Gauge.jsx
import { LinearGauge, RadialGauge } from 'canvas-gauges'
import React, { useEffect, useRef } from 'react'
export default (props) => {
const { value, isRadial = false } = props;
const gaugeDOM = useRef();
const gauge = useRef();
useEffect(() => {
const options = Object.assign({}, props, {
renderTo: gaugeDOM.current
@tmkasun
tmkasun / autoipset
Last active Jan 9, 2021
OpenWRT Create IPset on router startup
View autoipset
#!/bin/sh /etc/rc.common
# OpenWrt /etc/init.d/ script to automatically add ipsets across reboots
# For more info about how to write init scripts https://openwrt.org/docs/techref/initscripts
#
# howto:
# - upload this file as /etc/init.d/autoipset
# - # chmod 755 /etc/init.d/autoipset
# - # /etc/init.d/autoipset enable
# - # /etc/init.d/autoipset start
@tmkasun
tmkasun / rrdbackup
Created Jan 8, 2021 — forked from squarewf/rrdbackup
OpenWrt /etc/init.d/ script to backup and restore the rrd (collectd) database, to preserve data across reboots
View rrdbackup
#!/bin/sh /etc/rc.common
# OpenWrt /etc/init.d/ script to backup and restore the rrd (collectd) database, to preserve data across reboots
#
#
# howto:
# - upload this file as /etc/init.d/rrdbackup
# - (optional) adjust BACKUP_DIR below to point to a different target directory for the backup (e.g., a USB drive)
# - # chmod +x /etc/init.d/rrdbackup
# - # /etc/init.d/rrdbackup enable
@tmkasun
tmkasun / nginx CORS configuration.md
Last active Dec 21, 2020
How to configure Nginx to add CORS
View nginx CORS configuration.md

This document explain how to

  • Generate SSL self sign certificate with subject alternative names using openssl tool
  • Configure nginx to add CORS OPTION call handler for none-cors endpoints

This gist is mostly for my future references 😄

  • First you need to have openssl configuration file to tell the tool what kind of certificate do you need, Following is a sample certificate file containing two SAN domains
@tmkasun
tmkasun / userThemes.js
Created Nov 27, 2020
WSO2 API Manager 3.2.0+ sample publisher theme
View userThemes.js
/**
* IMPORTANT: This file only contains theme JSS of the Publisher app, Don't add other configuration parameters here.
* This theme file is an extension of material-ui default theme https://material-ui.com/customization/default-theme/
* Application related configurations are located in `<PUBLISHER_ROOT>site/public/theme/settings.js`
*/
const userThemes = {
light(theme) {
return (
{
overrides: {
@tmkasun
tmkasun / Logout.jsx
Created Sep 4, 2020
Sample custom redirect
View Logout.jsx
import React, { Component } from 'react';
import User from '../data/User';
import Utils from '../data/Utils';
/**
* Logout component
* @class Logout
* @extends {Component} Logout component
*/
class Logout extends Component {
@tmkasun
tmkasun / config.md
Last active May 25, 2020
How to configure nginx as a revers proxy for WSO2 API Manager SPA apps
View config.md

For APIM 3.0.0

Update deployment.toml

[transport.https.properties]
proxyPort = 443

[server]
hostname = "knnect.lk"
@tmkasun
tmkasun / defaultTheme.js
Created Apr 13, 2020
Sample config to enable language switcher
View defaultTheme.js
const Configurations = {
/* Refer devportal/source/src/defaultTheme.js */
custom: {
languageSwitch: {
active: true,
languages: [
{
key: 'en',
image: '/site/public/images/flags/en.png',
imageWidth: 24, // in pixles
@tmkasun
tmkasun / Ubuntu wake on LAN.md
Created Feb 15, 2020
Setting up wakeonlan useful commands
View Ubuntu wake on LAN.md

Check wake on lan supported and enabled in hardware

sudo ethtool <NIC>

wakeonland command installation

in mac use

View md.js
{
.
.
.
externals: {
Themes: 'AppThemes', // Should use long names for preventing global scope JS variable conflicts
MaterialIcons: 'MaterialIcons',
Config: 'AppConfig',
}
}