Skip to content

Instantly share code, notes, and snippets.

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

Kasun Vithanage kasvith

🏠
Working from home
View GitHub Profile
@kasvith
kasvith / bash-colors.md
Created April 7, 2017 17:40 — forked from iamnewton/bash-colors.md
The entire table of ANSI color codes.

Regular Colors

Value Color
\e[0;30m Black
\e[0;31m Red
\e[0;32m Green
\e[0;33m Yellow
\e[0;34m Blue
\e[0;35m Purple
@kasvith
kasvith / Manderbolt smooth color
Created August 4, 2017 15:53
Manderbolt smooth color
public Color getFractalColor(FractalPointData fractalPointData){
double mu = fractalPointData.getIterations() + 1 - Math.log(Math.log(fractalPointData.getConvergedAbsolute()/LOG2)/LOG2);
int red = (int)(Math.sin(redFrequency * mu + redChannelPhase) * 128f + 127f);
int green = (int)(Math.sin(greenFrequency * mu + greenChannelPhase) * 128f + 127f);
int blue = (int)(Math.sin(blueFrequency * mu + blueChannelPhase) * 128f + 127f);
red = Utils.Clamp(red, 0, 255);
green = Utils.Clamp(green, 0, 255);
blue = Utils.Clamp(blue, 0 , 255);
@kasvith
kasvith / Manderbolt smooth color
Created August 4, 2017 15:53
Manderbolt smooth color
public Color getFractalColor(FractalPointData fractalPointData){
double mu = fractalPointData.getIterations() + 1 - Math.log(Math.log(fractalPointData.getConvergedAbsolute()/LOG2)/LOG2);
int red = (int)(Math.sin(redFrequency * mu + redChannelPhase) * 128f + 127f);
int green = (int)(Math.sin(greenFrequency * mu + greenChannelPhase) * 128f + 127f);
int blue = (int)(Math.sin(blueFrequency * mu + blueChannelPhase) * 128f + 127f);
red = Utils.Clamp(red, 0, 255);
green = Utils.Clamp(green, 0, 255);
blue = Utils.Clamp(blue, 0 , 255);
@kasvith
kasvith / manderbolt.smoothcolor.java
Last active August 5, 2017 05:41
Manderbolt smooth color. Use LOG2 as Math.log(2); Use converged Z absolute
public Color getFractalColor(FractalPointData fractalPointData){
double mu = fractalPointData.getIterations() + 1 - Math.log(Math.log(fractalPointData.getConvergedAbsolute()/LOG2)/LOG2);
int red = (int)(Math.sin(redFrequency * mu + redChannelPhase) * 128f + 127f);
int green = (int)(Math.sin(greenFrequency * mu + greenChannelPhase) * 128f + 127f);
int blue = (int)(Math.sin(blueFrequency * mu + blueChannelPhase) * 128f + 127f);
red = Utils.Clamp(red, 0, 255);
green = Utils.Clamp(green, 0, 255);
blue = Utils.Clamp(blue, 0 , 255);
@kasvith
kasvith / main.c
Created February 12, 2018 19:20
C Hello world
#include <stdio.h>
int main()
{
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
}
@kasvith
kasvith / index.js
Created February 19, 2018 13:51
NodeJS TCP server
'use strict'
const net = require('net')
net.createServer((socket) => {
socket.on('data', (payload) => {
socket.write('Echo server\r\n')
console.info(`Client: ${socket.remoteAddress} Data: %s`, payload)
})
@kasvith
kasvith / pom.xml
Created February 21, 2018 16:37
Web App POM
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.kasun</groupId>
<artifactId>AddressBook</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>AddressBook Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<template>
<router-view></router-view>
</template>
<script>
export default {
}
</script>
<template>
<v-app id="inspire">
<v-navigation-drawer
fixed
v-model="drawer"
app
>
<v-list dense>
<v-list-tile>
<v-list-tile-action>
'use strict'
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export const store = new Vuex.Store({
state: {
layout: 'simple-layout'