Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Kasun Thennakoon tmkasun

🏠
Working from home
View GitHub Profile
@tmkasun
tmkasun / demo.md
Created May 5, 2021
Demo - Effect of blocking the main event loop in JavaScript
View demo.md
  • Open the Link
  • Open the Developer console
  • And type
setInterval(() => {var a = Date.now(); while(Date.now() - a < 1000);},3000)
  • Open the performace monitor in the browser
  • And you will see the below CPU usage pattern image
View settings.json
{
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"python.languageServer": "Pylance",
"[xml]": {
"editor.defaultFormatter": "DotJoshJohnson.xml"
},
"npm.packageManager": "npm",
"editor.rulers": [
120
@tmkasun
tmkasun / launch.json
Last active Mar 30, 2021
vscode launch file
View launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "DebugWebpack",
@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 Jun 26, 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 / 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 / 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